Skip to main content

Code to perform analysis on segmentations like those produced by CellMap

Project description

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.
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.

Analysis Tools

Tool CLI Command Description
Measurement measure Compute metrics (volume, surface area, radius of gyration, bounding box) for objects and contact sites. 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 to a common resolution using nearest-neighbor interpolation.


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

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.

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

cellmap_analyze-0.2.3.tar.gz (923.6 kB view details)

Uploaded Source

Built Distributions

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

cellmap_analyze-0.2.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

cellmap_analyze-0.2.3-cp312-cp312-macosx_10_13_universal2.whl (1.7 MB view details)

Uploaded CPython 3.12macOS 10.13+ universal2 (ARM64, x86-64)

File details

Details for the file cellmap_analyze-0.2.3.tar.gz.

File metadata

  • Download URL: cellmap_analyze-0.2.3.tar.gz
  • Upload date:
  • Size: 923.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for cellmap_analyze-0.2.3.tar.gz
Algorithm Hash digest
SHA256 c369972e39df5db7702a87644c9137d2022ce5ded36639084d876b17fe895db5
MD5 633aba6c33b5a2f17d6f612bf06ccf17
BLAKE2b-256 ac0e651e635be29df4645ec03af930f5b9311b2cd931f57f29e132964b96e3c4

See more details on using hashes here.

File details

Details for the file cellmap_analyze-0.2.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for cellmap_analyze-0.2.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 9a254fb8ec6dc5538ffb183592fb5232149c073fea3c084ed1f34db6b6598a16
MD5 e1cfcb2217d9e4000c492bb39f5587b0
BLAKE2b-256 c24c3a0f98f2014555493d6e1717618043b9b1bd648d9fdbefd95316314226bf

See more details on using hashes here.

File details

Details for the file cellmap_analyze-0.2.3-cp312-cp312-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for cellmap_analyze-0.2.3-cp312-cp312-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 527af894ce4cf7ecd702a67f5a6ed4a3e89f79e3f8c5a52e795b6cc783e37b4d
MD5 05f0cd5addf8f3bff74190038028fd27
BLAKE2b-256 db70c7bbd7d918f11c39b0816b194529ee3a17cd7d59caa945ad9e9852808f80

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