Cell segmentation and ROI analysis tool. Supports Cellpose and StarDist segmentation engines with a modern PyQt6 interface.
- Segmentation — Run Cellpose (including SAM) or StarDist on microscopy images
- ROI Analysis — Convert segmentation masks to quantitative measurements (area, integrated density, mean gray value, standard deviation) exported as Excel spreadsheets
- Dataset Viewer — Browse large image folders with lazy-loaded thumbnails, zoom/pan preview, and keyboard navigation
- Spreadsheet Import — Parse experiment xlsx files (FIM sheet format) to extract image paths with well/channel/stage filters
- Training — Fine-tune Cellpose models on your own labelled data
- Image Preprocessing — Denoise, deblur, and upsample images using Cellpose restoration models
Download install_and_run.bat and double-click it. Or from a terminal:
curl -O https://raw.githubusercontent.com/we-02/S2L/main/install_and_run.bat
install_and_run.bat
The script will:
- Clone the repository to
%USERPROFILE%\S2L - Create a conda environment with Python 3.11
- Install all dependencies
- Detect your GPU and ask if you want CUDA acceleration
- Launch the app
Subsequent runs pull updates, sync dependencies, and launch.
curl -O https://raw.githubusercontent.com/we-02/S2L/main/install_and_run.sh
chmod +x install_and_run.sh
./install_and_run.shPyTorch is installed CPU-only on macOS (no CUDA support).
curl -O https://raw.githubusercontent.com/we-02/S2L/main/install_and_run.sh
chmod +x install_and_run.sh
./install_and_run.shIf an NVIDIA GPU is detected, the script asks whether to install PyTorch with CUDA support.
If you prefer to set things up yourself:
git clone https://github.com/we-02/S2L.git
cd S2L
conda create -n S2L python=3.11 -y
conda activate S2L
pip install -r requirements.txtFor GPU acceleration on Windows/Linux:
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118For CPU-only (macOS or no NVIDIA GPU):
pip install torch torchvisionThen run:
python main.py- Open the Segmentation page
- Set input mode to Folder
- Browse for your image directory and output directory
- Choose an engine (Cellpose or StarDist) and model
- Enable "Run segmentation" and/or "Run label → ROI analysis"
- Click Start processing
- Set input mode to Spreadsheet
- Browse for your experiment
.xlsxfile - Click Parse spreadsheet
- Use the Well / Stage / Channel / Type checkboxes to filter images
- Set an output directory
- Click Start processing
Masks are saved to the output directory. The ROI step generates Excel files and overlay images there as well.
Navigate to the Viewer page to browse image folders. Click Open folder or use the View buttons next to directory inputs on other pages. Supports:
- Thumbnail grid with lazy loading
- Click to preview, scroll to zoom, drag to pan
- Arrow keys to navigate, Escape to deselect
- Filename filter bar
S2L/
├── main.py # Entry point
├── run_s2l.py # Alternative entry with dependency check
├── install_and_run.bat # Windows launcher
├── install_and_run.sh # macOS/Linux launcher
├── requirements.txt
├── s2l/
│ ├── core/
│ │ ├── segmenter.py # Cellpose segmentation engine
│ │ ├── stardist_segmenter.py# StarDist segmentation engine
│ │ ├── roi_converter.py # Mask → ROI measurements + overlay
│ │ ├── summary.py # Summary Excel generation
│ │ ├── trainer.py # Cellpose model training
│ │ └── spreadsheet_parser.py# Experiment xlsx parser
│ ├── ui/
│ │ ├── main_window.py # Main app window + all pages
│ │ ├── theme.py # Dark theme stylesheet
│ │ ├── dataset_viewer.py # Image browser with thumbnails
│ │ └── preprocessing_gui.py # Image enhancement tool
│ └── utils/
│ └── sam_utils.py # SAM model utilities
└── docs/ # Sphinx documentation
- Python 3.11
- PyQt6
- NumPy < 2.1 (for numba/stardist compatibility)
- OpenCV, scikit-image, scipy
- pandas, openpyxl, xlsxwriter
- Cellpose >= 4.0
- PyTorch >= 2.0
- StarDist (optional)
See LICENSE for details.