Closed oesteban closed 2 years ago
cc/ @psadil could you give this a try?
Basically, you can do this offline with:
import nibabel as nb
from mriqc.synthstrip.cli import conform
conform(nb.load("input_image.nii.gz")).to_filename("conformed.nii.gz")
With the old code, you should see the wrong image shape (considering the reference that of synthstrip). With this PR you should see the shortest axis put before.
Let me know what you find.
I'm re-reading the original issue, and thought a bit about your solution:
# ...calculate target_affine above here...
# Get corner voxel centers in mm
corners_xyz = np.abs(
affine
@ target_affine
@ np.hstack((corner_centers_ijk, np.ones((len(corner_centers_ijk), 1)))).T
)
This indeed works because it implicitly reorders the shapes. I feel my patch is more explicit and, therefore less prone to future regressions.
Alright, I'm pretty confident this is the fix -- I'm going to do the wrong thing and merge this to then release if tests pass on master, on a Friday evening.
Confirming that, with the new changes, the original image I'd been working with has not been cropped. So, looks good to me
The calculation of the new shape within the preprocessing for SynthStrip was done in XYZ coordinates (i.e., extents for each physical axis were estimated and divided by the new 1mm pixel size). However, the new axis sizes did not account for data being stored with IJK -> XZY convention (corresponding to LIA).
This PR accounts for this miscalculation.
Resolves: #999.