-
Notifications
You must be signed in to change notification settings - Fork 1
BUG:ACCESS_VIOLATION crashes and NumPy shape bug in 4D CT pipeline #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -270,6 +270,12 @@ module = [ | |
| ] | ||
| disable_error_code = ["import-not-found", "import-untyped"] | ||
|
|
||
| [[tool.mypy.overrides]] | ||
| # torch/icon_registration/unigradicon are lazy-loaded at runtime; string | ||
| # forward-reference annotations like "torch.Size" are intentional. | ||
| module = ["physiomotion4d.register_images_icon"] | ||
| ignore_errors = true | ||
|
|
||
|
Comment on lines
+273
to
+278
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid blanket type/lint suppression for Lines 273-278 ( As per coding guidelines, "Use full type hints with Also applies to: 407-408 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| [tool.pyright] | ||
| # Third-party packages (e.g. pyvista) are in dependencies but may have no stubs; | ||
| # do not report import-not-found so analysis matches mypy overrides above. | ||
|
|
@@ -398,6 +404,8 @@ ignore = [ | |
| "test_*.py" = ["S101", "PLR2004", "ARG001", "ARG002"] | ||
| "tests/*.py" = ["S101", "PLR2004", "ARG001", "ARG002"] | ||
| "experiments/**/*.py" = ["T201", "S101"] | ||
| # torch/icon_registration are lazy-loaded at runtime; forward-reference strings are intentional | ||
| "src/physiomotion4d/register_images_icon.py" = ["F821"] | ||
|
|
||
| [tool.ruff.lint.isort] | ||
| known-first-party = ["physiomotion4d"] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,12 +36,12 @@ def main() -> int: | |
| --pca-number-of-modes 10 \\ | ||
| --output-dir ./results | ||
|
|
||
| # Enable mask-to-image refinement (requires template labelmap and label IDs) | ||
| # Enable labelmap-to-image refinement (requires template labelmap and label IDs) | ||
| %(prog)s \\ | ||
| --template-model heart_model.vtu \\ | ||
| --patient-models lv.vtp rv.vtp myo.vtp \\ | ||
| --patient-image patient_ct.nii.gz \\ | ||
| --mask-to-image \\ | ||
| --labelmap-to-image \\ | ||
| --template-labelmap heart_labelmap.nii.gz \\ | ||
| --template-labelmap-muscle-ids 1 2 3 \\ | ||
| --template-labelmap-chamber-ids 4 5 6 \\ | ||
|
|
@@ -76,7 +76,7 @@ def main() -> int: | |
| ) | ||
| parser.add_argument( | ||
| "--template-labelmap", | ||
| help="Path to template labelmap image (.nii.gz, .nrrd, .mha). Required when --mask-to-image is set.", | ||
| help="Path to template labelmap image (.nii.gz, .nrrd, .mha). Required when --labelmap-to-image is set.", | ||
| ) | ||
| parser.add_argument( | ||
| "--output-dir", required=True, help="Output directory for results" | ||
|
|
@@ -119,18 +119,18 @@ def main() -> int: | |
|
|
||
| # Registration configuration | ||
| parser.add_argument( | ||
| "--no-mask-to-mask", | ||
| dest="use_mask_to_mask", | ||
| "--no-labelmap-to-labelmap", | ||
| dest="use_labelmap_to_labelmap", | ||
| action="store_false", | ||
| default=True, | ||
| help="Disable mask-to-mask deformable registration", | ||
| help="Disable labelmap-to-labelmap deformable registration", | ||
| ) | ||
| parser.add_argument( | ||
| "--mask-to-image", | ||
| dest="use_mask_to_image", | ||
| "--labelmap-to-image", | ||
| dest="use_labelmap_to_image", | ||
| action="store_true", | ||
| default=False, | ||
| help="Enable mask-to-image refinement (requires --template-labelmap and label IDs)", | ||
| help="Enable labelmap-to-image refinement (requires --template-labelmap and label IDs)", | ||
| ) | ||
| parser.add_argument( | ||
| "--use-ICON-refinement", | ||
|
|
@@ -163,9 +163,11 @@ def main() -> int: | |
| print(f"Error: Patient image not found: {args.patient_image}") | ||
| return 1 | ||
|
|
||
| if args.use_mask_to_image: | ||
| if args.use_labelmap_to_image: | ||
| if args.template_labelmap is None: | ||
| print("Error: --template-labelmap is required when --mask-to-image is set.") | ||
| print( | ||
| "Error: --template-labelmap is required when --labelmap-to-image is set." | ||
| ) | ||
| return 1 | ||
| if not os.path.exists(args.template_labelmap): | ||
| print(f"Error: Template labelmap not found: {args.template_labelmap}") | ||
|
|
@@ -238,10 +240,12 @@ def main() -> int: | |
| pca_model=pca_model, | ||
| pca_number_of_modes=args.pca_number_of_modes, | ||
| ) | ||
| if args.use_mask_to_mask: | ||
| workflow.set_use_mask_to_mask_registration(args.use_mask_to_mask) | ||
| if args.use_mask_to_image: | ||
| workflow.set_use_mask_to_image_registration( | ||
| if args.use_labelmap_to_labelmap: | ||
| workflow.set_use_labelmap_to_labelmap_registration( | ||
| args.use_labelmap_to_labelmap | ||
| ) | ||
|
Comment on lines
+243
to
+246
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Always wire the L2L flag, including the disabled case. When Suggested fix- if args.use_labelmap_to_labelmap:
- workflow.set_use_labelmap_to_labelmap_registration(
- args.use_labelmap_to_labelmap
- )
+ workflow.set_use_labelmap_to_labelmap_registration(
+ args.use_labelmap_to_labelmap
+ )🤖 Prompt for AI Agents |
||
| if args.use_labelmap_to_image: | ||
| workflow.set_use_labelmap_to_image_registration( | ||
| True, | ||
| template_labelmap=template_labelmap, | ||
| template_labelmap_organ_mesh_ids=args.template_labelmap_muscle_ids, | ||
|
|
@@ -282,17 +286,17 @@ def main() -> int: | |
| print(f" Registered surface: {output_surface_file}") | ||
|
|
||
| # Save registered labelmap if available | ||
| if workflow.m2i_template_labelmap is not None: | ||
| if workflow.l2i_template_labelmap is not None: | ||
| output_labelmap_file = os.path.join( | ||
| args.output_dir, f"{args.output_prefix}_labelmap.nii.gz" | ||
| ) | ||
| itk.imwrite(workflow.m2i_template_labelmap, output_labelmap_file) | ||
| itk.imwrite(workflow.l2i_template_labelmap, output_labelmap_file) | ||
| print(f" Registered labelmap: {output_labelmap_file}") | ||
| elif workflow.m2m_template_labelmap is not None: | ||
| elif workflow.l2l_template_labelmap is not None: | ||
| output_labelmap_file = os.path.join( | ||
| args.output_dir, f"{args.output_prefix}_labelmap.nii.gz" | ||
| ) | ||
| itk.imwrite(workflow.m2m_template_labelmap, output_labelmap_file) | ||
| itk.imwrite(workflow.l2l_template_labelmap, output_labelmap_file) | ||
|
Comment on lines
+289
to
+299
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Write labelmaps with ITK compression enabled. The new registered labelmap exports omit Suggested fix- itk.imwrite(workflow.l2i_template_labelmap, output_labelmap_file)
+ itk.imwrite(
+ workflow.l2i_template_labelmap,
+ output_labelmap_file,
+ compression=True,
+ )
@@
- itk.imwrite(workflow.l2l_template_labelmap, output_labelmap_file)
+ itk.imwrite(
+ workflow.l2l_template_labelmap,
+ output_labelmap_file,
+ compression=True,
+ )🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| print(f" Registered labelmap: {output_labelmap_file}") | ||
|
|
||
| # Save intermediate results if available | ||
|
|
@@ -310,12 +314,12 @@ def main() -> int: | |
| workflow.pca_template_model_surface.save(output_pca_file) | ||
| print(f" PCA result: {output_pca_file}") | ||
|
|
||
| if workflow.m2m_template_model_surface is not None: | ||
| output_m2m_file = os.path.join( | ||
| args.output_dir, f"{args.output_prefix}_m2m_surface.vtp" | ||
| if workflow.l2l_template_model_surface is not None: | ||
| output_l2l_file = os.path.join( | ||
| args.output_dir, f"{args.output_prefix}_l2l_surface.vtp" | ||
| ) | ||
| workflow.m2m_template_model_surface.save(output_m2m_file) | ||
| print(f" Mask-to-mask result: {output_m2m_file}") | ||
| workflow.l2l_template_model_surface.save(output_l2l_file) | ||
| print(f" Labelmap-to-labelmap result: {output_l2l_file}") | ||
|
|
||
| print("\n" + "=" * 70) | ||
| print("Registration completed successfully!") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Synchronize the remaining registration terminology in this README.
You updated this section to labelmap-based wording, but Line 250 still describes the same workflow as “mask-based,” which leaves conflicting guidance in one document.
🤖 Prompt for AI Agents