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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

segment_kidney_structures-0.1.1.tar.gz (74.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

segment_kidney_structures-0.1.1-py3-none-any.whl (74.0 MB view details)

Uploaded Python 3

File details

Details for the file segment_kidney_structures-0.1.1.tar.gz.

File metadata

  • Download URL: segment_kidney_structures-0.1.1.tar.gz
  • Upload date:
  • Size: 74.0 MB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for segment_kidney_structures-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c0a61d9c75beb5095202865f7f6c5c0417354a48ae9f1b8b02fe80626174644a
MD5 b4175c3f094eec315cc8843a1eb059a2
BLAKE2b-256 f335dcbad62eb5889d6d073663e16f78f29a842a27277cceef1716bc3de5edde

See more details on using hashes here.

File details

Details for the file segment_kidney_structures-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: segment_kidney_structures-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 74.0 MB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for segment_kidney_structures-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 58b2a2799d49232240616e66a4091955fa4fdc60109966c84e7e798ba6344626
MD5 f3ca68ea2051e121a3bddd4e9e20f2f3
BLAKE2b-256 a74cd139cb1a98b76bd96ed7cc0b58911c0d25d9b0a039ae172fa22f3f60c5bb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page