Freesurfers -- 

This morning, I was trying to convert a 4 frame MPRAGE scan into a 1 frame RMS 
image.  I wrote my own matlab code to do it ...

function err = rms_mprage(old,new)
%convert 4-frame mprage into 1 frame mprage by taking RMS of voxels

old_hdr = load_nifti(old);
new_hdr = old_hdr;
new_hdr.vol = 
sqrt((old_hdr.vol(:,:,:,1).^2+old_hdr.vol(:,:,:,2).^2+old_hdr.vol(:,:,:,3).^2+old_hdr.vol(:,:,:,4).^2)/4);
err = save_nifti(new_hdr,new);

So I ran >>> rms_mprage('MPRAGE1.nii','MPRAGE_new.nii')

Also, Bruce said I could do this ...

mri_average -noconform -sqr MPRAGE1.nii#0 MPRAGE1.nii#1 MPRAGE1.nii#2 
MPRAGE1.nii#3 MPRAGE_rms.nii

However...
kerryave:002 $ ls -l
-rw-rw-r-- 1 sburns lingua 92275040 Dec 21 12:27 MPRAGE1.nii
-rw-rw-r-- 1 sburns lingua    24340 Dec 20 15:17 MPRAGE1.nii-infodump.dat
-rw-rw-r-- 1 sburns lingua 23069024 Apr 12 13:29 MPRAGE_new.nii
-rw-rw-r-- 1 sburns lingua 46137696 Apr 12 13:35 MPRAGE_rms.nii

So I was curious why the _rms.nii was twice as big.  Probably a datatype issue, 
right?

kerryave:002 $ mri_info MPRAGE_new.nii 
Volume information for MPRAGE_new.nii
          type: nii
    dimensions: 256 x 256 x 176
   voxel sizes: 1.0000, 1.0000, 1.0000
          type: FLOAT (3)
           fov: 256.000
           dof: 0
        xstart: -128.0, xend: 128.0
        ystart: -128.0, yend: 128.0
        zstart: -88.0, zend: 88.0
            TR: 2530.00 msec, TE: 0.00 msec, TI: 0.00 msec, flip angle: 0.00 
degrees
       nframes: 1
       PhEncDir: UNKNOWN
ras xform present
    xform info: x_r =   0.0055, y_r =   0.0068, z_r =  -1.0000, c_r =    -0.9523
              : x_a =  -0.9719, y_a =   0.2354, z_a =  -0.0037, c_a =     2.8859
              : x_s =  -0.2354, y_s =  -0.9719, z_s =  -0.0079, c_s =     0.8822
Orientation   : PIL
Primary Slice Direction: sagittal

voxel to ras transform:
                0.0055   0.0068  -1.0000    85.4734
               -0.9719   0.2354  -0.0037    97.4806
               -0.2354  -0.9719  -0.0079   156.1061
                0.0000   0.0000   0.0000     1.0000

voxel-to-ras determinant -1

ras to voxel transform:
                0.0055  -0.9719  -0.2354   131.0176
                0.0068   0.2354  -0.9719   128.1845
               -1.0000  -0.0037  -0.0079    87.0654
                0.0000   0.0000   0.0000     1.0000

And...

kerryave:002 $ mri_info MPRAGE_rms.nii
Volume information for MPRAGE_rms.nii
          type: nii
    dimensions: 256 x 256 x 176
   voxel sizes: 1.0000, 1.0000, 1.0000
          type: FLOAT (3)
           fov: 256.000
           dof: 0
        xstart: -128.0, xend: 128.0
        ystart: -128.0, yend: 128.0
        zstart: -88.0, zend: 88.0
            TR: 2530.00 msec, TE: 0.00 msec, TI: 0.00 msec, flip angle: 0.00 
degrees
       nframes: 1
       PhEncDir: UNKNOWN
ras xform present
    xform info: x_r =   0.0055, y_r =   0.0068, z_r =  -1.0000, c_r =    -0.9523
              : x_a =  -0.9719, y_a =   0.2354, z_a =  -0.0037, c_a =     2.8859
              : x_s =  -0.2354, y_s =  -0.9719, z_s =  -0.0079, c_s =     0.8822
Orientation   : PIL
Primary Slice Direction: sagittal

voxel to ras transform:
                0.0055   0.0068  -1.0000    85.4734
               -0.9719   0.2354  -0.0037    97.4806
               -0.2354  -0.9719  -0.0079   156.1061
                0.0000   0.0000   0.0000     1.0000

voxel-to-ras determinant -1

ras to voxel transform:
                0.0055  -0.9719  -0.2354   131.0176
                0.0068   0.2354  -0.9719   128.1845
               -1.0000  -0.0037  -0.0079    87.0654
                0.0000   0.0000   0.0000     1.0000

Weird that mri_info shows the datatype for both images as float. fslhd shows 
different things...

kerryave:002 $ fslhd MPRAGE_new.nii 
filename       MPRAGE_new.nii

sizeof_hdr     348
data_type      INT16
dim0           4
dim1           256
dim2           256
dim3           176
dim4           1
dim5           1
dim6           1
dim7           1
vox_units      mm
time_units     ms
datatype       4
nbyper         2
bitpix         16
pixdim0        0.0000000000
pixdim1        1.0000000000
pixdim2        1.0000000000
pixdim3        1.0000000000
pixdim4        2530.0000000000
pixdim5        1.0000000000
pixdim6        1.0000000000
pixdim7        1.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.000000  0.000000  -1.000000  87.473366
qto_xyz:2      -0.976296  0.216439  -0.000000  100.261627
qto_xyz:3      -0.216439  -0.976296  -0.000000  153.275482
qto_xyz:4      0.000000  0.000000  0.000000  1.000000
qform_xorient  Anterior-to-Posterior
qform_yorient  Superior-to-Inferior
qform_zorient  Right-to-Left
sform_name     Aligned Anat
sform_code     2
sto_xyz:1      0.005469  0.006804  -0.999962  85.473358
sto_xyz:2      -0.971887  0.235419  -0.003714  97.480621
sto_xyz:3      -0.235385  -0.971870  -0.007900  156.106079
sto_xyz:4      0.000000  0.000000  0.000000  1.000000
sform_xorient  Anterior-to-Posterior
sform_yorient  Superior-to-Inferior
sform_zorient  Right-to-Left
file_type      NIFTI-1+
file_code      1
descrip        FreeSurfer Dec 18 2010
aux_file       

kerryave:002 $ fslhd MPRAGE_rms.nii 
filename       MPRAGE_rms.nii

sizeof_hdr     348
data_type      FLOAT32
dim0           3
dim1           256
dim2           256
dim3           176
dim4           1
dim5           1
dim6           1
dim7           1
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        2.5299999714
pixdim5        1.0000000000
pixdim6        1.0000000000
pixdim7        1.0000000000
vox_offset     352
cal_max        0.0000
cal_min        0.0000
scl_slope      0.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.005469  0.006804  -0.999962  85.473358
qto_xyz:2      -0.971887  0.235419  -0.003714  97.480621
qto_xyz:3      -0.235385  -0.971870  -0.007900  156.106079
qto_xyz:4      0.000000  0.000000  0.000000  1.000000
qform_xorient  Anterior-to-Posterior
qform_yorient  Superior-to-Inferior
qform_zorient  Right-to-Left
sform_name     Scanner Anat
sform_code     1
sto_xyz:1      0.005469  0.006804  -0.999962  85.473358
sto_xyz:2      -0.971887  0.235419  -0.003714  97.480621
sto_xyz:3      -0.235385  -0.971870  -0.007900  156.106079
sto_xyz:4      0.000000  0.000000  0.000000  1.000000
sform_xorient  Anterior-to-Posterior
sform_yorient  Superior-to-Inferior
sform_zorient  Right-to-Left
file_type      NIFTI-1+
file_code      1
descrip        FreeSurfer Mar 19 2011
aux_file       


fslhd shows different data types, which explains the difference in size.  I 
think there's a bug in mri_info that is incorrectly reading MPRAGE_new.nii as 
float data.  Not an earth shattering bug by any means, but I thought I'd let 
you know anyways.


Scott Burns
Kuperberg Lab
Martinos Center for Biomedical Imaging
sbu...@nmr.mgh.harvard.edu

The information in this e-mail is intended only for the person to whom it is 
addressed. If you believe this e-mail was sent to you in error and the e-mail 
contains patient information, please contact the Partners Compliance HelpLine 
at http://www.partners.org/complianceline . If the e-mail was sent to you in 
error but does not contain patient information, please contact the sender and 
properly dispose of the e-mail.




_______________________________________________
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.

Reply via email to