Differences between revisions 6 and 7
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
## Note: This page was created with the CommandTemplate
##
## If you're modifying this page please take a look at the
## latest version of CommandTemplate to ensure that you're
## using the latest version of the CommandTemplate
##
Line 2: Line 8:
##
## Note: If you are modifying this page please refer to the
## CommandTemplate page and confirm that this page has the latest
## CommandTemplate formatting
Line 8: Line 10:
mri_convert - general purpose utility for file format conversion and volume resampling mri_convert - converts MRI data format/file type
Line 11: Line 13:
mri_convert [argA] -flag1 [arg2] -flag2 [arg3] [<options>]

= Positional Arguments =
|| [argA] || description ||

= Required Flagged Arguments =
|| -flag1 [arg1] || description ||
|| -flag2 [arg2] || description ||

= Optional Flagged Arguments =
|| -flag3 [arg3] || description ||
|| -flag4 [arg4] || description ||
mri_convert [options] <in volume> <out volume>

= Arguments =
== Positional Arguments ==
|| in volume || your input file name

== Required Flagged Arguments ==
None.
The file type can be specified in two ways. First, mri_convert will try
to figure it out on its own from the format of the file name (eg, files thatend in .img are assumed to be in spm analyze format). Second, the user canexplicity set the type of file using --in_type and/or --out_type.
Legal values for --in_type (-it) and --out_type (-ot) are:
 
  cor - MGH-NMR COR format

  minc - MNI's Medical Imaging NetCDF format (output may not work) analyze - 3D analyze (same as spm)

  analyze4d - 4D analyze

  spm - SPM Analyze format (same as analyze and analyze3d) ge - GE Genesis format (input only)

  gelx - GE LX (input only)

  lx - same as gelx

  ximg - GE XIMG variant (input only)

  siemens - Siemens IMA (input only)

  dicom - generic DICOM Format (input only)

  siemens_dicom - Siemens DICOM Format (input only)

  afni - AFNI format

  brik - same as afni

  bshort - MGH-NMR bshort format

  bfloat - MGH-NMR bfloat format

  sdt - Varian (?)

  outline - MGH-NMR Outline format

  otl - same as outline

  gdf - GDF volume (requires image stem for output; use -gis)
 

== Optional Flagged Arguments ==

Options are

  -ro, --read_only

  -nw, --no_write
 
  -ii, --in_info

  -oi, --out_info

  -is, --in_stats

  -os, --out_stats

  -im, --in_matrix

  -om, --out_matrix
 
  -iis, --in_i_size <size>

  -ijs, --in_j_size <size>

  -iks, --in_k_size <size>

  --force_ras_good : use default when orientation info absent
 
  -iid, --in_i_direction <R direction> <A direction> <S direction> -ijd, --in_j_direction <R direction> <A direction> <S direction> -ikd, --in_k_direction <R direction> <A direction> <S direction>

  -ic, --in_center <R coordinate> <A coordinate> <S coordinate>

  -oni, -oic, --out_i_count <count>

  -onj, -ojc, --out_j_count <count>

  -onk, -okc, --out_k_count <count>
 
  -ois, --out_i_size <size>

  -ojs, --out_j_size <size>

  -oks, --out_k_size <size>

 --nskip n : skip the first n frames
 
  -oid, --out_i_direction <R direction> <A direction> <S direction> -ojd, --out_j_direction <R direction> <A direction> <S direction> -okd, --out_k_direction <R direction> <A direction> <S direction>

  -oc, --out_center <R coordinate> <A coordinate> <S coordinate>

  -odt, --out_data_type <uchar|short|int|float>

  -rt, --resample_type <interpolate|weighted|nearest|sinc|cubic> (default is interpolate)
 
  --no_scale flag <-ns>: 1 = dont rescale values for COR
 
  -nc --nochange - don't change type of input to that of template
 
  -tr TR : TR in seconds
 
  --unwarp_gradient_nonlinearity
      <sonata | allegra | GE>
      <fullUnwarp | through-plane>
      <JacobianCorrection | noJacobianCorrection>
      <linear | sinc>
      <sincInterpHW>
 
Line 25: Line 131:
|| volume1 || description ||
|| volume2 || description ||
|| out volume || desired output filename.format ||
Line 29: Line 134:
description

= Example 1 =
mri_convert foo -i f -o out

description

= Example 2 =
mri_convert foo -i f -o out -f fvalue

description


= Examples =
== Example 1 ==
APPLYING TRANSFORMS (INCLUDING TALAIRACH)
 
  --apply_transform xfmfile (-T or -at)
  
  --apply_inverse_transform xfmfile (-ait)
  
  --devolvexfm subjectid :
  
  --like vol: output is embedded in a volume like vol
 
 The volume can be resampled into another space by supplying a transform using the --apply_transform flag. This reads the transform file and applies the transform (when --apply_inverse_transform is used, the transform is inverted and then applied). An example of a transform file is talairach.xfm as found in subjectid/mri/transforms. To convert a subject's orig volume to talairach space, execute the following lines:
 
  cd subjectid/mri
  
  mkdir talairach
  
  mri_convert --apply_transform transforms/talariach.xfm
     --devolvexfm subjectid --ic 0 0 0
     orig talairach
 
 This properly accounts for the case where the input volume does not have it's coordinate center at 0.
 
 To evaluate the result, run:
 
    tkmedit -f $SUBJECTS_DIR/talairach/mri/orig -aux talairach
 
 The main and aux volumes should overlap very closely. If they do not,
 use tkregister2 to fix it (run tkregister --help for docs).
 
== Example 2 ==
CONVERTING TO SPM-ANALYZE FORMAT
 
Converting to SPM-Analyze format can be done in two ways, depeding uponwhether a single frame or multiple frames are desired. For a single frame,simply specify the output file name with a .img extension, and mri_convert
will save the first frame into the file. For multiple frames, specify the
base as the output file name and add --out_type spm. This will save each
frame as baseXXX.img where XXX is the three-digit, zero-padded frame number.
Frame numbers begin at one. By default, the width the of zero padding is 3.This can be controlled with --in_nspmzeropad N where N is the new width.

= Bugs =
None

= Other Available Options =
-r, --reorder olddim1 olddim2 olddim3
 
  Reorders axes such that olddim1 is the new column dimension,
  olddim2 is the new row dimension, olddim3 is the new slice
  dimension. Example: 2 1 3 will swap rows and cols.
 
  --invert_contrast threshold
 
  All voxels in volume greater than threshold are replaced
  with 255-value. Only makes sense for 8 bit images.
  Only operates on the first frame.
 

  -i, --input_volume

  -o, --output_volume

  -c, --conform
            conform to 1mm voxel size in coronal slice direction with 256^3 or more

  -cm, --conform_min
            conform to the src min direction size

  -cs, --conform_size size_in_mm
            conform to the size given in mm

  -po, --parse_only

  -is, --in_stats

  -os, --out_stats

  -ro, --read_only

  -nw, --no_write

  -sn, --subject_name

  -rl, --reslice_like

  -tt, --template_type <type> (see above)

  -f, --frame

  -sc, --scale <scale factor>

  -il, --in_like

  -roi

  -fp, --fill_parcellation

  -sp, --smooth_parcellation

  -zo, --zero_outlines

  -cf, --color_file

  -nt, --no_translate

  --status (status file for DICOM conversion)

  --sdcmlist (list of DICOM files for conversion)

  -ti, --template_info : dump info about template

  -gis <gdf image file stem>

  -zgez, --zero_ge_z_offset

            set c_s=0 (appropriate for dicom files from GE machines with isocenter scanning)
 
Notes:
 
If the user specifies any of the direction cosines, the ras_good_flag is set.
Line 42: Line 258:
["othercommand1"], ["othercommand2"]
Line 45: Line 261:
FreeSurfer FreeSurfer, FsFast
Line 54: Line 270:
None
Line 60: Line 276:
BruceFischl CherifSahyoun

Name

mri_convert - converts MRI data format/file type

Synopsis

mri_convert [options] <in volume> <out volume>

Arguments

Positional Arguments

|| in volume || your input file name

Required Flagged Arguments

None. The file type can be specified in two ways. First, mri_convert will try to figure it out on its own from the format of the file name (eg, files thatend in .img are assumed to be in spm analyze format). Second, the user canexplicity set the type of file using --in_type and/or --out_type. Legal values for --in_type (-it) and --out_type (-ot) are:

  • cor - MGH-NMR COR format minc - MNI's Medical Imaging NetCDF format (output may not work) analyze - 3D analyze (same as spm) analyze4d - 4D analyze spm - SPM Analyze format (same as analyze and analyze3d) ge - GE Genesis format (input only) gelx - GE LX (input only) lx - same as gelx ximg - GE XIMG variant (input only) siemens - Siemens IMA (input only) dicom - generic DICOM Format (input only) siemens_dicom - Siemens DICOM Format (input only) afni - AFNI format brik - same as afni bshort - MGH-NMR bshort format bfloat - MGH-NMR bfloat format sdt - Varian (?) outline - MGH-NMR Outline format otl - same as outline gdf - GDF volume (requires image stem for output; use -gis)

Optional Flagged Arguments

Options are

  • -ro, --read_only -nw, --no_write -ii, --in_info -oi, --out_info -is, --in_stats -os, --out_stats -im, --in_matrix -om, --out_matrix

    -iis, --in_i_size <size>

    -ijs, --in_j_size <size>

    -iks, --in_k_size <size> --force_ras_good : use default when orientation info absent

    -iid, --in_i_direction <R direction> <A direction> <S direction> -ijd, --in_j_direction <R direction> <A direction> <S direction> -ikd, --in_k_direction <R direction> <A direction> <S direction>

    -ic, --in_center <R coordinate> <A coordinate> <S coordinate>

    -oni, -oic, --out_i_count <count>

    -onj, -ojc, --out_j_count <count>

    -onk, -okc, --out_k_count <count>

    -ois, --out_i_size <size>

    -ojs, --out_j_size <size>

    -oks, --out_k_size <size>

  • --nskip n : skip the first n frames
    • -oid, --out_i_direction <R direction> <A direction> <S direction> -ojd, --out_j_direction <R direction> <A direction> <S direction> -okd, --out_k_direction <R direction> <A direction> <S direction>

      -oc, --out_center <R coordinate> <A coordinate> <S coordinate>

      -odt, --out_data_type <uchar|short|int|float>

      -rt, --resample_type <interpolate|weighted|nearest|sinc|cubic> (default is interpolate)

      --no_scale flag <-ns>: 1 = dont rescale values for COR -nc --nochange - don't change type of input to that of template -tr TR : TR in seconds --unwarp_gradient_nonlinearity

      • <sonata | allegra | GE> <fullUnwarp | through-plane> <JacobianCorrection | noJacobianCorrection> <linear | sinc> <sincInterpHW>

Outputs

out volume

desired output filename.format

Description

Examples

Example 1

APPLYING TRANSFORMS (INCLUDING TALAIRACH)

  • --apply_transform xfmfile (-T or -at) --apply_inverse_transform xfmfile (-ait) --devolvexfm subjectid : --like vol: output is embedded in a volume like vol
  • The volume can be resampled into another space by supplying a transform using the --apply_transform flag. This reads the transform file and applies the transform (when --apply_inverse_transform is used, the transform is inverted and then applied). An example of a transform file is talairach.xfm as found in subjectid/mri/transforms. To convert a subject's orig volume to talairach space, execute the following lines:
    • cd subjectid/mri mkdir talairach mri_convert --apply_transform transforms/talariach.xfm
      • --devolvexfm subjectid --ic 0 0 0 orig talairach
    This properly accounts for the case where the input volume does not have it's coordinate center at 0. To evaluate the result, run:
    • tkmedit -f $SUBJECTS_DIR/talairach/mri/orig -aux talairach
    The main and aux volumes should overlap very closely. If they do not, use tkregister2 to fix it (run tkregister --help for docs).

Example 2

CONVERTING TO SPM-ANALYZE FORMAT

Converting to SPM-Analyze format can be done in two ways, depeding uponwhether a single frame or multiple frames are desired. For a single frame,simply specify the output file name with a .img extension, and mri_convert will save the first frame into the file. For multiple frames, specify the base as the output file name and add --out_type spm. This will save each frame as baseXXX.img where XXX is the three-digit, zero-padded frame number. Frame numbers begin at one. By default, the width the of zero padding is 3.This can be controlled with --in_nspmzeropad N where N is the new width.

Bugs

None

Other Available Options

-r, --reorder olddim1 olddim2 olddim3

  • Reorders axes such that olddim1 is the new column dimension, olddim2 is the new row dimension, olddim3 is the new slice dimension. Example: 2 1 3 will swap rows and cols. --invert_contrast threshold All voxels in volume greater than threshold are replaced with 255-value. Only makes sense for 8 bit images. Only operates on the first frame. -i, --input_volume -o, --output_volume -c, --conform
    • conform to 1mm voxel size in coronal slice direction with 256^3 or more
    -cm, --conform_min
    • conform to the src min direction size
    -cs, --conform_size size_in_mm
    • conform to the size given in mm
    -po, --parse_only -is, --in_stats -os, --out_stats -ro, --read_only -nw, --no_write -sn, --subject_name -rl, --reslice_like

    -tt, --template_type <type> (see above) -f, --frame

    -sc, --scale <scale factor> -il, --in_like -roi -fp, --fill_parcellation -sp, --smooth_parcellation -zo, --zero_outlines -cf, --color_file -nt, --no_translate --status (status file for DICOM conversion) --sdcmlist (list of DICOM files for conversion) -ti, --template_info : dump info about template

    -gis <gdf image file stem> -zgez, --zero_ge_z_offset

    • set c_s=0 (appropriate for dicom files from GE machines with isocenter scanning)

Notes:

If the user specifies any of the direction cosines, the ras_good_flag is set.

See Also

Links

FreeSurfer, FsFast

Methods Description

description
description

References

Reporting Bugs

Report bugs to <analysis-bugs@nmr.mgh.harvard.edu>

Author/s

CherifSahyoun

mri_convert (last edited 2017-11-29 12:05:15 by MorganFogarty)