CardioSeg is an interactive Python application for cell and nuclei segmentation, manual correction, spatial annotation, and quantitative analysis of H&E-stained cardiac histology images.
The application combines a napari-based desktop GUI with Cellpose segmentation, scikit-image measurements, and optional spatial transcriptomics annotation through Scanpy-compatible datasets.
Project status: Alpha
CardioSeg is ready for source distribution and internal evaluation. Segmentation quality should still be validated against your own annotated cardiomyocyte datasets before clinical, diagnostic, or production use.
- Load common microscopy image formats including TIFF, PNG and JPEG
- Segment cells and nuclei using configurable Cellpose diameter settings
- Inspect, recolor, and filter label layers in napari
- Manually correct segmentation masks and annotations
- Compute morphology and intensity measurements for labeled cells
- Export measurements to CSV for downstream workflows in Python, R, Fiji/ImageJ, or QuPath
- Attach optional spatial transcriptomics annotations and gene-expression overlays when compatible datasets are available
CardioSeg is best installed with conda or mamba because of platform-specific dependencies such as Qt, PyTorch, napari, and microscopy image I/O libraries.
git clone https://github.com/<username>/cardioseg.git
cd cardioseg
mamba env create -f environment.yml
mamba activate cardioseg
pip install -e .
python -m cardioseg.appIf you prefer conda:
conda env create -f environment.yml
conda activate cardiosegUse the Windows CUDA environment only on systems with a CUDA 11.8-compatible NVIDIA GPU and driver.
mamba env create -f environment_win.yml
mamba activate cardioseg-win
pip install -e .
python -m cardioseg.appFor Windows systems without CUDA support, use environment.yml instead.
Launch CardioSeg with:
python -m cardioseg.app- Open CardioSeg and load a microscopy image
- Configure segmentation settings such as approximate object diameter
- Run automated Cellpose segmentation
- Inspect cells and nuclei in napari
- Correct masks or annotations manually if needed
- Compute measurements and export CSV outputs
- Optionally load compatible spatial datasets for cell-type or gene-expression overlays
cardioseg/
├── app.py # Application entry point
├── assignment/ # Cell/nucleus relationship utilities
├── gui/ # napari widgets, panels, and Qt styling
├── io/ # Image and measurement I/O helpers
├── measurements/ # Morphology and texture measurements
├── models/ # Domain-specific data classes
├── segmentation/ # Cellpose wrappers and mask utilities
├── spatial/ # Spatial annotation and ROI helpers
└── utils/ # Shared utility code
environment.yml # CPU/cross-platform conda environment
environment_win.yml # Windows CUDA environment
pyproject.toml # Packaging metadata and console scripts
README.md # Project overview and usage
LICENSE # License information
CardioSeg currently focuses on CSV-based measurement export that can be loaded back into the GUI for retrospective analysis. In addition, the search bar allows for the output of a text file with statistical measurements, by the command:
stats()CardioSeg has been tested on:
- macOS (Intel and Apple Silicon)
- Windows 10/11
- Python 3.10
- CUDA 11.8
Performance depends on image size and available GPU memory.
This work is licensed under a Creative Commons Attribution 4.0 International License.
CardioSeg builds on the scientific Python imaging ecosystem, especially:
- napari
- Cellpose
- scikit-image
- Scanpy
- PyTorch
- tifffile