Skip to main content

CI Status Codecov

cellmap-analyze

A suite of Dask-powered tools for processing and analyzing terabyte-scale 3D segmentation datasets. Supports both isotropic and anisotropic voxel sizes.


Features

Processing Tools

Tool CLI Command Description
Connected Components connected-components Threshold predictions, apply masks, and extract connected components. Volume thresholds are in physical units (nm³).
Clean Components clean-connected-components Refine existing segmentations by removing small/large components.
Contact Sites contact-sites Identify regions where two segmentations are within a configurable physical distance. Handles mismatched voxel sizes by resampling to a common resolution.
Fill Holes fill-holes Fill interior gaps in segmented volumes.
Filter IDs filter-ids Exclude unwanted segmentation IDs. Kept IDs are renumbered 1..N in the order given, unless preserve_ids: true.
Mutex Watershed mws Mutex watershed agglomeration from affinities.
Label With Mask label-with-mask Label one dataset with IDs from another.
Morphological Operations morphological-operations Erosion and dilation of segmented datasets. Processing order across blocks is not guaranteed.
Skeletonize skeletonize Generate skeletons from segmented objects with optional pruning and simplification. Automatically resamples to isotropic resolution before skeletonization.
Compute EDT compute-edt Compute a Euclidean distance transform over a segmentation, for reuse across repeated split-narrow-bridges runs.
Split Narrow Bridges split-narrow-bridges Split accidentally-merged blob-like objects (nuclei, cells) at thin necks via EDT-watershed, preserving all original foreground voxels.
Multiscale multiscale Add downsampled levels (s1, s2, …) to an existing zarr dataset for viewing, until a level fits in one chunk. Integer data (labels) is downsampled by mode and floats by mean, on anisotropic data the finer axes are halved first, and each level's OME translation is placed at its voxel centres.

These tools chain together into a full predictions-to-segmentations pipeline: start from raw model output (connected-components thresholds prediction probability maps, or mws agglomerates affinities) to get an initial instance segmentation, optionally refine it (split-narrow-bridges to separate accidentally-merged instances, fill-holes, morphological-operations), then finalize with clean-connected-components and/or filter-ids.

Each processing command that writes a volume then adds a multiscale pyramid to it, as multiscale does, so every output is ready to view. Set multiscale: false in its run-config.yaml to skip this; compute-edt adds one only with multiscale: true.

Analysis Tools

Tool CLI Command Description
Measurement measure Compute metrics (volume, surface area, radius of gyration, bounding box, principal axes) for objects and contact sites. Principal axes give three axis lengths (equivalent-ellipsoid diameters, as in scikit-image's regionprops), elongation (longest / second), flatness (second / third), and the longest axis's direction. Supports raw intensity statistics when a raw dataset is provided.
Fit Lines fit_lines_to_segmentations Fit geometric lines to elongated/cylindrical structures.
Assign to Organelles assign_to_organelles Map segmented objects to organelles based on centers of mass.

Anisotropic data

All operations handle anisotropic voxel sizes (e.g. (8, 8, 32) nm in ZYX). Physical-unit parameters like minimum_volume_nm_3, contact_distance_nm, and gaussian_smoothing_sigma_nm are automatically converted to the appropriate per-axis voxel units. When two datasets have different voxel sizes, they are resampled onto the same voxel grid, using nearest-neighbor interpolation for labels; raw intensities in measure are block-averaged when read at a coarser voxel size.

A roi in a run-config is in nm, ["z_start:z_end", "y_start:y_end", "x_start:x_end"], and selects the voxels whose centres lie inside it; the output covers just those voxels.

Datasets are read through worldarray: zarr v2/v3, N5 and Neuroglancer precomputed, from local paths or s3://, gs:// and http(s)://. Its README documents where each format places voxel 0. Each array is read with its spatial axes in z, y, x order, so one stored x, y, z (as TensorSwitch writes OME-Zarr v3) is transposed on read. Outputs are written z, y, x, and multiscale adds levels in the dataset's own order.


Installation

pip install cellmap-analyze

Usage

All commands share the same basic interface:

<command> [options] <config_path>
  • <command>: One of the processing or analysis tools listed above.

  • <config_path>: Directory containing:

    • run-config.yaml (parameters for your chosen command)
    • dask-config.yaml (Dask cluster settings)

Options:

  • -n, --num-workers N: Number of Dask workers to launch.

Output: A new directory named config_path-<YYYYMMDDHHMMSS> will be created, containing copies of your configs and an output.log for monitoring.


Configuration Examples

The following run-config.yaml could be used to run connected-components.

run-config.yaml

input_path: /path/to/predictions.zarr/mito/s0
output_path: /path/to/segmentations.zarr/mito
intensity_threshold_minimum: 0.71
minimum_volume_nm_3: 1E7
delete_tmp: true
connectivity: 1
mask_config:
  cell:
    path: /path/to/masks.zarr/cell/s0
    mask_type: inclusive
fill_holes: true

dask-config.yaml

The following dask-config.yaml files can be used for a variety of tasks.

Local

jobqueue:
  local:
    ncpus: 1
    processes: 1
    cores: 1
    log-directory: job-logs
    name: dask-worker

distributed:
  scheduler:
    work-stealing: true

LSF Cluster

jobqueue:
  lsf:
    ncpus: 8        # cores per job chunk
    processes: 12  # worker processes per chunk
    cores: 12      # threads per process (1 thread each)
    memory: 120GB  # 15 GB per slot
    walltime: 08:00
    mem: 120000000000
    use-stdin: true
    log-directory: job-logs
    name: cellmap-analyze
    project: charge_group

distributed:
  scheduler:
    work-stealing: true
  admin:
    log-format: '[%(asctime)s] %(levelname)s %(message)s'
    tick:
      interval: 20ms
      limit: 3h

Each worker reads and writes with its share of the job's CPUs, ncpus (or cores) divided by processes, at least 1: the example above gives each worker 1 thread. The job script exports it as WORLDARRAY_THREADS.

Submission

To run on 12 dask workers:

Local run example:

connected-components -n 12 config_path

Cluster submit example (LSF):

bsub -n 4 -P chargegroup connected-components -n 12 config_path

Acknowledgements

The center-finding implementation is taken from funlib.evaluate.

Metadata

Release files for cellmap-analyze 0.6.3

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

Source distribution (sdist)

Source distribution for cellmap-analyze 0.6.3
File Size Uploaded Provenance Actions
cellmap_analyze-0.6.3.tar.gz 1.0 MB Without provenance Details for cellmap_analyze-0.6.3.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for cellmap-analyze 0.6.3
File Interpreter ABI Platform Actions
cellmap_analyze-0.6.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details for cellmap_analyze-0.6.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
cellmap_analyze-0.6.3-cp312-cp312-macosx_10_13_universal2.whl CPython 3.12 CPython 3.12 macOS 10.13+ universal2 (ARM64, x86-64) Details for cellmap_analyze-0.6.3-cp312-cp312-macosx_10_13_universal2.whl

Total release size: 7.0 MB

Release files / cellmap_analyze-0.6.3.tar.gz

Download URL cellmap_analyze-0.6.3.tar.gz
Size 1.0 MB
Tags Source
SHA-256 checksum
How to use checksums
6aec4d5d81818a4da28b92c8d5e2474478a5117730138af3582770c33b4b52c1
BLAKE2b-256 checksum
How to use checksums
20e79f457830f75613707072b41da9432af0d005145a81394b67a62d8d0cd3a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / cellmap_analyze-0.6.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL cellmap_analyze-0.6.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 4.1 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
e53f2f08733a3a1dc31d7fa5c38422db49bed636e6aa30cf778369ef3787e51c
BLAKE2b-256 checksum
How to use checksums
d967ff0939a48013cc84b97bc887fcbeaa1794d74d1240e62bae8241361909ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / cellmap_analyze-0.6.3-cp312-cp312-macosx_10_13_universal2.whl

Download URL cellmap_analyze-0.6.3-cp312-cp312-macosx_10_13_universal2.whl
Size 1.9 MB
Tags CPython 3.12 macOS 10.13+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
40f989f38e4389f3e3c1191fda3b2df20d8049389df9cae4a91b46fb8c2b6f04
BLAKE2b-256 checksum
How to use checksums
8df5a202ee44643bd14d4817d5692693185a0c8f8af560f2ed42767e48f925ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Security for cellmap-analyze 0.6.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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