/StarDist3D

Primary LanguagePythonBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

StarDist3D

This repository contains a user-friendly PyTorch implementation of StarDist 3D for nuclei segmentation based on:

Examples (from C. elegans embryos)

Input images StarDist3D predictions
Input image 1 Prediction 1
Input image 2 Prediction 2

Installation

You should have a C++ compiler installed as this code relies on C/C++ extensions that need to be compiled. You may follow these steps to install Stardist 3D:

  1. Download the repo:

     git clone https://github.com/itarampoulous/StarDist3D
    
  2. Create a python 3.7.9 conda environment with cuda toolkit for GPU-based computing:

     conda create --name "environment_name" python=3.7.9 cudatoolkit
    
  3. Activate the conda environment:

     conda activate "environment_name"
    
  4. Navigate to the directory (StarDist3D) containing the requirements.txt file and install the dependencies:

     pip install -r ./requirements.txt
    
  5. Install the package by running from the same directory containing the setup.py script:

     pip install .
    

Run from the command line

Training

Training using a training configuration file (see example):

trainStardist3D --config path/to/training_configuration.yml

Note that the dataset has to have the following structure:

    dataset
            ── train
                    ├── images
                    ├── masks

            ── val (optional, if you want to evaluate during training)
                    ├── images
                    ├── masks

Inference

Prediction using a prediction configuration file (see example):

predictStardist3D --config path/to/prediction_configuration.yml

Evaluation

Evaluation using an evaluation configuration file (see example):

evaluateStardist3D --config path/to/evaluation_configuration.yml

Examples of evaluation metrics generated by evaluateStardist3D on C. elegans embryo:

Evaluation on ground truth nuclei centroids Evaluation on ground truth masks
Evaluation centroidsGT 1 Evaluation masksGT 1
Evaluation centroidsGT 2 Evaluation masksGT 2

Run on a Jupyter Notebook

Training

You can use the Jupyter Notebook for StarDist3D training from the examples to train a StarDist3D model.

Inference

You can use the Jupyter Notebook for StarDist3D predictions from the examples to make predictions using a trained StarDist3D model.

Evaluation

You can use the Jupyter Notebook for StarDist3D evaluations from the examples to evaluate the model's predictions using nuclear centroids or nuclear masks as ground truths.