-
Notifications
You must be signed in to change notification settings - Fork 262
qform not saved #463
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
Comments
FYI found a thread on FSL listserve that says for FSL the sform is primary and qform is fall back, so it depends. j |
Could you say more about what exactly you are doing? I guess loading into memory as PARREC format, and then converting to nifti, using a script? Could you give a minimal script that demonstrates the problem? |
sure. here is nii header dump straight out of parrec2nii: you see only sform data in the header. toddr@scotty:/...ntrol/hbm_group_data/ants_template/template_v1$ fslhd -x SCS353_WIP_MEMP_VBM_SENSE_11_1_rms.nii.gz |
here is the command with print statements inserted in parrec2nii to expose affine and qform values: ornt after LAS dot affine = [[ -3.64994708 0. 1.83564171 123.66276611] toddr@scotty: |
i have a fix which uses fslorient -copysform2qform in a subshell. its inelegant but needs must. |
Having now looked in detail at nifti1.py header_dtd definitions there is no qform matrix definition (or sform matrix for that matter), just the qform code, quaternions, and qoffsets but they don't seem to survive writing to file. the sform matrix gets generated presumably from that, tho i havn't figured out how yet. seems possible the qform matrix could be easily generated as well, then written. |
The qform matrix derives from the translations, composed on the quaternion rotations composed with the zooms with an extra flip - description here : http://nifti.nimh.nih.gov/nifti-1/documentation/nifti1fields/nifti1fields_pages/qsform.html - implemented at https://github.com/nipy/nibabel/blob/master/nibabel/nifti1.py#L889 I'm guessing that the problem here is that, when you create a new blank NIfTI header, and ask to set an affine matrix into the header, the default qform has code 0 ('unknown') - see https://github.com/nipy/nibabel/blob/master/nibabel/nifti1.py#L1738 . I guess you want the affine code to be something else, such as 2 'aligned'. This will then show up with (for example) the FSL output you are looking at. |
yes indeed. how could than implemented without new code? do |
Right - |
thanks matthew, that worked. problem solved. i would recommend the one line added to the parrec2nii binary script at line 225 in a pull request. is it faster for you or shall i?
|
Would you mind doing it? If you have time, it would be good to have a test too. |
no worries. i'll give it a go. |
@mrjeffs - any progress? Can I help? |
We're getting to close to a release - any chance of PR for this in the next couple of days? |
congrats to jasper for doing the heavy lifting on building the tests. |
MRG: parrec2nii sets qform code to 2 Set qform code to 2 instead of 0 when writing out parrec2nii images. Closes #463
hi matthew et al, just converted both some of my parrec data and then the nibabel/test/data and found no qform in the nii files. the sform is there but no qform. it is in the pr_hdr and the nhdr object. i can access it using the get_qform() method but it does not make it into the actual saved file. This is an issue because some packages do not fall back on the sform when the qform is missing and without offsets things get a little unpredictable for example with ANTS.
can you confirm this behavior and offer a solution?
jeff
The text was updated successfully, but these errors were encountered: