convert_file

Purpose:

Convert Analyze, Voxbo, Dicom and interfile files to Analyze, Voxbo, Interfile and AFNI file formats.

Usage:

convert_file [hvltLT -f<frame(s)_code> -s <#_to_skip> -M<master>] <input> <output> <format>

Supported input formats:

  • Dicom
  • ana: Analyze.
  • brik: afni format.
  • ni1: Two-file nifti format. This file is compatible with the Analyze format, i.e., it creates files with extensions ".hdr" and ".img" and can be read by programs that require the analyze format.
  • nii: One-file nifti format

Output formats (the "output_format) parameter:

  • brik: AFNI brik
  • ana: Analyze
  • ni1: Two-file nifti
  • nii: One-file nifti

Options:

  • -l: Flip images left-to-right in physical coordinates, i.e., flip fast changing dimension. Do not change spatial orientation info in header
  • -t: Flip images top-to-bottom. Do not change spatial orientation info in the header.
  • -L: Flip the image left-to-right and also change the spatial orientation info in header.
  • -T: Flip the image top-to-bottom and also change the spatial orientation info in the header.
  • -v: Print extra stuff to the screen.
  • -M Master containing target valid coordinate system data. This is useful if images have been converted to Analyze format for processing and are to be converted back to a format such as AFNI that requires knowledge of the coordinate system. The master can be in AFNI, NIFTI, P-file, dicom, or I-file format.
  • -f FRAME, --frame=FRAME Specifies that the single specified. This option takes two forms. If -f "i-j" is entered, frames i to j will be converted. If "-f i" is entered, only frame "i" will be converted. Frames are numbered starting at zero.frame be converted
  • -s SKIP, --skip=SKIP Number of frames to skip.

Examples:

Convert dicom images in the directory S2_EFGRE3D to an AFNI brik convert_file S2_EFGRE3D T1High brik

Convert dicom images in S4_EPI2 to a nifti and skip the first 4 frames. convert_file -s4 S4_EPI2 s4_epi nii

Convert frames 10 to 20 of dicom images in S4_EPI2 to a nifti file frames. convert_file -f10-20 S4_EPI2 s4_epi nii

Convert dicom images in S4_EPI2 to a nifti file with all frames. convert_file S4_EPI2 s4_epi nii

Convert dicom images in S4_EPI2 to a nifti file containing only frame 3. convert_file -f3 S4_EPI2 s4_epi nii

Flip the image physically from left-to-right, but header info is unaffected. convert_file -l image.nii image_lr.nii nii

Flip the image physically from left-to-right, and also change header. convert_file -l image.nii image_lr.nii nii
This is useful for programs such as fslview that ignore the orientation information in the header.

Notes:

  • -lt, These options flip the physical storage order rather than the transformation matrix. These options are useful when converting images that have been stored incorrectly, as often occurs with images stored with an analyze header but not in the correct orientation.
  • -LT: These options flip the image physically as well as change the information in the header. These should be used when trying to flip into an orientation that will work with non-compliant software while retaining consistency between the header and the data.
  • AFNI  files are written by to3d if the input it analyze format. Nifti and afni input files are written to afni by spawning 3dcopy.
  • Some packages require that the images be physically stored in LPI coordinates, i.e., the same as Analyze images. Images in RAI format can be flipped by using the -LT options. This will flip the images physically while flipping the orientation represented in the header as well.

To recap the -ltLT options: The lower case options (-lt) are used when the image coordinates in the header are incorrect (say analyze format images stored in rai coordinates - this happens with some older software). These options will flip the image into agreement with the info in the header, if chosen correctly. The upper case options (-LT) flip both the coordinate system descriptor and the image. This is useful if you have correct coordinate descriptors but the image has to physically be in a specific coordinate system. I added this for fsl. Our axial images are usually stored in RAI coordinates, but fsl wants them physically stored in LPI coordinates. Using the -LT option flips the image into the coordinate system that fsl wants but also flips the coordinate system descriptors to maintain compatibility with other software.

Last modified February 24, 2011