Skip to main content

CUDA-accelerated CellStitch 3D labeling using Instanseg segmentation.

Project description

CellStitch-Cuda: CUDA-accelerated CellStitch 3D labeling.

cuda-version

About this repo

An overhaul of the CellStitch algorithm, developed by Yining Liu and Yinuo Jin (original repository), publication can be found here.

Some major adjustments:

  • Replaced NumPy with CuPy for GPU-accelerated calculations.
  • Replaced nested for-loops with vectorized calculations for dramatic speedups (~100x).
  • Included novel segmentation method InstanSeg, which enables multichannel inputs (repo and publication).
  • An all-in-one method that takes an ZCYX-formatted .tif file, performs the correct transposes, and writes stitched labels.
  • Included a histogram-based bleach correction to adjust for signal degradation over the Z-axis (originally developed for ImageJ in (Miura 2020) and released for Python by marx-alex in napari-bleach-correct).

Some comparisons

The calculations were run on the same machine (GPU: NVIDIA Quadro RTX 6000 24 GB; CPU: Intel Xeon Gold 6252 (48/96 cores); RAM: 1024 GB), the core count of which gave it a clear parallel-processing advantage. This particularly affects the fill_holes_and_remove_small_masks function, which has been rewritten to utilize parallel processing. img-a

In image A, GPU VRAM load was ~200 MB at its peak.

img-b

In image B, GPU VRAM load was ~2442 MB at its peak

Installation

Notes

This setup has so far only been verified on Windows-based, CUDA-accelerated machines. Testing has only been performed on CUDA 12.x. There are no reasons why 11.x should not work (check instructions), but your mileage may vary.

Conda setup

conda create -n cellstitch-cuda python=3.11
conda activate cellstitch-cuda

Install using PyPi

pip install cellstitch-cuda
pip uninstall torch
conda install pytorch pytorch-cuda=12.4 -c conda-forge -c pytorch -c nvidia

You may replace the version number for pytorch-cuda with whatever is applicable for you.

Additional steps for CUDA 11.x

pip uninstall cupy-cuda12x
pip install cupy-cuda11x

Instructions

From an image

from cellstitch_cuda.pipeline import cellstitch_cuda

img = "path/to/image.tif"
# or feed img as a numpy ndarray

volumetric_masks = cellstitch_cuda(img)

From pre-existing orthogonal labels

from cellstitch_cuda.pipeline import full_stitch

# Define xy_masks, yz_masks, xz_masks in some way

volumetric_masks = full_stitch(xy_masks, yz_masks, xz_masks)

References

Goldsborough, T., O’Callaghan, A., Inglis, F., Leplat, L., Filbey, A., Bilen, H., & Bankhead, P. (2024) A novel channel invariant architecture for the segmentation of cells and nuclei in multiplexed images using InstanSeg. bioRxiv, 2024.09.04.611150. doi: 10.1101/2024.09.04.611150

Liu, Y., Jin, Y., Azizi, E., & Blumberg, E. (2023) Cellstitch: 3D cellular anisotropic image segmentation via optimal transport. BMC Bioinformatics, 24(480). doi: 10.1186/s12859-023-05608-2

Miura, K. (2020) Bleach correction ImageJ plugin for compensating the photobleaching of time-lapse sequences. F1000Res, 9:1494. doi: 10.12688/f1000research.27171.1

Stringer, C., Wang, T., Michaelos, M., & Pachitariu, M. (2021) Cellpose: a generalist algorithm for cellular segmentation. Nature Methods, 18(1), 100-106. doi: 10.1038/s41592-020-01018-x

Project details


Download files

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

Source Distribution

cellstitch_cuda-1.0.4.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

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

cellstitch_cuda-1.0.4-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

Details for the file cellstitch_cuda-1.0.4.tar.gz.

File metadata

  • Download URL: cellstitch_cuda-1.0.4.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.11

File hashes

Hashes for cellstitch_cuda-1.0.4.tar.gz
Algorithm Hash digest
SHA256 10cf05f00c7fdc2e7d7acef979feb8e316a9963e5fa2519284dc47a82581c3e6
MD5 1c6622cad4878e2a81573a270efd2437
BLAKE2b-256 a8bbf443c053faeea9505225841d68f42150cf474b8c6d62f558fa11ddb5c9d4

See more details on using hashes here.

File details

Details for the file cellstitch_cuda-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for cellstitch_cuda-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6817b70413da4ec16af1e4cb3606b7b9006897dfe07afb1ed167f54b3be17ef6
MD5 5dc62070ecc1b334d17c849c6be578eb
BLAKE2b-256 eeeb8036be8da650abd932ef8b7f5012489cc0706116681c1d2b1ee349df6ee5

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 Pingdom Monitoring Sentry Error logging StatusPage Status page