Skip to content

feat: add atlas-based registration solution for vertebrae - #6

Open
monkeylam wants to merge 1 commit into
BodyMaps:mainfrom
monkeylam:feature/vertebrae-warmup-postprocessing
Open

feat: add atlas-based registration solution for vertebrae#6
monkeylam wants to merge 1 commit into
BodyMaps:mainfrom
monkeylam:feature/vertebrae-warmup-postprocessing

Conversation

@monkeylam

@monkeylam monkeylam commented Jul 21, 2026

Copy link
Copy Markdown

Description

Integrates sophisticated atlas-based registration pipeline into ShapeKit as an optional module for high-throughput batch processing of spine segmentations. This solution uses deformable image registration to align input vertebrae to a reference atlas, enabling intelligent label refinement based on spatial and anatomical consistency.

What This Does

A four-stage registration-based pipeline:

Stage 1: Cleanup

Removes noise and consolidates vertebrae labels:

  • Identifies connected components within each vertebra label
  • Removes small fragments below size thresholds
  • Pools remaining noise into nearest vertebra centroid
  • Result: Clean, consolidated vertebrae masks ready for registration

Stage 2: Registration (Core Innovation)

Uses ANTsPy to establish spatial correspondence with reference atlas:

  • Rigid registration: Aligns input to atlas (handles translation and rotation)
  • Affine registration: Accounts for scaling and shearing variations
  • SyN deformable registration: Fine-grained local anatomical alignment
  • Label-weighted: Preserves anatomical structure during warping
  • Result: Input vertebrae warped to atlas space with clear spatial correspondence

Stage 3: Relabel

Assigns components based on atlas guidance:

  • For each disconnected component, checks which atlas labels it overlaps
  • Computes spatial distance to atlas label centroids
  • Uses Hungarian algorithm for optimal label assignment
  • Falls back to spatial distance if overlap is minimal
  • Result: Components assigned to anatomically correct vertebrae based on spatial and atlas guidance

Stage 4: Finalize

Consolidates to target vertebrae count through intelligent operations:

  • Splits oversized vertebrae based on spatial spacing and size ratios
  • Merges small vertebrae with neighbors if spatially close
  • Removes false positive fragments detected during processing
  • Enforces final target count (e.g., 24 vertebrae for C1-L5)
  • Result: Final label map with correct vertebrae count and anatomical consistency

Key Features

  • Configurable vertebrae count: 7 (cervical), 12 (thoracic), 5 (lumbar), 24 (full), or custom
  • High-throughput batch processing: 1-2 cases/hour per CPU core
  • Backward compatible: Default configuration uses legacy mode, no breaking changes
  • Good degradation: Automatically falls back to legacy processing if dependencies or atlas paths missing
  • Comprehensive audit trails: CSV files documenting every processing decision

Results

Mean vertebra Dice: 92.8%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant