BUG: Fix generated partial volumes misaligned with input volume node #147
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.