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

Matthew Brett matthew.brett at gmail.com
Mon Jun 27 14:20:33 EDT 2016


Hi,

On Mon, Jun 27, 2016 at 6:06 AM, Jean-Christophe Houde
<jean.christophe.houde at gmail.com> wrote:
> Just a quick note: qform_code = 0 normally means that it is not set, so I'm
> surprised to see some values in your last qto_xyz...
>
> 2016-06-27 8:04 GMT-04:00 Samuel St-Jean <stjeansam at gmail.com>:
>>
>> So, to add a more practical example to what I outlined above, seems like
>> saving a dataset in this manner preserves the sform, but changes the qform.
>> According to the doc, they should both provide the same information in
>> reconstructing the affine (possible from different origins). So I compared
>> the header of an original nifti file and the same thing after saving it
>> without headers, and here are the interesting parts.
>>
>> - sform is identical
>> - sform name changed from
>>
>> sform_name     Scanner Anat
>> sform_code     1
>>
>> to
>>
>> sform_name     Aligned Anat
>> sform_code     2
>>
>> - some qform fields went from
>>
>> qform_name     Scanner Anat
>> qform_code     1
>> qto_xyz:1      1.796652  0.000000  0.000000  -115.754318
>> qto_xyz:2      0.000000  1.795833  -0.054337  -90.885376
>> qto_xyz:3      0.000000  0.054236  1.799180  54.572971
>>
>> to
>>
>> qform_name     Unknown
>> qform_code     0
>> qto_xyz:1      1.796652  0.000000  0.000000  0.000000
>> qto_xyz:2      0.000000  1.796652  0.000000  0.000000
>> qto_xyz:3      0.000000  0.000000  1.800000  0.000000

Just to clarify - the rules for sform / qform are the following:

If you don't pass a header to image construction, then the input
`affine` gets set into both sform and qform, with default sform /
qform output codes.

If you do pass a header, and the input `affine` is the same as the
affine implied by the header (either via the sform or qform), or the
input affine is None, then the header (therefore sform / qform) is
unchanged.

If you do pass a header, and the affine is different from that implied
by the header, both sform and qform get set to match the input affine.

Does that explain what you are seeing?

Cheers,

Matthew


More information about the Neuroimaging mailing list