This repository provides a fully automated pipeline for analyzing multi-channel confocal microscopy images of cells. It uses:
Cellposefor instance segmentation of cytoplasm and nuclei- Percentile-based thresholding for mitochondria and 2SC detection
- Quantitative extraction of intensity metrics and colocalization statistics
The pipeline operates on .tiff images with 4 channels and outputs per-image segmentation masks, overlays, and summary CSV reports.
-
🖼️ Preprocessing
- Recursively loads
.tiffimages and normalizes channels using global percentile thresholds.
- Recursively loads
-
🧫 Segmentation
- Cytoplasm & nuclei via Cellpose
- Mitochondria & 2SC via global thresholding (e.g. 90th / 95th percentile in normalized space)
-
📊 Quantification
- Calculates 2SC intensity in cytoplasm (excluding nucleus & mitochondria) and in nucleus (excluding mitochondria)
- Computes mitochondrial colocalization with 2SC
- Estimates per-cell areas for cytoplasm, nuclei, and mitochondria
-
🎨 Overlay Generation
- Produces visual overlays of segmented structures for interpretation
-
📁 Batch Processing
- Automatically processes all
.tiffimages in subdirectories - Stores outputs in organized folders
- Saves CSV summary reports
- Automatically processes all
Each input image must be a .tiff file with 4 channels, representing:
| Channel Index | Target Structure |
|---|---|
0 |
Nucleus |
1 |
Cytoplasm |
2 |
Mitochondria |
3 |
2SC Staining |
Images can be organized into subfolders (e.g., by experimental condition or cell type). The script handles recursive traversal and processing.
Install dependencies with:
pip install numpy tifffile scikit-image matplotlib opencv-python cellposeCellpose will optionally use a GPU if available.
Modify the paths and channel indices in the __main__ section of multi_channel_cell_segmentation.py:
raw_data_path = '/path/to/raw_images/' # input directory (recursively scanned)
top_level_output_path = '/path/to/output/'
nuclei_channel = 0
cyto_channel = 1
mito_channel = 2
sc_channel = 3Then, run the script:
python multi_channel_cell_segmentation.pyFor each image:
| Output File | Description |
|---|---|
*_Processed_Image.tiff |
Normalized and downsampled image |
*_Cytoplasm_Mask.tiff |
Segmented cytoplasm overlay |
*_Nucleus_Mask.tiff |
Segmented nucleus overlay |
*_Mitochondria_Mask.tiff |
Mitochondria mask from thresholding |
*_Segmentation_Overlay.tiff |
Overlay of cytoplasm and nucleus |
*_MitoCyto2SC_Overlay.tiff |
Combined overlay of all structures |
*_cellwise_areas.csv |
Per-cell area stats (cytoplasm, nucleus, mito) |
Intensity_Colocalisation_data.csv |
Summary stats per image (2SC, colocalisation) |
This pipeline is ideal for:
- Quantifying 2SC localization patterns across cell types
- Evaluating mitochondrial-2SC colocalization metrics
- Extracting cell-wise morphometrics for statistical analysis
- Generating overlay visualizations for publication or QC
For questions, bugs, or contributions, feel free to open an issue or reach out!