performs image segmentation by leveraging the colocalization of multiple fluorescence channels
Project description
napari-segmencolo
A napari plugin for AI-based segmentation with multichannel colocalization filtering, classification, and export to Imaris / Excel.
Developed during an internship in fluorescence imaging, to replace an Imaris-based workflow with a reproducible open-source pipeline.
This napari plugin was generated with copier using the napari-plugin-template.
Features
| Tab | What it does |
|---|---|
| ① Segmentation | StarDist · Cellpose · Ilastik-style pixel classification — 2D & 3D |
| ② Colocalization | KEEP/EXCLUDE filtering by fluorescence channel |
| ③ Classification | KMeans (unsupervised) or RandomForest (semi-supervised), with nameable classes |
| ④ Export Imaris | TIFF (all licenses) or IMS/HDF5 (native Imaris) + object counts to Excel |
| ⑤ Batch | Process a whole folder of CZI files automatically → Excel summary |
Works in 2D and on z-stacks (via MIP projection or slice-by-slice merging).
Installation
You can install napari-segmencolo via pip:
pip install napari-segmencolo
To install together with napari and a Qt backend:
pip install "napari-segmencolo[all]"
For development (from a local clone):
pip install -e ".[all]"
Quick start
1. Segmentation
- Open your image in napari (File > Open, or drag and drop).
- In the plugin, ① Segmentation tab:
- Select the layer to segment (e.g. DAPI for nuclei).
- Choose StarDist (recommended for round nuclei).
- Pick a Z handling mode — 2D projection (MIP) is recommended for counting (every nucleus counted once).
- Optional: draw a rectangle with the Shapes tool, then tick ROI.
- Click ▶ Run segmentation.
2. Colocalization filtering
Example: keep only the green nuclei that do NOT colocalize with the red channel.
- ② Colocalization tab → Add a rule.
- Select the red channel, mode EXCLUDE, threshold = 500, overlap = 0.3.
- Click ✔ Apply filtering.
A new Filtered_labels layer appears in napari.
3. Classification (e.g. healthy vs apoptotic nuclei)
- ③ Classification tab: pick the labels layer and a reference channel.
- Set the number of classes and name them (e.g. "Positive", "Negative").
- KMeans: classes are formed automatically from intensity + morphology. RandomForest: annotate a few labels by hand (label 3 → class 1, …), then classify.
The class names are reused as column headers in the Excel export.
4. Export for Imaris / counts
- ④ Export Imaris tab, select the labels layer to export.
- Enter the voxel size (µm) matching your acquisition.
- Click 💾 Export as TIFF (then in Imaris: File > Open > select the .tif).
- Click 📊 Export counts (Excel) to save object counts (total + per class).
To convert to Surfaces in Imaris:
Edit > Surfaces > Add New Surfaces > Detect from Channel.
5. Batch processing
- ⑤ Batch tab → Browse… to pick a folder of
.czifiles. - Channel names are read from the first file → choose the nuclei and marker channels by name.
- Set the segmentation parameters and (optionally) KMeans classification.
- Click ▶ Run batch → Excel to produce a summary table (one row per image). Tick Show each image + segmentation in napari to verify results visually.
File architecture
src/napari_segmencolo/
├── __init__.py # Package entry point (OpenMP workaround, exposes the widget)
├── napari.yaml # napari manifest (declares the widget)
├── _widget.py # Main GUI (the 5 tabs) and orchestration
├── segmentation.py # StarDist, Cellpose, Ilastik-style + Z-plane merging
├── colocalization.py # Multichannel colocalization filtering
├── classification.py # Feature extraction + KMeans / RandomForest
├── stats.py # Object counting + Excel export
├── czi_io.py # Direct CZI reading (channel names + MIP)
└── export_imaris.py # TIFF export
tests/
└── test_colocalization.py
Main dependencies
napari,qtpy— viewer and GUIstardist,cellpose— deep-learning segmentationscikit-image,scikit-learn— image processing and classificationpandas,numpy— data and arraystifffile— TIFF exportopenpyxl— Excel exporth5py— IMS / HDF5 export (optional)pylibCZIrw— CZI reading (batch mode)
The Ilastik-style mode is implemented in-house (scikit-image + scikit-learn); it does not require an Ilastik installation.
Author
Lena PROUX — Imaging internship. Plugin built to replace an Imaris-based workflow with a reproducible, open-source pipeline.
Credits and citations
This plugin builds on several open-source libraries. It does not redistribute
their source code — they are used as standard Python dependencies, installed
via pip, which every license below permits.
Software used
| Library | Role in the plugin | License |
|---|---|---|
| napari | Image viewer & plugin framework | BSD-3-Clause |
| StarDist | Nucleus segmentation | BSD-3-Clause |
| Cellpose | Cell / nucleus segmentation | BSD-3-Clause |
| scikit-image | Image processing & object features | BSD-3-Clause |
| scikit-learn | KMeans, RandomForest | BSD-3-Clause |
| pandas / NumPy | Tables & arrays | BSD-3-Clause |
| tifffile | TIFF export | BSD-3-Clause |
| openpyxl | Excel export | MIT |
| qtpy | Qt binding abstraction | MIT |
| h5py | IMS / HDF5 export | BSD-3-Clause |
| pylibCZIrw | CZI file reading (batch) | LGPL-3.0 |
Note on pylibCZIrw (LGPL-3.0): it is used as an unmodified, separately installed dependency (no source code is copied into this plugin). The LGPL permits this use within a BSD-licensed project; users remain free to replace or upgrade the library independently.
Please cite (for scientific use)
If you use the segmentation models in published work, please cite the original papers — this is requested by their authors and is independent of the software license:
- StarDist — Schmidt, U., Weigert, M., Broaddus, C., & Myers, G. (2018). Cell Detection with Star-Convex Polygons. MICCAI 2018. https://doi.org/10.1007/978-3-030-00934-2_30
- Cellpose — Stringer, C., Wang, T., Michaelos, M., & Pachitariu, M. (2021). Cellpose: a generalist algorithm for cellular segmentation. Nature Methods, 18, 100–106. https://doi.org/10.1038/s41592-020-01018-x
- napari — napari contributors (2019). napari: a multi-dimensional image viewer for Python. https://doi.org/10.5281/zenodo.3555620
Pretrained models
The StarDist and Cellpose pretrained models (2D_versatile_fluo, cyto3, …)
may carry their own usage terms. They are suitable for academic research; verify
their conditions before any commercial use.
Contributing
Contributions are very welcome. Tests can be run with tox; please ensure the coverage at least stays the same before you submit a pull request.
License
Distributed under the terms of the BSD-3 license, "napari-segmencolo" is free and open source software.
Issues
If you encounter any problems, please file an issue along with a detailed description.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file napari_segmencolo-0.1.0.tar.gz.
File metadata
- Download URL: napari_segmencolo-0.1.0.tar.gz
- Upload date:
- Size: 63.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e059999984aa22b2eca2de627d00edfaabc6a2761a9632786b28b6aef535d47c
|
|
| MD5 |
82d58eb6f937aa909a0038d9d149a87f
|
|
| BLAKE2b-256 |
a4157be85380b22594c4055220e56d90729f9a25c8809db2e3c26ec0b3f84370
|
File details
Details for the file napari_segmencolo-0.1.0-py3-none-any.whl.
File metadata
- Download URL: napari_segmencolo-0.1.0-py3-none-any.whl
- Upload date:
- Size: 55.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
275fcf0192592d7a57a7eae2710556bdb71f917477f39245b0a0c01b32e5b329
|
|
| MD5 |
a13cff3083739675db8e8464432dd007
|
|
| BLAKE2b-256 |
22ebfbe00808f802fe3887a670f670e831fe2529664dab67af25c5d357918d4a
|