Skip to content

ENH: Refactor naming and add statistical model CLIs#27

Merged
aylward merged 4 commits intomainfrom
segmentanatomy
Feb 17, 2026
Merged

ENH: Refactor naming and add statistical model CLIs#27
aylward merged 4 commits intomainfrom
segmentanatomy

Conversation

@aylward
Copy link
Copy Markdown
Collaborator

@aylward aylward commented Feb 15, 2026

  • Rename heart_model_to_patient → fit_statistical_model_to_patient (workflow, CLI, docs: register_heart_model_to_patient → fit_statistical_model_to_patient)
  • Rename segment_chest_base → segment_anatomy_base
  • Add create_statistical_model CLI and workflow (+ docs)
  • Add visualize_pca_modes CLI
  • Update docs, API references, and dependent modules

- Rename heart_model_to_patient → fit_statistical_model_to_patient
  (workflow, CLI, docs: register_heart_model_to_patient → fit_statistical_model_to_patient)
- Rename segment_chest_base → segment_anatomy_base
- Add create_statistical_model CLI and workflow (+ docs)
- Add visualize_pca_modes CLI
- Update docs, API references, and dependent modules
Copilot AI review requested due to automatic review settings February 15, 2026 17:43
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR performs a comprehensive refactoring of the PhysioMotion4D codebase to improve naming consistency and adds new CLI tools for statistical shape model workflows. The changes rename WorkflowRegisterHeartModelToPatient to WorkflowFitStatisticalModelToPatient and SegmentChestBase to SegmentAnatomyBase to better reflect their general-purpose nature. Additionally, it introduces two new workflow classes and three new CLI commands for creating and working with PCA statistical shape models.

Changes:

  • Renamed core classes and files to improve clarity: WorkflowRegisterHeartModelToPatientWorkflowFitStatisticalModelToPatient, segment_chest_base.pysegment_anatomy_base.py
  • Added new WorkflowCreateStatisticalModel class and CLI for building PCA models from sample meshes
  • Added visualize_pca_modes CLI for interactive PCA mode visualization
  • Refactored API to make PCA and mask-to-image registration opt-in features (breaking change with better API design)
  • Added RegisterModelsPCA.from_pca_model() method to accept dict-based PCA models
  • Enhanced boundary checking in contour_tools.py for points outside image bounds
  • Updated all documentation, experiments, and examples to reflect the new naming

Reviewed changes

Copilot reviewed 42 out of 42 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
statistics.md Updated file references to reflect renamed modules
workflow_fit_statistical_model_to_patient.py Renamed class; refactored to make template_labelmap and patient_image optional; PCA and mask-to-image now opt-in
workflow_create_statistical_model.py New workflow implementing full PCA statistical model creation pipeline
segment_anatomy_base.py Renamed from segment_chest_base; added int16 cast fix for threshold image
segment_heart_simpleware.py Updated import to use SegmentAnatomyBase
segment_chest_vista_3d.py Updated import to use SegmentAnatomyBase
segment_chest_total_segmentator.py Updated import to use SegmentAnatomyBase
segment_chest_ensemble.py Updated import to use SegmentAnatomyBase
register_models_pca.py Added from_pca_model() classmethod; fixed typos; removed unused instance variables
register_models_distance_maps.py Changed default roi_dilation_mm from 10 to 20
physiomotion4d_base.py Updated example class names in docstrings
image_tools.py Added flip_image_to_identity_direction() method
contour_tools.py Added boundary checking to skip out-of-bounds points
cli/visualize_pca_modes.py New CLI for interactive PCA mode visualization with slider
cli/fit_statistical_model_to_patient.py Renamed CLI; updated to use new opt-in API for PCA and mask-to-image
cli/create_statistical_model.py New CLI for creating PCA statistical models
cli/init.py Updated all exports with new CLI names
init.py Updated imports and exports for renamed classes
pyproject.toml Updated CLI entry points; added mypy ignore for sklearn (typo: "sklean")
experiments/README.md Updated CLI command references throughout
experiments/Heart-*.ipynb Updated notebooks to use renamed classes and new API patterns
experiments/Heart-Simpleware_Segmentation/README.md Updated workflow class references
experiments/Heart-Create_Statistical_Model/README.md Updated workflow class references
docs/* Comprehensive documentation updates for renamed classes and new CLIs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/physiomotion4d/contour_tools.py
Comment thread pyproject.toml Outdated
Comment thread src/physiomotion4d/workflow_create_statistical_model.py Outdated
Comment thread src/physiomotion4d/contour_tools.py
Copilot AI review requested due to automatic review settings February 17, 2026 14:43
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 42 out of 42 changed files in this pull request and generated 11 comments.

Comments suppressed due to low confidence (1)

docs/cli_scripts/fit_statistical_model_to_patient.rst:46

  • This doc page still documents --template-labelmap and --patient-image as required for basic usage, but the CLI now allows omitting --patient-image (reference image is created from patient models) and only requires --template-labelmap when mask-to-image refinement is enabled. Please update the examples and the “Required Arguments” section to reflect the current CLI behavior (and document --mask-to-image as the trigger for requiring labelmap + IDs).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/physiomotion4d/contour_tools.py Outdated
Comment thread src/physiomotion4d/contour_tools.py
Comment thread src/physiomotion4d/contour_tools.py Outdated
Comment thread src/physiomotion4d/workflow_create_statistical_model.py
Comment thread src/physiomotion4d/register_models_pca.py
Comment thread src/physiomotion4d/register_models_distance_maps.py Outdated
Comment thread src/physiomotion4d/workflow_create_statistical_model.py Outdated
Comment thread src/physiomotion4d/segment_heart_simpleware.py
Comment thread src/physiomotion4d/segment_chest_total_segmentator.py
Comment thread pyproject.toml Outdated
@aylward aylward merged commit 8e57cb9 into main Feb 17, 2026
11 checks passed
@aylward aylward deleted the segmentanatomy branch February 17, 2026 16:45
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.

2 participants