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

Matthew Brett matthew.brett at gmail.com
Tue Jun 28 09:13:18 EDT 2016


Hi,

On Mon, Jun 27, 2016 at 11:50 PM, Samuel St-Jean <stjeansam at gmail.com> wrote:
> I'll need to play a bit with it today and ask some guy about the flipping, I
> am reporting for someone else actually. So, it seems to be harmless to put
> back the header in the case of unchanged affine (as it is in my situation),
> could be that other software downstream does not really like something else.
> I did not reuse it because of dtypes, voxelsize and other things which may
> wildly change on processed data.
>
>
> Anyway, this example is using your case number 1, no header, affine is
> gotten from get_affine. Of course it was not modified during the processing,
> and I end up with a different sform/qform. Accoridng to your first point, I
> expected them to be identical, but I end up with a sligthly different (and
> diagonal) qform. They also have different names, so ifthey were set to the
> same thing I would expect them to be pristine copies.
>
> That's a bit troublesome now as JC pointed out, since we all use the same
> set of scripts for the  heavy processing, which don't reuse headers as I can
> remember. Does not seem to cause any problem for us, don't want to receive
> hate mail by other people using some of our stuff and saying we broke their
> data though.
>
> Are sform and qform set to match the affine in exactly the same way, or does
> some transformation is applied and then they are identical? I went through
> the info on the nibabel website about headers and affine, so maybe I just
> missed it also if anyone has other info to add.

Well - remember that the qform is stored differently from the sform.
In particular, the qform cannot store shears, because it's the
composition of the translations on a pure rotation on the zooms,
whereas the sform can, because it stores a full 3 x 4 affine matrix.

The sform and the qform will have different so-called "transform
codes", if the sform and qform both get set (rules as described in my
last email).  This is because the default transform codes are
different for the sform and qform, and we use the defaults.

The flip should always be the same though, when the sform and qform
get set together - at least if the external software is reading the
header correctly.

Cheers,

Matthew


More information about the Neuroimaging mailing list