{"name":"napari-cellseg3d","display_name":"CellSeg3D","visibility":"public","icon":"","categories":[],"schema_version":"0.0.4","on_activate":null,"on_deactivate":null,"contributions":{"commands":[{"id":"napari-cellseg3d.load","title":"Create reviewer","python_name":"napari_cellseg3d.plugins:Reviewer","short_title":null,"category":null,"icon":null,"enablement":null},{"id":"napari-cellseg3d.help","title":"Create Help","python_name":"napari_cellseg3d.plugins:Helper","short_title":null,"category":null,"icon":null,"enablement":null},{"id":"napari-cellseg3d.utils","title":"Create utilities","python_name":"napari_cellseg3d.plugins:Utilities","short_title":null,"category":null,"icon":null,"enablement":null},{"id":"napari-cellseg3d.infer","title":"Create Inference widget","python_name":"napari_cellseg3d.plugins:Inferer","short_title":null,"category":null,"icon":null,"enablement":null},{"id":"napari-cellseg3d.train","title":"Create Trainer widget","python_name":"napari_cellseg3d.plugins:Trainer","short_title":null,"category":null,"icon":null,"enablement":null}],"readers":null,"writers":null,"widgets":[{"command":"napari-cellseg3d.load","display_name":"Labeling","autogenerate":false},{"command":"napari-cellseg3d.infer","display_name":"Inference","autogenerate":false},{"command":"napari-cellseg3d.train","display_name":"Training","autogenerate":false},{"command":"napari-cellseg3d.utils","display_name":"Utilities","autogenerate":false},{"command":"napari-cellseg3d.help","display_name":"Help/About...","autogenerate":false}],"sample_data":null,"themes":null,"menus":{},"submenus":null,"keybindings":null,"configuration":[]},"package_metadata":{"metadata_version":"2.4","name":"napari-cellseg3d","version":"0.2.4","dynamic":["license-file"],"platform":null,"supported_platform":null,"summary":"Plugin for cell segmentation in 3D","description":"# CellSeg3D: self-supervised (and supervised) 3D cell segmentation, primarily for mesoSPIM data!\n\n<!-- [![napari hub](https://img.shields.io/endpoint?url=https://api.napari-hub.org/shields/napari-cellseg3d)](https://www.napari-hub.org/plugins/napari_cellseg3d) -->\n\n[![PyPI](https://img.shields.io/pypi/v/napari-cellseg3d.svg?color=green)](https://pypi.org/project/napari-cellseg3d)\n[![Python versions](https://img.shields.io/pypi/pyversions/napari-cellseg3d)](https://pypi.org/project/napari-cellseg3d)\n[![Downloads](https://static.pepy.tech/badge/napari-cellseg3d)](https://pepy.tech/project/napari-cellseg3d)\n[![Downloads](https://static.pepy.tech/badge/napari-cellseg3d/month)](https://pepy.tech/project/napari-cellseg3d)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/AdaptiveMotorControlLab/CellSeg3D/raw/main/LICENSE)\n[![codecov](https://codecov.io/gh/AdaptiveMotorControlLab/CellSeg3D/branch/main/graph/badge.svg?token=hzUcn3XN8F)](https://codecov.io/gh/AdaptiveMotorControlLab/CellSeg3D)\n[![Code style:Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n\n<img src=\"https://images.squarespace-cdn.com/content/v1/57f6d51c9f74566f55ecf271/838605d0-9723-4e43-83cd-6dbfe4adf36b/cellseg-logo.png?format=1500w\" title=\"cellseg3d\" alt=\"cellseg3d logo\" width=\"150\" align=\"right\" vspace = \"80\"/>\n\n**A package for 3D cell segmentation with deep learning, including a napari plugin**: training, inference, and data review. In particular, this project was developed for analysis of confocal and mesoSPIM-acquired (cleared tissue + lightsheet) tissue datasets, but is not limited to this type of data. [Check out our publication for more information!](https://elifesciences.org/articles/99848)\n\n![demo](https://images.squarespace-cdn.com/content/v1/57f6d51c9f74566f55ecf271/0d16a71b-3ff2-477a-9d83-18d96cb1ce28/full_demo.gif?format=500w)\n\n## Installation\n\n💻 See the [Installation page](https://adaptivemotorcontrollab.github.io/CellSeg3D/welcome.html) in the documentation for detailed instructions.\n\n## Documentation\n\n📚 Documentation is available at [https://AdaptiveMotorControlLab.github.io/CellSeg3D](https://adaptivemotorcontrollab.github.io/CellSeg3D/welcome.html)\n\n📚 For additional examples and how to reproduce our paper figures, see: [https://github.com/C-Achard/cellseg3d-figures](https://github.com/C-Achard/cellseg3d-figures)\n\n## Quick Start\n\n```\npip install napari_cellseg3d\n```\n\nTo use the plugin, please run:\n\n```\nnapari\n```\n\nThen go into `Plugins > napari_cellseg3d`, and choose which tool to use.\n\n- **Review (label)**: 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.\n- **Inference**: This module allows you to use pre-trained segmentation algorithms on volumes to automatically label cells and compute statistics.\n- **Train**: This module allows you to train segmentation algorithms from labeled volumes.\n- **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; fragment images into smaller cubes for training; or converting labels from instance to segmentation and the opposite.\n\n## Why use CellSeg3D?\n\nThe strength of our approach is we can match supervised model performance with purely self-supervised learning, meaning users don't need to spend (hundreds) of hours on annotation. Here is a quick look of our key results. TL;DR see panel **f**, which shows that with minmal input data we can outperform supervised models:\n\n![FIG1 (1)](https://github.com/user-attachments/assets/0d970b45-79ff-4c58-861f-e1e7dc9abc65)\n\n**Figure 1. Performance of 3D Semantic and Instance Segmentation Models.**\n**a:** Raw mesoSPIM whole-brain sample, volumes and corresponding ground truth labels from somatosensory (S1) and visual (V1) cortical regions.\n**b:** Evaluation of instance segmentation performance for baseline\nthresholding-only, supervised models: Cellpose, StartDist, SwinUNetR, SegResNet, and our self-supervised model WNet3D over three data subsets.\nF1-score is computed from the Intersection over Union (IoU) with ground truth labels, then averaged. Error bars represent 50% Confidence Intervals\n(CIs).\n**c:** View of 3D instance labels from supervised models, as noted, for visual cortex volume in b evaluation.\n**d:** Illustration of our WNet3D architecture showcasing the dual 3D U-Net structure with our modifications.\n\n## News\n\n### **CellSeg3D now published at eLife**\n\nRead the [article here !](https://elifesciences.org/articles/99848)\n\n### **New version: v0.2.4**\n\n- v0.2.4:\n  - Python 3.10-12 support added\n  - Several fixes to deprecation errors on newer Python versions\n  - Upgraded packaging to use only pyproject.toml\n  - Added uv.lock to repository for more reproducible installs\n\n> [!WARNING]\n> If you are still getting errors related to `in_channels` on the SwinUNetR model, please open an issue and report your MONAI version. Thanks!\n\n- v0.2.2:\n\n  - Updated the Colab Notebooks for training and inference\n  - New models available in the inference demo notebook\n  - CRF optional post-processing adjustments (and pip install directly)\n\n- v0.2.1:\n\n  - Updated plugin default behaviors across the board to be more readily applicable to demo data\n  - Threshold value in inference is now automatically set by default according to performance on demo data on a per-model basis\n  - Added a grid search utility to find best thresholds for supervised models\n\n- v0.2.0:\n\n  - Changed project name to \"napari_cellseg3d\" to avoid setuptools deprecation\n  - Small API changes for training/inference from a script\n  - Some fixes to WandB integration and csv saving after training\n\nPrevious additions:\n\n- v0.1.2: Fixed manifest issue for PyPi\n- Improved training interface\n- Unsupervised model : WNet3D\n  - Generate labels directly from raw data!\n  - Can be trained in napari directly or in Google Colab\n  - Pretrained weights for mesoSPIM whole-brain cell segmentation\n- WandB support (install wandb and login to use automatically when training)\n- Remade and improved documentation\n  - Moved to Jupyter Book\n  - Dedicated installation page, and working ARM64 install for macOS Silicon users\n- New utilities\n- Many small improvements and many bug fixes\n\n## Requirements\n\n**Compatible with Python 3.10 to 3.12.**\nRequires **[napari]**, **[PyTorch]** and **[MONAI]**.\nCompatible with Windows, MacOS and Linux.\nInstallation of the plugin itself should not take more than 30 minutes, depending on your internet connection,\nand whether you already have Python and a package manager installed.\n\nFor PyTorch, please see [the PyTorch website for installation instructions].\n\nA CUDA-capable GPU is not needed but very strongly recommended, especially for training.\n\nIf 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.\n\nPlease reach out if you have any issues with the installation, we will be happy to help!\n\n### Install note for ARM64 (Silicon) Mac users\n\nTo avoid issues when installing on the ARM64 architecture, please follow these steps.\n\n1. Create a new conda env using the provided conda/napari_CellSeg3D_ARM64.yml file :\n\n   ```\n    git clone https://github.com/AdaptiveMotorControlLab/CellSeg3d.git\n    cd CellSeg3d\n    conda env create -f conda/napari_CellSeg3D_ARM64.yml\n    conda activate napari_CellSeg3D_ARM64\n   ```\n\n1. Install a Qt backend (PySide or PyQt5)\n\n1. Launch napari, the plugin should be available in the plugins menu.\n\n## Issues\n\n**Help us make the code better by reporting issues and adding your feature requests!**\n\nIf you encounter any problems, please [file an issue] along with a detailed description.\n\n## Testing\n\nYou can generate docs locally by running `make html` in the docs/ folder.\n\nBefore testing, install all requirements using `pip install napari-cellseg3d[test]`.\n\n`pydensecrf` is also required for testing.\n\nTo run tests locally:\n\n- Locally : run `pytest napari_cellseg3d\\_tests` in the plugin folder.\n- Locally with coverage : In the plugin folder, run `coverage run --source=napari_cellseg3d -m pytest` then `coverage xml` to generate a .xml coverage file.\n- With tox : run `tox` in the plugin folder (will simulate tests with several python and OS configs, requires substantial storage space)\n\n## Contributing\n\nContributions are very welcome.\n\nPlease ensure the coverage at least stays the same before you submit a pull request.\n\nFor local installation from Github cloning, please run:\n\n```\npip install -e .\n```\n\n## License\n\nDistributed under the terms of the [MIT] license.\n\n\"napari-cellseg3d\" is free and open source software.\n\n## Citation\n\n```\n@article {10.7554/eLife.99848,\narticle_type = {journal},\ntitle = {CellSeg3D, Self-supervised 3D cell segmentation for fluorescence microscopy},\nauthor = {Achard, Cyril and Kousi, Timokleia and Frey, Markus and Vidal, Maxime and Paychere, Yves and Hofmann, Colin and Iqbal, Asim and Hausmann, Sebastien B and Pagès, Stéphane and Mathis, Mackenzie Weygandt},\neditor = {Cardona, Albert},\nvolume = 13,\nyear = 2025,\nmonth = {jun},\npub_date = {2025-06-24},\npages = {RP99848},\ncitation = {eLife 2025;13:RP99848},\ndoi = {10.7554/eLife.99848},\nurl = {https://doi.org/10.7554/eLife.99848},\nabstract = {Understanding the complex three-dimensional structure of cells is crucial across many disciplines in biology and especially in neuroscience. Here, we introduce a set of models including a 3D transformer (SwinUNetR) and a novel 3D self-supervised learning method (WNet3D) designed to address the inherent complexity of generating 3D ground truth data and quantifying nuclei in 3D volumes. We developed a Python package called CellSeg3D that provides access to these models in Jupyter Notebooks and in a napari GUI plugin. Recognizing the scarcity of high-quality 3D ground truth data, we created a fully human-annotated mesoSPIM dataset to advance evaluation and benchmarking in the field. To assess model performance, we benchmarked our approach across four diverse datasets: the newly developed mesoSPIM dataset, a 3D platynereis-ISH-Nuclei confocal dataset, a separate 3D Platynereis-Nuclei light-sheet dataset, and a challenging and densely packed Mouse-Skull-Nuclei confocal dataset. We demonstrate that our self-supervised model, WNet3D – trained without any ground truth labels – achieves performance on par with state-of-the-art supervised methods, paving the way for broader applications in label-scarce biological contexts.},\nkeywords = {self-supervised learning, artificial intelligence, neuroscience, mesoSPIM, confocal microscopy, platynereis},\njournal = {eLife},\nissn = {2050-084X},\npublisher = {eLife Sciences Publications, Ltd},\n}\n```\n\n## Acknowledgements\n\nThis plugin was developed by originally Cyril Achard, Maxime Vidal, Mackenzie Mathis.\nThis work was funded, in part, from the Wyss Center to the [Mathis Laboratory of Adaptive Intelligence](https://www.mackenziemathislab.org/).\nPlease refer to the documentation for full acknowledgements.\n\n## Plugin base\n\nThis [napari] plugin was generated with [Cookiecutter] using [@napari]'s [cookiecutter-napari-plugin] template.\n\n[@napari]: https://github.com/napari\n[cookiecutter]: https://github.com/audreyr/cookiecutter\n[cookiecutter-napari-plugin]: https://github.com/napari/cookiecutter-napari-plugin\n[file an issue]: https://github.com/AdaptiveMotorControlLab/CellSeg3D/issues\n[mit]: http://opensource.org/licenses/MIT\n[monai]: https://docs.monai.io/en/stable/installation.html#installing-the-recommended-dependencies\n[monai's optional dependencies]: https://docs.monai.io/en/stable/installation.html#installing-the-recommended-dependencies\n[napari]: https://github.com/napari/napari\n[pytorch]: https://pytorch.org/get-started/locally/\n[the pytorch website for installation instructions]: https://pytorch.org/get-started/locally/\n","description_content_type":"text/markdown","keywords":null,"home_page":null,"download_url":null,"author":null,"author_email":"Cyril Achard <cyril.achard@epfl.ch>, Maxime Vidal <maxime.vidal@epfl.ch>, Mackenzie Mathis <mackenzie@post.harvard.edu>","maintainer":null,"maintainer_email":null,"license":"MIT","classifier":["Development Status :: 4 - Beta","Framework :: napari","Intended Audience :: Science/Research","License :: OSI Approved :: MIT License","Operating System :: OS Independent","Programming Language :: Python","Programming Language :: Python :: 3 :: Only","Programming Language :: Python :: 3.10","Programming Language :: Python :: 3.11","Programming Language :: Python :: 3.12","Topic :: Scientific/Engineering :: Artificial Intelligence","Topic :: Scientific/Engineering :: Image Processing","Topic :: Scientific/Engineering :: Visualization","Topic :: Software Development :: Testing"],"requires_dist":["imagecodecs>=2023.3.16","itk","matplotlib>=3.4.1","monai[einops,nibabel,tifffile]>=0.9","napari[all]>=0.4.14","numpy","pyclesperanto","pydensecrf2","qtpy","scikit-image>=0.19.2","torch>=1.11","tqdm","pydensecrf2; extra == \"crf\"","pre-commit; extra == \"dev\"","ruff; extra == \"dev\"","twine; extra == \"dev\"","jupyter-book<2; extra == \"docs\"","onnx; extra == \"onnx-cpu\"","onnxruntime; extra == \"onnx-cpu\"","onnx; extra == \"onnx-gpu\"","onnxruntime-gpu; extra == \"onnx-gpu\"","napari[pyqt6]; extra == \"pyqt6\"","napari[pyside6]; extra == \"pyside6\"","coverage; extra == \"test\"","onnx; extra == \"test\"","onnxruntime; extra == \"test\"","pytest; extra == \"test\"","pytest-cov; extra == \"test\"","pytest-qt; extra == \"test\"","tox; extra == \"test\"","twine; extra == \"test\"","wandb; extra == \"wandb\""],"requires_python":">=3.10","requires_external":null,"project_url":["Documentation, https://adaptivemotorcontrollab.github.io/cellseg3d-docs/res/welcome.html","Homepage, https://github.com/AdaptiveMotorControlLab/CellSeg3D","Issues, https://github.com/AdaptiveMotorControlLab/CellSeg3D/issues"],"provides_extra":["crf","dev","docs","onnx-cpu","onnx-gpu","pyqt6","pyside6","test","wandb"],"provides_dist":null,"obsoletes_dist":null},"npe1_shim":false}