Skip to content
Merged
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
4 changes: 2 additions & 2 deletions src/physiomotion4d/register_images_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def set_fixed_mask(self, fixed_mask: Optional[itk.Image]) -> None:
if self.mask_dilation_mm > 0:
imMath = ttk.ImageMath.New(self.fixed_mask)
imMath.Dilate(
int(self.fixed_image.GetSpacing()[0] / self.mask_dilation_mm), 1, 0
int(self.mask_dilation_mm / self.fixed_image.GetSpacing()[0]), 1, 0
)
Comment on lines 187 to 191
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

This change fixes a unit conversion that affects mask preprocessing across all registrars, but there are no tests asserting the mm→voxel dilation behavior (search in tests found no references to mask_dilation). Adding a focused unit test that checks the computed voxel radius for a known spacing would help prevent regressions.

Copilot uses AI. Check for mistakes.
Comment on lines 187 to 191
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

Optional: using int(mask_dilation_mm / spacing) floors the voxel radius, so the physical dilation will be <= the requested mm (sometimes noticeably, depending on spacing). If you want the closest physical match, consider using rounding/ceiling instead (and keep the approach consistent for fixed and moving masks).

Copilot uses AI. Check for mistakes.
self.fixed_mask = imMath.GetOutputUChar()

Expand Down Expand Up @@ -320,7 +320,7 @@ def register(
if self.mask_dilation_mm > 0:
imMath = ttk.ImageMath.New(new_moving_mask)
imMath.Dilate(
int(moving_image.GetSpacing()[0] / self.mask_dilation_mm), 1, 0
int(self.mask_dilation_mm / moving_image.GetSpacing()[0]), 1, 0
)
Comment on lines 320 to 324
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

Optional: int(mask_dilation_mm / spacing) floors the voxel radius, which can under-approximate the requested physical dilation. Consider rounding/ceiling if the intention is to match mm more closely.

Copilot uses AI. Check for mistakes.
new_moving_mask = imMath.GetOutputUChar()

Expand Down
Loading