c3d
c3d copied to clipboard
-origin not using NIFTI coordinates
c3d -help origin
-origin : Set image origin
Syntax: `-origin vector `
Set the origin of the image. The origin is the world coordinate (in NIfTI coordinate space) of the center of the voxel (0,0,0) in the image. The origin should be specified in millimeters.
c3d input.img -origin 100x100x100mm -o output.img
But the code calls SetOrigin
https://github.com/pyushkevich/c3d/blob/master/ConvertImageND.cxx#L1515-L1521
which is not overridden in itkOrientedRASImage.h .
The coordinate of voxel 0,0,0 should be the value of the qoffset field in the NIFTI header. But if I do
% c3d tpl-MNI152NLin2009cAsym_res-01_T1w.nii.gz -info-full | grep qoffset
qoffset_x = -96
qoffset_y = -132
qoffset_z = -78
% c3d tpl-MNI152NLin2009cAsym_res-01_T1w.nii.gz -origin -96x-132x-78mm -o origin_changed.nii.gz
the origin is changed
% c3d tpl-MNI152NLin2009cAsym_res-01_T1w.nii.gz -origin -96x-132x-78mm -info-full | grep qoffset
qoffset_x = 96
qoffset_y = 132
qoffset_z = -78