This repository contains a lightweight, still-in-development workflow for processing ZooScan TIFF images using Python and Snakemake.
It is not a complete or official replacement for ZooProcess/ImageJ — just a practical experimental pipeline intended for local research use.
The pipeline runs in three main steps, mirroring the Snakefile:
- Load raw ZooScan
.tif - Subtract background (large master TIFF)
- Apply optional smoothing / clipping
- Output:
data/work/<sample>_preprocessed.tif
- Threshold using hybrid Otsu + local window
- Extract connected components
- Crop ROI PNGs
- Measure morphometrics
- Output:
data/raw_rois/<sample>/*.pngdata/tables/<sample>_objects.tsv
- Re-segment inside each ROI
- Keep only the largest component
- Dilate to keep fine structures (antennae, setae, etc.)
- Mask background to pure white
- Apply tone adjustment (gamma)
- Output:
data/cleaned_rois/<sample>/*.pngdata/tables/<sample>_objects_clean.tsv
Below are three examples (from comparison_examples/) showing:
- Left: Original ZooScan (ImageJ workflow)
- Middle: Raw ROI (this pipeline)
- Right: Masked/Cleaned ROI (this pipeline)
| Original ZooScan | Raw ROI (this pipeline) | Masked ROI (this pipeline) |
|---|---|---|
![]() |
![]() |
![]() |
| Original ZooScan | Raw ROI (this pipeline) | Masked ROI (this pipeline) |
|---|---|---|
![]() |
![]() |
![]() |
| Original ZooScan | Raw ROI (this pipeline) | Masked ROI (this pipeline) |
|---|---|---|
![]() |
![]() |
![]() |
Create the environment:
conda env create -f env.yaml
conda activate zooprocess_py
Dry run:
snakemake -np
Run full pipeline:
snakemake -c 8
- Not a full replica of ZooProcess
- Background subtraction less sophisticated than ImageJ macros
- Segmentation may require tuning per sample
- Cleanup still experimental
- Manual curation recommended before EcoTaxa upload
MIT License
This software is provided “as-is” with no guarantee of correctness or suitability.
Use at your own risk.








