Feature/nightly#74
Conversation
Add three new ImageTools methods that cover all TubeTK usage in the package and experiments: - make_isotropic_image: already existed (equivalent to ResampleImage.SetMakeHighResIso); now used in experiments too. - binary_dilate_image: replaces ImageMath.Dilate + GetOutputUChar/Short, using BinaryDilateImageFilter with a FlatStructuringElement ball kernel. - binary_erode_image: replaces ImageMath.Erode, using BinaryErodeImageFilter with a FlatStructuringElement ball kernel. - keep_largest_connected_component: replaces SegmentConnectedComponents with SetKeepOnlyLargestComponent(True), using ConnectedComponentImageFilter + RelabelComponentImageFilter + BinaryThresholdImageFilter. Callers updated: - src/physiomotion4d/segment_anatomy_base.py: hole-fill open in segment_connected_component() now uses ImageTools methods. - src/physiomotion4d/segment_heart_simpleware.py: myocardium dilate/erode in segmentation_method() now uses ImageTools methods. - src/physiomotion4d/segment_heart_simpleware_trimmed_branches.py: trim_branches() rewrites the multi-label ImageMath chain as per-label binary masks (avoiding inter-label bleed) and uses ImageTools for all morphology and largest-component selection. - experiments/Heart-Statistical_Model_To_Patient/*.py: ResampleImage replaced by ImageTools().make_isotropic_image(). - experiments/Lung-GatedCT_To_USD/0-register_dirlab_4dct.py: dilate_mask() helper replaced by ImageTools().binary_dilate_image(). Non-code changes: - pyproject.toml: drop itk-tubetk>=1.4.0 dependency. - docs/conf.py: remove sys.modules['itk.TubeTK'] mock (no longer imported). - tests/test_segment_heart_simpleware_trimmed_branches.py: remove the Python <3.12 skipif guard that existed solely because TubeTK's SegmentConnectedComponents segfaulted on CPython 3.11; trim_branches() is now pure ITK and runs on all supported Python versions.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (15)
Cache: Disabled due to data retention organization setting Knowledge base: Disabled due to data retention organization setting WalkthroughThis PR removes the ChangesTubeTK removal and ImageTools migration
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR removes the project’s dependency on TubeTK by replacing TubeTK-based image morphology / connected-component operations with standard ITK filters (via ImageTools), and updates tests/docs/workflows accordingly.
Changes:
- Drop
itk-tubetkfrom dependencies and remove remaining TubeTK usages in segmentation and experiments. - Add standard-ITK implementations for binary dilate/erode and “keep largest connected component” to
ImageTools, and refactor heart segmentation trimming logic to use them. - Update docs/tests and adjust the nightly workflow’s venv creation command.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
tests/test_segment_heart_simpleware_trimmed_branches.py |
Removes Python-version gating now that trimming no longer depends on TubeTK. |
statistics.md |
Removes TubeTK from the dependency list. |
src/physiomotion4d/segment_heart_simpleware.py |
Replaces TubeTK ImageMath dilation/erosion with ImageTools helpers. |
src/physiomotion4d/segment_heart_simpleware_trimmed_branches.py |
Refactors trim_branches() to use ITK-only morphology and connected-component filtering. |
src/physiomotion4d/segment_anatomy_base.py |
Replaces TubeTK morphology usage with ImageTools. |
src/physiomotion4d/register_images_icon.py |
Updates a comment that previously referenced TubeTK behavior. |
src/physiomotion4d/image_tools.py |
Adds ITK-only binary dilate/erode and largest-component utilities. |
README.md |
Removes TubeTK from “Key Dependencies”. |
pyproject.toml |
Removes itk-tubetk from install requirements. |
experiments/Lung-GatedCT_To_USD/0-register_dirlab_4dct.py |
Uses ImageTools for mask dilation instead of TubeTK. |
experiments/Heart-Statistical_Model_To_Patient/heart_model_to_model_registration_pca.py |
Uses ImageTools.make_isotropic_image() instead of TubeTK resampling. |
experiments/Heart-Statistical_Model_To_Patient/heart_model_to_model_icp_itk.py |
Uses ImageTools.make_isotropic_image() instead of TubeTK resampling. |
docs/installation.rst |
Removes TubeTK from documented dependencies. |
docs/conf.py |
Removes Sphinx mocking of itk.TubeTK. |
.github/workflows/nightly-health.yml |
Changes venv creation command (needs pinning to Python 3.11). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| imMath = ImageTools() | ||
| spacing = interior_image.GetSpacing() | ||
| imMath.Dilate(round(7 / spacing[0]), 1, 0) | ||
| imMath.Erode(round(4 / spacing[0]), 1, 0) | ||
| exterior_image = imMath.GetOutputUChar() | ||
| exterior_image = imMath.binary_dilate_image( | ||
| interior_image, round(7 / spacing[0]), 1, 0 | ||
| ) |
| imMath.SetInput(lv_img) | ||
| imMath.Dilate(round(2 / spacing[0]), 1, 0) | ||
| lv_img = imMath.GetOutput() | ||
| lv_img = image_tools.binary_dilate_image(lv_img, round(2 / spacing[0]), 1, 0) |
| # Python 3.11 is required because the [physicsnemo] extra pulls in | ||
| # nvidia-physicsnemo, which requires Python >= 3.11. | ||
| run: | | ||
| & "C:\Users\saylward\AppData\Local\Programs\Python\Python311\python.exe" -m venv "$env:RUNNER_TEMP\physiomotion4d-venv" | ||
| & py -m venv "$env:RUNNER_TEMP\physiomotion4d-venv" | ||
| echo "$env:RUNNER_TEMP\physiomotion4d-venv\Scripts" >> $env:GITHUB_PATH |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #74 +/- ##
==========================================
+ Coverage 34.66% 35.93% +1.26%
==========================================
Files 57 57
Lines 7283 7289 +6
==========================================
+ Hits 2525 2619 +94
+ Misses 4758 4670 -88
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary by CodeRabbit
New Features
Bug Fixes
Documentation