Skip to main content

segment-kidney-structures

Purpose: This package is built to perform instance segmentation of kidney structures — glomeruli, tubules, and capillaries. The input is multiplexed fluorescence imaging (e.g. CODEX) of kidney biopsies. The input format is greyscale 16-bit .tif. The three pre-trained omnipose models corresponding to three major kidney structures (glomeruli, tubules, blood vessels) are finetuned and ready to be deployed. The outputs are segmentation masks (.tif and .npy) saved as a subfolder in the input directory.

Installation

pip install segment-kidney-structures
# or
uv pip install segment-kidney-structures

The three segmentation models require a working omnipose/ cellpose environment with GPU support (PyTorch + CUDA). Follow the omnipose installation guide to set up the omnipose venv.

Usage

1. Install segment-kidney-structures into an activated virtual environment

segment-kidney-structures must be installed into the same venv where omnipose is installed.

uv venv .venv
source .venv/bin/activate
uv pip install segment-kidney-structures

2. Generate segmentation inputs from specific marker channels

The current preprocessing script expects the following folder structure <root-dir>/<dataset>/<input-folder>/<marker>/, with one subfolder per marker containing matching-named TIFF images.

# Glomeruli: RGB composite from CD10, Claudin1, CD31 (+ DAPI for QC)
segment-kidney-structures preprocess-glomeruli \
    --root-dir /path/to/data --dataset your_dataset --input-folder your_folder_name

# Tubules: normalized sum of MUC1, Claudin1, CD138, CD10 channels
segment-kidney-structures preprocess-tubules \
    --root-dir /path/to/data --dataset your_dataset --input-folder your_folder_name

# Capillaries/vessels: CD31 
segment-kidney-structures preprocess-vessels \
    --root-dir /path/to/data --dataset your_dataset --input-folder your_folder_name

Troubleshooting tips:

  • Make sure the filenames in each marker folder match.
  • Set --markers based on your folder names (comma-separated).
  • The output files are saved under <root-dir>/<dataset>/<output-folder>/.
  • Make sure you visually check some input files before proceeding to the next step (aka segmentation). The correct inputs (16-bit gray-scale TIFF) should display the signals of the kidney structures with very clean background.

3. Run segmentation

All CLI commands are available under the segment-kidney-structures cli.py

segment-kidney-structures segment --structure glomeruli --input-dir /path/to/data/
segment-kidney-structures segment --structure tubules   --input-dir /path/to/data/
segment-kidney-structures segment --structure capillaries --input-dir /path/to/data/

CLI arguments:

  • --model-path to use your own model instead of the pretrained ones
  • --mask-threshold / --diameter to change based on your data; setting these will override the tuned default parameters
  • --no-gpu to run on CPU
  • --dry-run to print the commands without executing them

Additional details on the models

Structure Input channels Trained on
glomeruli 3 (RGB) CD10 / DAPI / Claudin1 / CD31 composite
tubules 1 MUC1 / Claudin1 / CD138 / CD10 sum
capillaries 1 CD31

Additional model training data, sizes, parameters, and applications were published at https://doi.org/10.64898/2026.01.14.699505.

Acknowledgement

This tool was made possible thanks to many brilliant scientists who have paved the way and provide feedback and guidance. Many thanks to the teams behind Cellpose and Omnipose who built the general image segmentation tools. They were the foundations of segment-kidney-structures.

Cite segment-kidney-structures

If segment-kidney-structures has been useful to your research, please cite our paper below:

High-dimensional spatial proteomics and novel machine learning pipeline identifies disease specific renal damage states
Thao Cao, Madeleine S. Torcasso, Junting Ai, Satoshi Hara, Michael S. Andrade, Anthony Chang, Gabriel Casella, Anita S. Chong, Maryellen L. Giger, Marcus R. Clark
bioRxiv 2026.01.14.699505; doi: https://doi.org/10.64898/2026.01.14.699505

Feedback and Questions

We acknowledge that there is no perfect model, but there are some useful ones. We hope to keep improving our tool and support other scientists in their imaging analysis. If you have any feedback, questions, and comments, please send me an email (thaocao97@gmail.com).

License

MIT License

Copyright (c) 2026 Thao Cao

Metadata

Release files for segment-kidney-structures 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for segment-kidney-structures 0.1.1
File Size Uploaded
segment_kidney_structures-0.1.1.tar.gz 74.0 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for segment-kidney-structures 0.1.1
File Interpreter ABI Platform
segment_kidney_structures-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 148.0 MB

Release files / segment_kidney_structures-0.1.1.tar.gz

Download URL segment_kidney_structures-0.1.1.tar.gz
Size 74.0 MB
Tags Source
SHA-256 checksum
How to use checksums
c0a61d9c75beb5095202865f7f6c5c0417354a48ae9f1b8b02fe80626174644a
BLAKE2b-256 checksum
How to use checksums
f335dcbad62eb5889d6d073663e16f78f29a842a27277cceef1716bc3de5edde
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"SLES","version":"15.6","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / segment_kidney_structures-0.1.1-py3-none-any.whl

Download URL segment_kidney_structures-0.1.1-py3-none-any.whl
Size 74.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
58b2a2799d49232240616e66a4091955fa4fdc60109966c84e7e798ba6344626
BLAKE2b-256 checksum
How to use checksums
a74cd139cb1a98b76bd96ed7cc0b58911c0d25d9b0a039ae172fa22f3f60c5bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"SLES","version":"15.6","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page