Plugin for cell segmentation in 3D

    cellseg3d logo

    Code style: black License: MIT PyPI Python Version codecov napari hub

    A napari plugin for 3D cell segmentation: training, inference, and data review. In particular, this project was developed for analysis of mesoSPIM-acquired (cleared tissue + lightsheet) datasets.

    Help us make the code better by reporting issues and adding your feature requests!


    New version : v0.1.2

    • Fixed manifest issue for PyPi

    Previous additions :

    • Improved training interface
    • Unsupervised model : WNet
      • Generate labels directly from raw data !
      • Can be trained in napari directly or in Colab
      • Pretrained weights for mesoSPIM whole-brain cell segmentation
    • WandB support (install wandb and login to use automatically when training)
    • Remade and improved documentation
      • Moved to Jupyter Book
      • Dedicated installation page, and working ARM64 install for macOS Silicon users
    • New utilities
    • Many small improvements and many bug fixes




    See the Installation page in the documentation for detailed instructions.

    M1 Mac users

    To avoid issues when installing on the ARM64 architecture, please follow these steps.

    1. Create a new conda env using the provided conda/napari_cellseg3d_m1.yml file :

       git clone https://github.com/AdaptiveMotorControlLab/CellSeg3d.git
       cd CellSeg3d
       conda env create -f conda/napari_cellseg3d_m1.yml
       conda activate napari_cellseg3d_m1
    2. Install the plugin. From repository root folder, run :

       pip install -e .

      OR directly via PyPi :

       pip install napari-cellseg3d

      OR directly via napari-hub (see Installation section above)


    Available at https://AdaptiveMotorControlLab.github.io/CellSeg3d

    You can also generate docs by running make html in the docs/ folder.


    To use the plugin, please run:


    Then go into Plugins > napari-cellseg3d, and choose which tool to use.

    • Review: This module allows you to review your labels, from predictions or manual labeling, and correct them if needed. It then saves the status of each file in a csv, for easier monitoring.
    • Inference: This module allows you to use pre-trained segmentation algorithms on volumes to automatically label cells and compute statistics.
    • Train: This module allows you to train segmentation algorithms from labeled volumes.
    • Utilities: This module allows you to perform several actions like cropping your volumes and labels dynamically, by selecting a fixed size volume and moving it around the image; computing prediction scores from ground truth and predicition labels; or converting labels from instance to segmentation and the opposite.


    Python 3.8 or 3.9 required. Requires napari, PyTorch and MONAI.

    For PyTorch, please see the PyTorch website for installation instructions.

    A CUDA-capable GPU is not needed but very strongly recommended, especially for training.

    If you get errors from MONAI regarding missing readers, please see MONAI's optional dependencies page for instructions on getting the readers required by your images.


    If you encounter any problems, please file an issue along with a detailed description.


    Before testing, install all requirements using pip install napari-cellseg3d[test].

    pydensecrf is also required for testing.

    To run tests locally:

    • Locally : run pytest in the plugin folder
    • Locally with coverage : In the plugin folder, run coverage run --source=napari_cellseg3d -m pytest then coverage xml to generate a .xml coverage file.
    • With tox : run tox in the plugin folder (will simulate tests with several python and OS configs, requires substantial storage space)


    Contributions are very welcome.

    Please ensure the coverage at least stays the same before you submit a pull request.

    For local installation from Github cloning, please run:

    pip install -e .


    Distributed under the terms of the MIT license.

    "napari-cellseg3d" is free and open source software.


    This plugin was developed by Cyril Achard, Maxime Vidal, Mackenzie Mathis. This work was funded, in part, from the Wyss Center to the Mathis Laboratory of Adaptive Motor Control. Please refer to the documentation for full acknowledgements.

    Plugin base

    This napari plugin was generated with Cookiecutter using @napari's cookiecutter-napari-plugin template.


    • 0.1.2

    Last updated:

    • 02 April 2024

    First released:

    • 25 June 2022


    Supported data:

    • Information not submitted

    Plugin type:

    GitHub activity:

    • Stars: 43
    • Forks: 7
    • Issues + PRs: 5

    Python versions supported:

    Operating system:


    • numpy
    • napari[all]>=0.4.14
    • QtPy
    • scikit-image>=0.19.2
    • matplotlib>=3.4.1
    • tifffile>=2022.2.9
    • imagecodecs>=2023.3.16
    • torch>=1.11
    • monai[einops,nibabel]>=0.9.0
    • itk
    • tqdm
    • pyclesperanto-prototype
    • matplotlib

    Sign up to receive updates