Skip to content
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

BUG: Fix generated partial volumes misaligned with input volume node #147

Merged
merged 1 commit into from
Nov 20, 2024

Conversation

sbelsk
Copy link
Contributor

@sbelsk sbelsk commented Nov 16, 2024

Fixes #125

This commit fixes how the generated PV tiffs are loaded, to ensure that the partial volume nodes preserve the original RAS/LPS orientation of the input volume node.

Previously, the generated tiff files were always loaded in LPS-like orientation (e.g., the IJK-to-RAS Direction Matrix would have -1 in the first two diagonal entries). This would work correctly on most data we have tested against, when the data is also originally in LPS orientation. However, for data this is inherently in RAS directions (e.g., the IJK-to-RAS Direction Matrix would have 1 in the first two diagonal entries), or for cropped volume nodes (cropping is observed to flip the volume from RAS to LPS directions or vice-versa), the loaded PVs would appear misaligned.

Note

This fix ensures that when the PVs are aligned when loaded automatically at the end of the partial volume generation process, but it won't fix the fact that the TIFF files don't store the directions of the volume node. If volume files generated by SAM are opened in Slicer through the "Add Data" widget, their IJK-to-RAS direction will still default to having -1 in the first two diagonal entries.
For this reason, the generated volumes must be imported using the "Load Partial Volumes" button under the "Partial Volume Generation" group when the corresponding input volume node is selected in the Pre-Processing module.

Copy link
Contributor

@amymmorton amymmorton left a comment

Choose a reason for hiding this comment

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

Great!

image

All volume nodes (cropped etc) produce appropriate PV+tfm woot@!
image

This commit fixes how the generated PV tiffs are loaded, to ensure that
the partial volume nodes preserve the original RAS/LPS orientation of
the input volume node.

Previously, the generated tiff files were always loaded in LPS-like
orientation (e.g., the IJK-to-RAS Direction Matrix would have -1 in the
first two diagonal entries). This would work correctly on most data we
have tested against, when the data is also originally in LPS
orientation. However, for data this is inherently in RAS directions
(e.g., the IJK-to-RAS Direction Matrix would have 1 in the first two
diagonal entries), or for cropped volume nodes (cropping is observed to
flip the volume from RAS to LPS directions or vice-versa), the loaded
PVs would appear misaligned.
@sbelsk sbelsk force-pushed the fix-misaligned-generated-pvs branch from 0dc40eb to 6bea228 Compare November 20, 2024 15:29
@sbelsk sbelsk merged commit 54d8daa into BrownBiomechanics:main Nov 20, 2024
2 checks passed
@sbelsk sbelsk deleted the fix-misaligned-generated-pvs branch November 20, 2024 15:48
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.

Partial Volumes Generated do not spatially align with VolumeNode Input
3 participants