I’m integrating NiftyReg into an extension. (one of the goals is to get the computed transformation/deformation into Slicer)
I registered two images with reg_f3d and saved the control point grid (to later get the deformation).
reg_f3d -ref fixed.nii -flo moving.nii -res warped.nii -cpp controlPointGrid.nii
I then used reg_transform to get the displacement field as a .nii
reg_transform -ref fixed.nii -disp controlPointGrid.nii displacement.nii
I then loaded the displacement.nii into Slicer as a Transform. I got the following warning, but I’m not sure if it is relevant:
Warning: Loading /Desktop/volumes/niftyreg/displacement.nii - NIFTI file may not contain valid displacement field, the transform may be incorrect. Intent code is expected to be ‘1006’ (displacement vector), but the file contained: ‘1007’. Filename: ‘/Desktop/volumes/niftyreg/displacement.nii’.
Then I applied the transformation in Slicer to the moving image, but the result was very different (‘clearly wrong’) from the moving image transformed by NiftyReg.
First screenshot is a 50/50 overlay of the NiftyReg warped image (purple) over the fixed image (green)
First screenshot is a 50/50 overlay of the Slicer transformed image (purple) over the fixed image (green)
I’m not sure if the displacement field is somehow encoded differently/incorrectly or if I’m missing some steps in between. (the author of NiftyReg mentioned that “Note that the transformation are encoded from the reference to the floating space and all is stored in physical space (mm) rather than voxel space.” - not sure if this is relevant here)
Here’s a link to all the volumes