-
Notifications
You must be signed in to change notification settings - Fork 299
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
Make sure the xform_code is correct when generating references #745
Comments
Just something to be careful on: The standard says that sform takes precedence over qform, which means the qform can be ignored and not updated when transformations are applied by standards-conforming software. So there's the possibility that setting the qform codes to 2 could be misleading. Which is part of what makes ANTs' refusal to correctly handle sforms so frustrating. |
Turns out the reason Related: https://www.mail-archive.com/[email protected]/msg55547.html I believe that syncing the qform to the sform in the BOLD series at the start should resolve the issue, as the reference image will be derived from that, and the transforms will all be calculated on the reference and applied to the series. |
Incidentally, it's possible (though hacky) to turn a import os
import nibabel as nb
from gzip import GzipFile
img = nb.load('bold.nii.gz')
pair = nb.Nifti1Pair.from_image(img)
# This is the default offset, but real code would need to account for extensions
pair.header.set_data_offset(352)
with GzipFile('bold.hdr.gz', 'wb') as fobj:
fobj.write(pair.header.binaryblock)
os.link('bold.nii.gz', 'bold.img.gz') I'm just thinking in terms of strategies for fixing headers without making full copies of large BOLD series. |
I've written down the last two comments in two new issues that we may consider in a future, but right now they are not burning urgent. This issue is also related to #726. I guess this issue is completely covered now, so I'll close it. |
Comes from nipreps/niworkflows#202 (comment).
We need to make sure that the xform_code is 2 when generating images aligned in anatomical space and 4 when generating results on MNI space.
EDIT:
This issue also includes generating the appropriate documentation about affines.
Use cases (from nipreps/niworkflows#202 (comment)):
When moving within the same space (SDC, head motion correction, SBRef-EPI), we keep the original xforms (even if they are wrong in the original files).
When moving to different space (anatomical or MNI), we are generating an image taken as reference space. So it is this point when we need to make sure that the xform code is the appropriate one. Since we pass on this reference image to the registration interface, the xform matrices should, indeed, be copied over the resulting images. Same for ApplyTransforms.
When several T1w images are present, the affine is set to the one chosen as reference or a new affine corresponding to the intermediate space to all will be generated (see anat affine appears off for ds000114 between data and fmriprep output #624).
Bottomline: no interface should change xforms unless we are certain we want to do that. Only
GenerateSamplingReference
should make these changes.EDIT: this issue also covers #260:
@chrisfilo proposed:
And @effigies added #573 (comment):
The text was updated successfully, but these errors were encountered: