Aligned MRI outside brainstorm are no longuer aligned after importation

As you reported, the field sform is well read from the NIfTI in Brainstorm.

However, in Brainstorm, the vox2ras transformation can come either from sform or qform. It depends on the codes for each: sform_code and qform_code. Link to code.

If sform_code is not 2, it uses qform (if qform_code is not zero).

This behaviour is different from other software as nibabel (see link), where sform is used if sform_code is not 0. And this was how Brainstorm used to do it, until this

It seems this fix aimed to get the vox2ras from sform IFF the word coordinates were = 2 i.e., Coordinates aligned to another file's, or to anatomical "truth".

To me, the export fix, seem ok. However, I don't see the logic on the import part.


As mentioned above, nibabel prefers sform is its code is not 0. It seems FSL does the same, as well as other softwares. Though ITK preferes qform.

Related information on those NIfTI header fields:

1 Like