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
General discussion about qform/sform matrices and codes #3283
Comments
I've been thinking about this a lot recently, too, see #3270 (comment). As a bare minimum, I was thinking that we could come up with a set of checks to see whether the header complies with NIFTI specifications. Then, apply these checks when saving/loading images to catch issues. And, perhaps emit only But, checks like these would just be for getting an idea of the current state of SCT. (What problems exist, which parts of SCT are affected, etc.) I'm not sure what to do about those problems yet. I'm glad you've shared approaches from other software. |
One of the qform/sform issues linked above (#3232) sparked a discussion thread over at nibabel: nipy/nibabel#1001 That issue contains some (admittedly frank) comments that nonetheless I appreciate hearing.
That last comment piqued my interest. Are SCT's current practices frowned upon? I'm curious how the I'm also wondering... If we were using Some extra benefits to this:
(Switching from |
i have nothing more to say on #3283 (comment), i agree 100% with your comment @joshuacwnewton |
On this note, while exploring the NiPreps ecosystem, I came across the Notably, It has an Even for something as simple as "copying an affine matrix from a reference image" they do things a little differently than we do. Compare our current approach (from #2400): spinalcordtoolbox/spinalcordtoolbox/image.py Lines 380 to 384 in d080b8d
With their internal function # Copy xform infos
qform, qform_code = orig.header.get_qform(coded=True)
sform, sform_code = orig.header.get_sform(coded=True)
header = resampled.header.copy()
header.set_qform(qform, int(qform_code))
header.set_sform(sform, int(sform_code))
header["descrip"] = "xform matrices modified by %s." % (message or "(unknown)") Little things like the usage of the setters/getters, as well as updating the header description, seem like valuable takeaways. All in all, I'm really interested in exploring NiPreps further. |
Small update: I expected to be able to call Description of nipype for the curiousQuoting from the link above
So, Because of this, connecting |
Description
There has been a lot of issues related to the NIfTI's qform/sform and qform_code header fields. The purpose of this issue (which is not really an issue) is to centralize all the relevant information and cross-reference related issues. This issue also gathers various strategies for how to best deal with qform/sform fields.
Here are relevant links:
Resolved issues:
int
, but array datatype isfloat
#3232Open issues:
0
/2
#3005Nifti1Image
without matching header/affine will cause default s/qform codes (0
/2
) #32952
/1
) to reflect alignment with MNI space (4
) #3296set_qform
/set_sform
without specifyingcode
will overwrite0
codes with2
#4134What do other neuroimaging software do?
nibabel (used by SCT):
The algorithm to deal with qform/sform is defined in the get_best_affine() method. It is:
Which means that sform gets precedent on the qform.
ITK (used by ANTs):
MRtrix:
fMRIprep:
TODO
Possible solutions
The text was updated successfully, but these errors were encountered: