Learn R Programming

mritc (version 0.3-2)

readMRI: Read an MR Image into an Array

Description

Read an MR image of different formats into an array.

Usage

readMRI(file, dim, format)

Arguments

file
the name of the image file to be read in.
dim
the dimensions of the image. It is required for the image of type raw.gz, in which dim is a vector of length three specifying dimensions in x, y, and z directions. The default is NULL.
format
the format of the image file. Right now only the "Analyze", "NIfTI", and raw byte (unsigned with 1 byte per element in the byte stream) gzip formats are supported.

Value

  • An array with the appropriate dimensions containing the image volume. For the images of "Analyze" format, the ".hdr" file and its corresponding ".img" file should be in the same directory. For "NIfTI" format, If the extension of the filename is not included, the function searches for the "nii.gz" file, then for the ".nii" file, and finally for the "hdr/img" files in pair.

Details

The files of "Analyze" format are read in through the functions f.read.analyze.volume. The files of "NIfTI" format are read in through an adapted version of read.NIFTI. Besides the original ".nii" files and the "hdr/img" files, it can read the "nii.gz" files as well.

See Also

f.read.analyze.volume, read.NIFTI

Examples

Run this code
vol1 <- readMRI("t1.rawb.gz", c(91,109,91), "rawb.gz")
  
  vol2 <- readMRI("t1.nii.gz", format="nifti")

  vol3  <- readMRI("t1.nii", format="nifti")

  vol4 <- readMRI("t1-nifti.img", format="nifti")

  vol5 <- readMRI("t1-analyze.img", format="analyze")

Run the code above in your browser using DataLab