Analysing fMRI experiments with the fmri package in R. Version 1.0 - A users guide.

This document describes the usage of the R package fmri to analyse functional Magnetic Resonance Imaging (fMRI) data with structure adaptive smoothing procedures (PropagationSeparation (PS) approach) as described in [7]. 1 Analysing fMRI data with the fmri package Functional Magnetic Resonance Imaging (fMRI) is a non-invasive tool for studying the functionality of the brain and localizing cognitive functions. It has become increasingly important in neurosciences as well as for clinical applications such as presurgical planning. In a typical fMRI experiment with block design the patient has to perform one or several tasks alternated by some period of rest. However, activation in brain is not subject to direct measurement. fMRI-experiments therefore detect a change in blood oxygenation (BOLD response) [3, 4] instead. A higher oxygenation level is associated with increased neuronal activity necessary to solve the task. The fmri package was build to provide an easy-to-use interface for the analysis of fMRI data. The approach is based on a linear model for the hemodynamic response according to the Blood Oxygen Level Dependent (BOLD) effect and structural adaptive spatial smoothing of the resulting Statistical Parametric Map (SPM). The package requires R (version ≥ 2.2) [6] (binaries available for Linux and Windows) to be installed. 3D visualization needs the R-package tkrplot. Sections marked with a ? are not required in order to understand how to write an R-script based on the package and can thus be dropped at first reading. However, they contain information on the implementation of the algorithm if this is not straightforward. The statistical modelling implemented with this software is described in [7]. NOTE! This software comes with absolutely no warranty! It is not intended for clinical use, but for research purposes only. Absence of bugs can not be guaranteed! We first start with a basic script for using the fmri package in a typical fmri analysis. In the following sections of this manual we describe the consecutive steps of the analysis. This is accompanied by a complete documentation of the user-level functions of the package (also available through R’s help system). # load the package library(fmri) # read the data data <read.AFNI("afnifile") # or read sequence of ANALYZE files # analyze031file.hdr . analyze137file.hdr # data <read.ANALYZE("analyze", numbered=TRUE, "file", 31, 107) 2 # create expected BOLD signal and design matrix hrf <fmri.stimulus(107, c(18, 48, 78), 15, 2) x <fmri.design(hrf) # generate parametric map from linear model spm <fmri.lm(data, x) # structure adaptive smoothing with maximum bandwith hmax spmsmooth <fmri.smooth(spm, hmax=hmax) # calculate p-values for smoothed parametric map pvalue <fmri.pvalue(spmsmooth) # plot result slicewise into file or . plot(pvalue, maxpvalue=0.01, device="jpeg", file="result.jpeg") # . plot interactive 3D visualization plot(pvalue, maxpvalue=0.01, type="3d") 2 Reading the data The fmri package can read AFNI-HEAD/BRIK [2] and ANALYZE [1] files. Use data <read.AFNI(<filename>) data <read.ANALYZE(<filename>) to simply read the data in the file <filename> into the object data. Drop the extension in <filename>. While AFNI data is generally given as a four dimensional datacube in one file, ANALYZE format data often comes in a series of numbered files. The syntax to read them is as follows: data <read.ANALYZE(prefix = "", numbered = TRUE, postfix = "", picstart = 1, numbpic = 1) Setting the numbered argument to TRUE starts reading a list of files. prefix contains the string before the number, whereas postfix contains the string after the number in the filename. picstart is the number of the first file, and numbpic the number of files to be read. Note, that read.ANALYZE() requires the file names in the form: <prefix>007<postfix>. hdr/img It may well be that your scanner does not match this convention. If so, you have the possibility to combine the files into a four dimensional data cube with some third-party software first or ask 3 the authors of this package to include more conventions into the package. Both functions return lists of class ”fmridata” with list elements corresponding to the datacube (’ttt’), basic information on the data (’dim’, ’delta’ etc.), as well as the complete header information (’header’), which is itself a list with elements corresponding to the data format read. A head mask is defined by simply considering a 75% quantile of the data grey levels as cut-off. This will only be used to provide improved spatial correlation estimates for the head in fmri.lm(). read.AFNI I/O function Description Read HEAD/BRIK file. Usage read.AFNI(file) Arguments file name of the file (without extension) Details The function reads a HEAD/BRIK file. Value Object of class ”fmridata” with the following list entries: ttt 4 dimensional datacube, the first three dimensions are voxel dimensions, the fourth dimension denotes the time header header information list format data source. string ”HEAD/BRIK” delta voxel size in mm origin position of the datacube origin orient data orientation code. see AFNI documentation dim dimension of the datacube weights weights vector coding the relative voxel sizes in x, y, z-direction. mask head mask 4 Author(s) Karsten Tabelow tabelow@wias-berlin.de References R. W. Cox (1996). AFNI: Software for analysis and visualization of functional magnetic resonance neuroimages. Computers and Biomed. Res. 29:162-173. See Also write.AFNI, read.ANALYZE