[Neuroimaging] [nibabel] sform/qform flipping left - right in the affine and (possibly) fsl

Samuel St-Jean stjeansam at gmail.com
Fri Jun 24 02:35:19 EDT 2016


Hello,

So this is probably gonna look as a confused question because I still do not fully understand the issue myself. Anyway, reading upon https://github.com/nipy/nibabel/pull/90 and playing with loading a nifti and saving it back, it seems like sometimes the affine, sform and qform do not fully agree upon something and end up overwriting each other.

This also seems to only happen with data that went through fsl, like the HCP datasets. So basically a normal pipeline involving nibabel is like


volume = nib.load('my_data.nii.gz')
data = volume.get_data()
affine volume.get_affine()

## Do stuff on data

nib.save(nib.Nifti1Image(data, affine),'my_new_data.nii.gz')


Note how I did not save the header in this case. Now, for almost all cases, this works fine and a new header get created. And now for the question :

Is it a bad idea to strip out the header (since dtype, pixdim and other things might change depending on the processing involved)?
Is it possible to save back exactly the same header / sform / qform so that data won't be flipped in e.g. fslvew afterward? Is it just because software don't play well together or there is an unseen issue I don't get here?

I also remember a few years back playing the whole afternoon with get/set qform and sform rewriting our affines everytime, so I though might as well ask everyone since we never fully figured out the logic between what sets the affine in the header and why.


Thanks for reading,

Samuel



More information about the Neuroimaging mailing list