Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,8 @@ jobs:
# The following tests are excluded from CI and should be run locally:
#
# Slow/GPU-intensive tests:
# - tests/test_register_images_ants.py (slow, computationally intensive)
# - tests/test_register_images_icon.py (requires CUDA for ICON)
# - tests/test_register_images_ANTS.py (slow, computationally intensive)
# - tests/test_register_images_ICON.py (requires CUDA for ICON)
Comment on lines +410 to +411
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix excluded-test note filenames to match real paths.

Line 410, Line 411, and Line 424 reference uppercase test filenames. The repository test files are lowercase, so these examples are misleading and can fail when copied.

Suggested fix
-# - tests/test_register_images_ANTS.py (slow, computationally intensive)
-# - tests/test_register_images_ICON.py (requires CUDA for ICON)
+# - tests/test_register_images_ants.py (slow, computationally intensive)
+# - tests/test_register_images_icon.py (requires CUDA for ICON)
...
-#   pytest tests/test_register_images_ANTS.py -v --run-slow
+#   pytest tests/test_register_images_ants.py -v --run-slow

Also applies to: 424-424

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/ci.yml around lines 410 - 411, The excluded-test example
filenames in the CI config use uppercase names
(tests/test_register_images_ANTS.py and tests/test_register_images_ICON.py) that
don't match the actual lowercase test files; update these occurrences (including
the additional occurrence noted around the later reference) to the real
lowercase filenames (tests/test_register_images_ants.py and
tests/test_register_images_icon.py) so examples match repository paths and won't
mislead or break copy/paste.

# - tests/test_transform_tools.py (depends on slow registration tests)
# - tests/test_segment_chest_total_segmentator.py (requires CUDA for TotalSegmentator)
#
Expand All @@ -421,7 +421,7 @@ jobs:
# pytest tests/ -v --run-slow # Run all slow tests
# pytest tests/ -v --run-gpu --run-slow # GPU + slow (typical local dev profile)
# pytest tests/ -v --run-simpleware --run-gpu --run-slow # Full Simpleware coverage
# pytest tests/test_register_images_ants.py -v --run-slow
# pytest tests/test_register_images_ANTS.py -v --run-slow
#
# Self-hosted GPU runner enables ALL buckets via --run-all
# (--run-gpu --run-slow --run-simpleware --run-physicsnemo --run-experiments --run-tutorials).
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ network_weights
*.gz
*.mat
*.mhd
*.raw
*.zip
*.nii
*.tfm
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ print(WorkflowConvertImageToUSD.__name__)
- **Registration Classes**: Multiple registration methods for different use cases
- Image-to-Image Registration:
- `RegisterImagesICON`: Deep learning-based registration using Icon algorithm
- `RegisterImagesANTs`: Classical deformable registration using ANTs
- `RegisterImagesANTS`: Classical deformable registration using ANTs
- `RegisterTimeSeriesImages`: Specialized time series registration for 4D CT
- Model-to-Image/Model Registration:
- `RegisterModelsPCA`: PCA-based statistical shape model registration
Expand Down Expand Up @@ -354,7 +354,7 @@ if "lung" in masks:
### Image Registration

```python
from physiomotion4d import RegisterImagesICON, RegisterImagesANTs, RegisterTimeSeriesImages
from physiomotion4d import RegisterImagesICON, RegisterImagesANTS, RegisterTimeSeriesImages
import itk

# Option 1: Icon deep learning registration (GPU-accelerated)
Expand All @@ -364,14 +364,14 @@ registerer.set_fixed_image(itk.imread("reference_frame.mha"))
results = registerer.register(itk.imread("target_frame.mha"))

# Option 2: ANTs classical registration
registerer = RegisterImagesANTs()
registerer = RegisterImagesANTS()
registerer.set_fixed_image(itk.imread("reference_frame.mha"))
results = registerer.register(itk.imread("target_frame.mha"))

# Option 3: Time series registration for 4D CT
time_series_reg = RegisterTimeSeriesImages(
reference_index=0,
registration_method='icon' # or 'ants'
registration_method='ICON' # or 'ANTS'
)
transforms = time_series_reg.register_time_series(
image_filenames=["time00.mha", "time01.mha", "time02.mha"]
Expand Down Expand Up @@ -735,7 +735,7 @@ will change, and flag any coordinate-system or shape implications.
Use `/impl` for end-to-end implementation: read → summarize → plan → diff → lint.

```text
/impl add set_regularization_weight() to RegisterImagesANTs
/impl add set_regularization_weight() to RegisterImagesANTS
```

```text
Expand All @@ -757,7 +757,7 @@ Use `/test-feature` to get a test plan and a complete pytest file using syntheti
```

```text
/test-feature RegisterImagesANTs with a pair of small synthetic ITK images
/test-feature RegisterImagesANTS with a pair of small synthetic ITK images
```

The agent will state image shapes and axis orders in every test docstring, wire
Expand All @@ -772,7 +772,7 @@ Use `/doc-feature` after modifying a public API to refresh docstrings and regene
the API map.

```text
/doc-feature update docstrings for RegisterImagesANTs after adding set_regularization_weight
/doc-feature update docstrings for RegisterImagesANTS after adding set_regularization_weight
```

The agent will update affected docstrings in NumPy style, add shape/axis annotations
Expand Down
225 changes: 132 additions & 93 deletions docs/API_MAP.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ By Category

**Image Registration**
* :class:`~physiomotion4d.RegisterImagesBase` - Base registration class
* :class:`~physiomotion4d.RegisterImagesANTs` - ANTs registration
* :class:`~physiomotion4d.RegisterImagesANTS` - ANTs registration
* :class:`~physiomotion4d.RegisterImagesICON` - Icon deep learning registration
* :class:`~physiomotion4d.RegisterTimeSeriesImages` - 4D time series registration

Expand Down
8 changes: 4 additions & 4 deletions docs/api/registration/ants.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ ANTs Registration
.. module:: physiomotion4d.register_images_ants
.. currentmodule:: physiomotion4d

``RegisterImagesANTs`` provides optimization-based deformable image
``RegisterImagesANTS`` provides optimization-based deformable image
registration through ANTs.

Class Reference
===============

.. autoclass:: RegisterImagesANTs
.. autoclass:: RegisterImagesANTS
:members:
:undoc-members:
:show-inheritance:
Expand All @@ -23,12 +23,12 @@ Basic Registration

import itk

from physiomotion4d import RegisterImagesANTs
from physiomotion4d import RegisterImagesANTS

fixed = itk.imread("reference.mha")
moving = itk.imread("moving.mha")

registrar = RegisterImagesANTs()
registrar = RegisterImagesANTS()
registrar.set_modality("ct")
registrar.set_transform_type("SyN")
registrar.set_number_of_iterations([30, 15, 7])
Expand Down
6 changes: 3 additions & 3 deletions docs/api/registration/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ PhysioMotion4D image registration classes align moving 3D images to a fixed
Common Result Shape
===================

``RegisterImagesANTs.register()`` and ``RegisterImagesICON.register()`` return:
``RegisterImagesANTS.register()`` and ``RegisterImagesICON.register()`` return:

* ``forward_transform``
* ``inverse_transform``
Expand All @@ -35,12 +35,12 @@ Basic Example

import itk

from physiomotion4d import RegisterImagesANTs
from physiomotion4d import RegisterImagesANTS

fixed = itk.imread("reference.mha")
moving = itk.imread("moving.mha")

registrar = RegisterImagesANTs()
registrar = RegisterImagesANTS()
registrar.set_modality("ct")
registrar.set_fixed_image(fixed)

Expand Down
4 changes: 2 additions & 2 deletions docs/api/registration/time_series.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Time-Series Registration
.. currentmodule:: physiomotion4d

``RegisterTimeSeriesImages`` registers ordered 3D image phases to a reference
frame using ANTs, Greedy, ICON, or combined ``ants_icon`` / ``greedy_icon``
frame using ANTs, Greedy, ICON, or combined ``ANTS_ICON`` / ``greedy_ICON``
methods.

Class Reference
Expand All @@ -29,7 +29,7 @@ Basic Usage

images = [itk.imread(f"phase_{idx:02d}.mha") for idx in range(10)]

registrar = RegisterTimeSeriesImages(registration_method="ants")
registrar = RegisterTimeSeriesImages(registration_method="ANTS")
registrar.set_fixed_image(images[0])

result = registrar.register_time_series(
Expand Down
2 changes: 1 addition & 1 deletion docs/api/workflows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ High-Resolution 4D CT Reconstruction
time_series_images=time_series_images,
fixed_image=time_series_images[0],
reference_frame=0,
registration_method="ants",
registration_method="ANTS",
)

result = workflow.run_workflow(upsample_to_fixed_resolution=True)
Expand Down
2 changes: 1 addition & 1 deletion docs/architecture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Data Flow
v
RegisterTimeSeriesImages
| |
| +--> RegisterImagesANTs / RegisterImagesICON
| +--> RegisterImagesANTS / RegisterImagesICON
v
SegmentChestTotalSegmentator / SegmentHeartSimpleware
|
Expand Down
4 changes: 2 additions & 2 deletions docs/cli_scripts/4dct_reconstruction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ Registration Options
physiomotion4d-reconstruct-highres-4d-ct \
--time-series-images frame_*.mha \
--fixed-image highres_reference.mha \
--registration-method ants \
--ants-iterations 30 15 7 3 \
--registration-method ANTS \
--ANTS-iterations 30 15 7 3 \
--prior-weight 0.5 \
--output-dir ./results

Expand Down
2 changes: 1 addition & 1 deletion docs/cli_scripts/fit_statistical_model_to_patient.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Registration Configuration
Enable mask-to-image refinement registration. Requires
``--template-labelmap`` and template label IDs. Disabled by default.

``--use-icon-refinement``
``--use-ICON-refinement``
Enable ICON deep learning registration refinement (default: disabled)

Output Options
Expand Down
6 changes: 3 additions & 3 deletions docs/developer/registration_images.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ Basic Pattern

import itk

from physiomotion4d import RegisterImagesANTs
from physiomotion4d import RegisterImagesANTS

fixed = itk.imread("fixed.mha")
moving = itk.imread("moving.mha")

registrar = RegisterImagesANTs()
registrar = RegisterImagesANTS()
registrar.set_modality("ct")
registrar.set_fixed_image(fixed)

Expand All @@ -38,7 +38,7 @@ Time Series

images = [itk.imread(f"phase_{idx:02d}.mha") for idx in range(10)]

registrar = RegisterTimeSeriesImages(registration_method="ants")
registrar = RegisterTimeSeriesImages(registration_method="ANTS")
registrar.set_fixed_image(images[0])
result = registrar.register_time_series(
moving_images=images,
Expand Down
6 changes: 3 additions & 3 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ phase images:
time_series_images=time_series_images,
fixed_image=fixed_image,
reference_frame=0,
registration_method="ants",
registration_method="ANTS",
)

result = workflow.run_workflow(upsample_to_fixed_resolution=True)
Expand Down Expand Up @@ -176,10 +176,10 @@ Advanced registration with multiple stages:

.. code-block:: python

from physiomotion4d import RegisterImagesANTs
from physiomotion4d import RegisterImagesANTS
import itk

registerer = RegisterImagesANTs()
registerer = RegisterImagesANTS()

fixed = itk.imread("reference.mha")
moving = itk.imread("target.mha")
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ Script
``tutorials/tutorial_08_dirlab_pca_time_series.py``

Workflow
``RegisterTimeSeriesImages`` with ``registration_method='ants_icon'`` and
``RegisterTimeSeriesImages`` with ``registration_method='ANTS_ICON'`` and
``TransformTools``

Dataset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
# This performs progressive multi-stage registration: rigid → affine → SyN deformable
result = registrar.register(
transform_type="Deformable", # Uses ANTs SyN (Symmetric Normalization)
use_icon=False, # Set to True for additional ICON deep learning refinement
use_ICON=False, # Set to True for additional ICON deep learning refinement
)

forward_transform = result["forward_transform"]
Expand Down Expand Up @@ -341,6 +341,6 @@
# 1. Rigid alignment
# 2. Affine transformation
# 3. SyN deformable registration (diffeomorphic)
# - Setting `use_icon=True` in the `register()` call would add ICON deep learning refinement after SyN
# - Setting `use_ICON=True` in the `register()` call would add ICON deep learning refinement after SyN
# - The `roi_dilation_mm` parameter controls the dilation of the ROI mask (default 20mm)
# - SyN registration provides smooth, invertible deformation fields for anatomical correspondence
4 changes: 2 additions & 2 deletions experiments/Heart-GatedCT_To_USD/1-register_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import itk

from physiomotion4d.register_images_ants import RegisterImagesANTs
from physiomotion4d.register_images_ants import RegisterImagesANTS
from physiomotion4d.segment_chest_total_segmentator import SegmentChestTotalSegmentator
from physiomotion4d.test_tools import TestTools
from physiomotion4d.transform_tools import TransformTools
Expand Down Expand Up @@ -76,7 +76,7 @@
)

# %%
reg = RegisterImagesANTs()
reg = RegisterImagesANTS()
reg.set_mask_dilation(5)
reg.set_number_of_iterations([10, 5, 2])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from itk import TubeTK as ttk

from physiomotion4d.test_tools import TestTools
from physiomotion4d.register_images_ants import RegisterImagesANTs
from physiomotion4d.register_images_ants import RegisterImagesANTS
from physiomotion4d.register_images_greedy import RegisterImagesGreedy
from physiomotion4d.register_images_icon import RegisterImagesICON

Expand Down Expand Up @@ -106,7 +106,7 @@

# --- ANTs (deformable SyN) ---
try:
reg_a = RegisterImagesANTs()
reg_a = RegisterImagesANTS()
reg_a.set_modality("ct")
reg_a.set_transform_type("Deformable")
reg_a.set_number_of_iterations([10, 5, 2]) # reduced for speed
Expand Down
Loading
Loading