Hi,
I had to convert a file from ANALYZE to NIFTI where the sform-analogue
transformation matrix came as a separate text file. I used fslchfiletype
to convert the file into NIFTI and then thought to restore the
orientation information:
Original status of conversion to NIFTI:
hanke@feanor:/tmp$ fslhd anat.nii.gz |egrep '(to_xyz)|(form_code)'
qform_code 0
qto_xyz:1 0.898438 0.000000 0.000000 0.000000
qto_xyz:2 0.000000 1.000000 0.000000 0.000000
qto_xyz:3 0.000000 0.000000 1.421875 0.000000
qto_xyz:4 0.000000 0.000000 0.000000 1.000000
sform_code 0
sto_xyz:1 0.000000 0.000000 0.000000 0.000000
sto_xyz:2 0.000000 0.000000 0.000000 0.000000
sto_xyz:3 0.000000 0.000000 0.000000 0.000000
sto_xyz:4 0.000000 0.000000 0.000000 0.000000
Text format matrix:
hanke@feanor:/tmp$ cat mat.txt
0.0000000e+00 0.0000000e+00 -1.4218750e+00 9.1160938e+01
-8.9843750e-01 0.0000000e+00 0.0000000e+00 1.3244922e+02
0.0000000e+00 -1.0000000e+00 0.0000000e+00 1.2850000e+02
0.0000000e+00 0.0000000e+00 0.0000000e+00 1.0000000e+00
(Failing) Attempt to apply as sform matrix:
hanke@feanor:/tmp$ fslorient -setsform $(cat mat.txt) anat.nii.gz
hanke@feanor:/tmp$ fslhd anat.nii.gz |egrep '(to_xyz)|(form_code)'
qform_code 0
qto_xyz:1 0.898438 0.000000 0.000000 0.000000
qto_xyz:2 0.000000 1.000000 0.000000 0.000000
qto_xyz:3 0.000000 0.000000 1.421875 0.000000
qto_xyz:4 0.000000 0.000000 0.000000 1.000000
sform_code 0
sto_xyz:1 0.000000 0.000000 0.000000 0.000000
sto_xyz:2 0.000000 0.000000 0.000000 0.000000
sto_xyz:3 0.000000 0.000000 0.000000 0.000000
sto_xyz:4 0.000000 0.000000 0.000000 0.000000
Apparently an sform code != 0 is required:
hanke@feanor:/tmp$ fslorient -setsformcode 1 anat.nii.gz
hanke@feanor:/tmp$ fslhd anat.nii.gz |egrep '(to_xyz)|(form_code)'
qform_code 1
qto_xyz:1 -0.898438 0.000000 -0.000000 0.000000
qto_xyz:2 0.000000 1.000000 -0.000000 0.000000
qto_xyz:3 0.000000 0.000000 1.421875 0.000000
qto_xyz:4 0.000000 0.000000 0.000000 1.000000
sform_code 1
sto_xyz:1 -0.898438 0.000000 0.000000 0.000000
sto_xyz:2 0.000000 1.000000 0.000000 0.000000
sto_xyz:3 0.000000 0.000000 1.421875 0.000000
sto_xyz:4 0.000000 0.000000 0.000000 1.000000
However, this also changes the qform and sform matrices as well. But
with a proper sform code I can finally apply the matrix.
hanke@feanor:/tmp$ fslorient -setsform $(cat mat.txt) anat.nii.gz
hanke@feanor:/tmp$ fslhd anat.nii.gz |egrep '(to_xyz)|(form_code)'
qform_code 1
qto_xyz:1 -0.898438 0.000000 -0.000000 0.000000
qto_xyz:2 0.000000 1.000000 -0.000000 0.000000
qto_xyz:3 0.000000 0.000000 1.421875 0.000000
qto_xyz:4 0.000000 0.000000 0.000000 1.000000
sform_code 1
sto_xyz:1 0.000000 0.000000 -1.421875 91.160934
sto_xyz:2 -0.898438 0.000000 0.000000 132.449219
sto_xyz:3 0.000000 -1.000000 0.000000 128.500000
sto_xyz:4 0.000000 0.000000 0.000000 1.000000
This time the qform matrix remains unchanged.
I guess I still have difficulties to grasp all relations between qform
and sform, but it would be nice if fslorient would announce if it does
not/cannot do what it was told (or maybe even explain why).
Thanks,
Michael
--
GPG key: 1024D/3144BE0F Michael Hanke
http://apsy.gse.uni-magdeburg.de/hanke
ICQ: 48230050
|