[MINC-users] NIfTI to MINC revisited

Simon Eskildsen eskild at gmail.com
Tue Aug 14 07:26:07 EDT 2012


Hi all,

I have problems keeping the right coordinate system(s) when converting
nifti to minc and back (after some minc magic). During my hunt for a
solution, I came across the discussion about the future of minc from
last year and noticed this statement from Andrew:

> I think we have "sufficient" compatibility with Nifti right now (nii2mnc, mnc2nii)

Let's see if my problem is covered by "sufficient" :)
A simple test:

$ nii2mnc -v
program: 2.1.20
libminc: 2.1.20
netcdf : 3.5.0 of Apr 21 2010 15:47:20 $
HDF5   : 1.8.5

$ mnc2nii -v
program: 2.1.20
libminc: 2.1.20
netcdf : 3.5.0 of Apr 21 2010 15:47:20 $
HDF5   : 1.8.5

$ nii2mnc anonymous.nii anonymous_minc.mnc
$ mnc2nii anonymous_minc.mnc recovered.nii

I found that the mapping to scanner space disappears, while the
mapping to standard space changes (see the headers below). In this
case these mappings are identical in the original file.
The original and recovered image do not align in any viewer I've tried
(itksnap, mricron, fslview).

I'm no expert in quaternions, direction cosines, and whatnot, so I
welcome suggestions.

Simon



The headers:


$ fslhd anonymous.nii
filename       anonymous.nii

sizeof_hdr     348
data_type      INT16
dim0           3
dim1           256
dim2           256
dim3           176
dim4           1
dim5           1
dim6           1
dim7           1
vox_units      mm
time_units     s
datatype       4
nbyper         2
bitpix         16
pixdim0        0.0000000000
pixdim1        1.0000000000
pixdim2        1.0000000000
pixdim3        1.0000000000
pixdim4        0.0000000000
pixdim5        0.0000000000
pixdim6        0.0000000000
pixdim7        0.0000000000
vox_offset     352
cal_max        0.0000
cal_min        0.0000
scl_slope      1.000000
scl_inter      0.000000
phase_dim      0
freq_dim       0
slice_dim      0
slice_name     Unknown
slice_code     0
slice_start    0
slice_end      0
slice_duration 0.000000
time_offset    0.000000
intent         Unknown
intent_code    0
intent_name
intent_p1      0.000000
intent_p2      0.000000
intent_p3      0.000000
qform_name     Scanner Anat
qform_code     1
qto_xyz:1      -0.015369  0.078765  0.996775  -95.418961
qto_xyz:2      -0.999882  -0.000984  -0.015340  164.075089
qto_xyz:3      0.000228  0.996893  -0.078770  -58.668182
qto_xyz:4      0.000000  0.000000  0.000000  1.000000
qform_xorient  Anterior-to-Posterior
qform_yorient  Inferior-to-Superior
qform_zorient  Left-to-Right
sform_name     Scanner Anat
sform_code     1
sto_xyz:1      -0.015369  0.078765  0.996775  -95.418961
sto_xyz:2      -0.999882  -0.000984  -0.015340  164.075089
sto_xyz:3      0.000228  0.996893  -0.078771  -58.668182
sto_xyz:4      0.000000  0.000000  0.000000  1.000000
sform_xorient  Anterior-to-Posterior
sform_yorient  Inferior-to-Superior
sform_zorient  Left-to-Right
file_type      NIFTI-1+
file_code      1
descrip        3T 3D GR\IR TR=2420ms/TE=3.7ms/FA=9deg 31-Mar-2011 16:25:15.378
aux_file


$ mincheader anonymous_minc.mnc
hdf5 anonymous_minc {
dimensions:
        xspace = 256 ;
        yspace = 256 ;
        zspace = 176 ;
variables:
        short image(zspace, yspace, xspace) ;
                image:dimorder = "zspace,yspace,xspace" ;
                image:varid = "MINC standard variable" ;
                image:vartype = "group________" ;
                image:version = "MINC Version    1.0" ;
                image:valid_range = 0., 1346. ;
                image:signtype = "signed__" ;
        double image-min ;
                image-min:varid = "MINC standard variable" ;
                image-min:version = "MINC Version    1.0" ;
                image-min:vartype = "var_attribute" ;
        double image-max ;
                image-max:varid = "MINC standard variable" ;
                image-max:version = "MINC Version    1.0" ;
                image-max:vartype = "var_attribute" ;
        int xspace ;
                xspace:length = 256 ;
                xspace:varid = "MINC standard variable" ;
                xspace:vartype = "dimension____" ;
                xspace:version = "MINC Version    1.0" ;
                xspace:comments = "X increases from patient left to right" ;
                xspace:spacing = "regular__" ;
                xspace:alignment = "centre" ;
                xspace:units = "mm" ;
                xspace:start = 162.602538854934 ;
                xspace:step = -1.00000000606898 ;
                xspace:direction_cosines = 0.0153694198465393,
0.999881857525793, -0.00022786915222191 ;
        int yspace ;
                yspace:length = 256 ;
                yspace:varid = "MINC standard variable" ;
                yspace:vartype = "dimension____" ;
                yspace:version = "MINC Version    1.0" ;
                yspace:comments = "Y increases from patient posterior
to anterior" ;
                yspace:spacing = "regular__" ;
                yspace:alignment = "centre" ;
                yspace:units = "mm" ;
                yspace:start = 66.1629031937321 ;
                yspace:step = -1.00000000035803 ;
                yspace:direction_cosines = -0.0787646993712715,
0.000983522855324584, -0.996892749906301 ;
        int zspace ;
                zspace:length = 176 ;
                zspace:varid = "MINC standard variable" ;
                zspace:vartype = "dimension____" ;
                zspace:version = "MINC Version    1.0" ;
                zspace:comments = "Z increases from patient inferior
to superior" ;
                zspace:spacing = "regular__" ;
                zspace:alignment = "centre" ;
                zspace:units = "mm" ;
                zspace:start = 93.0067360319189 ;
                zspace:step = -0.999999982764245 ;
                zspace:direction_cosines = -0.996774750246724,
0.0153396113625601, 0.0787705122100061 ;
        int acquisition ;
                acquisition:varid = "MINC standard variable" ;
                acquisition:vartype = "group________" ;
                acquisition:version = "MINC Version    1.0" ;
        int patient ;
                patient:varid = "MINC standard variable" ;
                patient:vartype = "group________" ;
                patient:version = "MINC Version    1.0" ;
                patient:full_name = "3T 3D GR\\IR
TR=2420ms/TE=3.7ms/FA=9deg 31-Mar-2011 16:25:15.378" ;
        int study ;
                study:varid = "MINC standard variable" ;
                study:vartype = "group________" ;
                study:version = "MINC Version    1.0" ;


$ fslhd recovered.nii
filename       recovered.nii

sizeof_hdr     348
data_type      FLOAT32
dim0           3
dim1           256
dim2           256
dim3           176
dim4           1
dim5           1
dim6           0
dim7           0
vox_units      mm
time_units     s
datatype       16
nbyper         4
bitpix         32
pixdim0        0.0000000000
pixdim1        1.0000000000
pixdim2        1.0000000000
pixdim3        1.0000000000
pixdim4        0.0000000000
pixdim5        1.0000000000
pixdim6        0.0000000000
pixdim7        0.0000000000
vox_offset     352
cal_max        0.0000
cal_min        0.0000
scl_slope      1.000000
scl_inter      0.000000
phase_dim      0
freq_dim       0
slice_dim      0
slice_name     Unknown
slice_code     0
slice_start    0
slice_end      0
slice_duration 0.000000
time_offset    0.000000
intent         Unknown
intent_code    0
intent_name
intent_p1      0.000000
intent_p2      0.000000
intent_p3      0.000000
qform_name     Unknown
qform_code     0
qto_xyz:1      1.000000  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.000000  0.000000
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      0.015369  -0.078765  -0.996775  95.182411
sto_xyz:2      0.999882  0.000984  0.015340  -93.830009
sto_xyz:3      -0.000228  -0.996893  0.078771  181.812744
sto_xyz:4      0.000000  0.000000  0.000000  1.000000
sform_xorient  Posterior-to-Anterior
sform_yorient  Superior-to-Inferior
sform_zorient  Right-to-Left
file_type      NIFTI-1+
file_code      1
descrip        mnc2nii anonymous.mnc recovered.nii
aux_file


More information about the MINC-users mailing list