Skip to content

Releases: OpenHeartDevelopers/pycemrg-image-analysis

v0.1.0

05 May 13:10

Choose a tag to compare

v0.1.0 Pre-release
Pre-release

Initial public release. Establishes the core anatomy pipeline, label management
tooling, ML-oriented utilities, and supporting infrastructure.

Anatomy Pipeline

  • MyocardiumLogic — derives myocardium masks from blood pool labels using
    physical-space distance maps and configurable MyocardiumRule contracts.
    Supports multi-step application sequences (ApplicationStep) for fine-grained
    control over how walls are written into the output image.
  • ValveLogic — creates valve masks via signed-distance intersection between two
    anatomical structures, driven by ValveRule contracts.
  • RingLogic — creates pulmonary vein ring labels by combining vein distance maps
    with atrium myocardium boundaries, using RingRule contracts.
  • SegmentationLogic — creates cylinder masks from point clouds; used for
    fibre-direction annotation and cutting plane generation.
  • schematics/ — pre-defined anatomy blueprints for LV, RV, LA, RA, valves, and
    vein rings. Used as reference configurations for contract construction and
    label diagnostics.
  • recipes.py — six named end-to-end workflows: biventricular_basic,
    biventricular_full, four_chamber_basic, four_chamber_full, and variants.
    Each recipe is a pre-sequenced list of logic calls with fixed defaults.
  • logic/contracts.py — all data contracts as frozen dataclasses:
    MyocardiumCreationContract, ValveCreationContract, RingCreationContract,
    CylinderCreationContract, ApplicationStep, MyocardiumRule, ValveRule,
    RingRule.
  • logic/builders.pySegmentationPathBuilder constructs contracts from
    file paths and image metadata; reduces boilerplate in orchestrators.

Label Management

  • utilities/label_tools.pyLabelDiagnostic compares an image's present
    integer labels against a named schematic and produces a DiagnosticReport
    listing missing and unexpected labels. LabelRemapper converts a
    DiagnosticReport into an integer-to-integer mapping via
    suggest_mapping_from_report().
  • scaffolding.pyConfigScaffolder generates YAML and JSON parameter files
    for workflow runs. scaffold_components_with_mapping() handles the common case
    where 3D Slicer has reset label values to sequential 1–N.
  • scripts/utilities/labels_cli.py — command-line tool for inspecting label
    contents and computing volume statistics from NIfTI segmentation files.

Utilities

  • utilities/masks.py — four mask composition modes (ADD, REPLACE,
    REPLACE_ONLY, REPLACE_EXCEPT), wired through dispatchers.py.
  • utilities/components.pykeep_largest_component (per-label cleanup) and
    keep_largest_structure (multi-label debris removal).
  • utilities/spatial.py — point sampling on image grids, bounding-box slicing,
    coordinate-system utilities.
  • utilities/geometry.py — cylinder mask calculation in physical space.
  • utilities/filters.py — morphological and intensity filtering helpers.
  • utilities/io.pyload_image / save_image wrappers; consistent spacing
    and metadata handling across SimpleITK and NumPy array forms.
  • utilities/postprocessing.py — label volume computation and related cleanup.
  • scripts/utilities/inr_to_nifti.py — converts legacy .inr format images to
    NIfTI, preserving physical spacing metadata.

ML Utilities

  • utilities/metrics.py — Dice coefficient, SSIM, and related volume comparison
    metrics. All functions expect input normalized to [0, 1] in (Z, Y, X) order.
  • utilities/augmentation.py — spatial and intensity augmentation (flips, rotations,
    noise, contrast perturbation). Validates [0, 1] normalization at entry.
  • utilities/artifact_simulation.pydownsample_volume simulates
    lower-resolution acquisitions; preserve_extent flag controls whether physical
    extent is held fixed (needed for ML coordinate normalization pipelines).
  • utilities/sampling.pyextract_center_patch with automatic padding for
    patch-based training pipelines.

Infrastructure

  • PyPI-ready packaging via pyproject.toml + setuptools. Package name:
    pycemrg-image-analysis, requires Python >= 3.10.
  • GitHub Actions workflow for automated PyPI publishing on tag push.
  • MkDocs-based API documentation with per-module reference pages and guides.
  • Unit test suite covering components, metrics, augmentation, artifact simulation,
    sampling, spatial coordinates, and scaffolding — no test data required.
  • Integration test suite covering myocardium, valve, and ring creation — requires
    PYCEMRG_TEST_DATA_ROOT to be set; skipped automatically when absent.

Dependencies

Requires pycemrg>=0.1.0 (separate repository) for LabelManager and
ConfigScaffolder. Key third-party dependencies: SimpleITK, NumPy, SciPy,
scikit-image, trimesh, meshio, nibabel, pydicom.