# Transform 5TT to DWI space : Inconsistent qform and sform

**URL:** <https://community.mrtrix.org/t/transform-5tt-to-dwi-space-inconsistent-qform-and-sform/2070>\
**Category:** Uncategorized\
**Created:** [November 23, 2018, 10:05am UTC](https://community.mrtrix.org/t/transform-5tt-to-dwi-space-inconsistent-qform-and-sform/2070 "2018-11-23T10:05:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![liyuan\_yang](https://community.mrtrix.org/user_avatar/community.mrtrix.org/liyuan_yang/32/345_2.png) [@liyuan\_yang](https://community.mrtrix.org/u/liyuan_yang)\
**Post date:** [November 23, 2018, 10:05am UTC](https://community.mrtrix.org/t/transform-5tt-to-dwi-space-inconsistent-qform-and-sform/2070/1 "2018-11-23T10:05:29Z")

</div>

Dear MRtrix-Experts,

I get the 5TT image in T1 space.

Next I transform the 5TT image to DWI space(I have read [this post](https://community.mrtrix.org/t/5ttgen-waiitng-for-creation-of-new-file/1044/2)).

```auto

flirt -in T1.nii -ref FA.nii -out T12FA.nii -omat T12FA.mat

transformconvert T12FA.mat T1.nii FA.nii flirt_import T12FAmrt.mat

mrtransform 5TT.nii 5TT2FA.nii -linear T12FAmrt.mat

mrtransform: [WARNING] the input linear transform is not orthonormal and therefore applying this without the -template option will mean the output header transform will also be not orthonormal

```

**I find that the qform and sform of the 5TT-coregistered-DWI image are inconsistent**

```auto
fslhd 5TT2FA.nii
qform_name Scanner Anat
qform_code 1
qto_xyz:1 0.997192 0.005625 0.074613 -104.013123
qto_xyz:2 -0.001768 0.998663 -0.051654 -133.454071
qto_xyz:3 -0.074803 0.051378 0.995874 -67.540840
qto_xyz:4 0.000000 0.000000 0.000000 1.000000
qform_xorient Left-to-Right
qform_yorient Posterior-to-Anterior
qform_zorient Inferior-to-Superior
sform_name Scanner Anat
sform_code 1
sto_xyz:1 1.030852 0.003590 0.075165 -104.013123
sto_xyz:2 -0.003884 1.021482 -0.058058 -133.454071
sto_xyz:3 -0.075895 0.046108 1.027731 -67.540840
sto_xyz:4 0.000000 0.000000 0.000000 1.000000
sform_xorient Left-to-Right
sform_yorient Posterior-to-Anterior
sform_zorient Inferior-to-Superior
file_type NIFTI-1+
file_code 1

```

Then using the 5TT-coregistered-DWI image gets gmwmi image

```auto

5tt2gmwmi 5TT2FA.nii gmwmi.nii

5tt2gmwmi: [WARNING] voxel spacings inconsistent between NIFTI s-form and header field pixdim

5tt2gmwmi: [WARNING] qform and sform are inconsistent in NIfTI image &quot;5TT2FA.nii&quot; - using qform

5tt2gmwmi: [100%] Generating GMWMI seed mask

```

To check the results,I use fsleyes and mrview to test whether they match well.

In fsleyes , the 5TT-coregistered-DWI image and T1-coregistered-DWI image matches well,but the gmwmi image mismatch.

 ![1](https://community.mrtrix.org/uploads/default/original/2X/5/5e47de9b5b5b1799371b8ac7af5a80daa69c317c.png)

In mrview , the 5TT-coregistered-DWI image and gmwmi image matches well,but the T1-coregistered-DWI image mismatch.!

 ![screenshot0003](https://community.mrtrix.org/uploads/default/original/2X/a/a86864bcf3d73d7e8fea735306dfcd57b229d507.png)

So My questions are :

1.when transforming 5TT image to DWI space (no regriding ),why sform and qform are inconsistent?

2.The looking like mismatch of the three images in fsleyes or mrview will cause problems about the following analysis such as tractogram or constructing connectome?

Cheers  
Liyuan

---

<div class="post-metadata">

**Author:** ![rsmith](https://community.mrtrix.org/user_avatar/community.mrtrix.org/rsmith/32/2672_2.png) [@rsmith](https://community.mrtrix.org/u/rsmith)\
**Post date:** [November 25, 2018, 9:48am UTC](https://community.mrtrix.org/t/transform-5tt-to-dwi-space-inconsistent-qform-and-sform/2070/2 "2018-11-25T09:48:35Z")

</div>

Hi Liyuan,

> `flirt -in T1.nii -ref FA.nii -out T12FA.nii -omat T12FA.mat`

By not explicitly setting the degrees of freedom, `flirt` will automatically permit 12 degrees of freedom, i.e. a full affine registration & resulting transformation. This will almost invariably not be orthonormal, since it’s the linear terms over and above the 3 translations and 3 rotations that are the defining features of non-orthonormality in this context.

The NIfTI `qform` matrix is actually stored internally as a _quaternion_ (and 3 translations); this representation is fundamentally incapable of representing non-orthonormal transformations. So if the `sform` matrix is non-orthonormal, it is mathematically impossible for the `qform` transformation to match it.

Fundamentally the issue is that the registration between images of the same subject at the same time point should _not_ contain any terms over and above a rigid-body translation i.e. 6 degrees of freedom. I’ll skip here the discussion on why visualisation of the issue is different between `fsleyes` and `mrview`, or why the automatic selection of the `qform` matrix has the effect it does; best to focus on fixing the fundamental underlying issue.

Rob

---

<div class="post-metadata">

**Author:** ![liyuan\_yang](https://community.mrtrix.org/user_avatar/community.mrtrix.org/liyuan_yang/32/345_2.png) [@liyuan\_yang](https://community.mrtrix.org/u/liyuan_yang)\
**Post date:** [November 26, 2018, 1:09pm UTC](https://community.mrtrix.org/t/transform-5tt-to-dwi-space-inconsistent-qform-and-sform/2070/3 "2018-11-26T13:09:14Z")

</div>

Thanks so much for your helpful reply !
