readfmridata reads and imports fMRI data from various fMRI image files (Analyze, NIFTI and AFNI) into a 4D array. It is just a convenient wrapper around the data importing functions provided by the oro.nifti package.

readfmridata( directory, format, prefix, nimages, dim.image, 
  nii=TRUE )

Arguments

directory

Location of the directory where the fMRI image files are stored. Insert within quotations ("").

format

The format of the data file. One of "Analyze" (.img/.hdr files), "Nifti" (.img/.hdr files or .nii files) or "Afni" (.HEAD/.BRIK files).

prefix

If format is "Analyze" or "Nifti", then the part of the fMRI image file name appearing before the image number. The image number is assumed to have four digit representation, that is, the lowest number is 0001 and the highest possible number is 9999. If format is "Afni", then the file name. Insert within quotations("").

nimages

If format is "Analyze", number of images to be read beginning from the first image. If format is "Afni", not necessary.

dim.image

Size of the 3D fMRI image. A vector with three elements.

nii

Necessary only for "Nifti" format. nii=TRUE (default) indicates the image files are in .nii files . nii=FALSE indicates the image files are .img/.hdr files.

Value

A list containing the following:

fmridata

An array of dimension (dim.image, nimages), containing the image data for all images/time-points.

Details

The function uses package oro.nifti for reading from fMRI data files.

Author

Nilotpal Sanyal, Marco Ferreira Maintainer: Nilotpal Sanyal <nilotpal.sanyal@gmail.com>

Examples

# import simmulated fMRI data from image files provided within this package
fpath <- system.file("extdata", package="BHMSMAfMRI")
untar(paste0(fpath,"/fmridata.tar"), exdir=tempdir())
data <- array(dim=c(3,32,32,9))
for(subject in 1:3)
{
  directory <- paste0(tempdir(),"/fmridata","/s0",subject,"/")
  a <- readfmridata(directory, format="Analyze", prefix=paste0("s0",subject,"_t"),
  nimages=9, dim.image=c(32,32,1))
  data[subject,,,] <- a[,,1,]
}
dim(a)
#> [1] 32 32  1  9