R Package - AnalyzeReadR v0.1.2 02/02/2001

INTRODUCTION

This page explains how to install the R package AnalyzeReadR v0.1.2. I assume that you have a basic knowledge of UNIX/LINUX and that you already have R installed on your machine.

AnalyzeReadR contains functions that allow ANALYZE image format .img and .hdr files to be read into R automatically

I created this package for two reasons.

(1) These functions provide an interface between R and ANALYZE files. Many fMRI datasets are stored in this format and R provides a very flexible platform upon which to explore and analyze these datasets. I hope this may be useful to other Statisticians/Researchers.

(2) I wanted to practise how to create a R package! To do this i used the book `S Programming' by Venables and Ripley and the on-line R documentation available at http://www.ci.tuwien.ac.at/R/

There is GUI which can be run from R that is based on this package called AnalyeReadRGUI

If you have any problems/suggestions using this package, please email me on marchini@stats.ox.ac.uk

INSTALLATION

1. Download the g-zipped tar archive  AnalyzeReadR_0.1.2.tar.gz

2. Unzip the file using gunzip AnalyzeReadR_0.1.2.tar.gz

3. Unpack the archive using   tar -xvf AnalyzeReadR_0.1.2.tar

This will create a directory called AnalyzeReadR and the files example.img and example.hdr (see EXAMPLES)

4.  Install the package using     R CMD INSTALL -l /path/to/LIB AnalyzeReadR

/path/to/LIB should be the library directory where you wish to put the package.

If you have root access to your machine then use      R CMD INSTALL AnalyzeReadR

and the package will be put into the default R library tree.

5. You can then start an R session and load the package using

 library(AnalyzeReadR,lib.loc="/path/to/LIB")

or     library(AnalyzeReadR) (if you installed the package into the default R library tree)

6. Use the EXAMPLES section to see how the functions work.

FUNCTIONS

The package contains the following functions

f.read.analyze.header - reads a .hdr file and returns it as a list
f.read.analyze.volume - reads in a .img file into an array
f.analyze.file.summary - summarises the contents of a .img file
f.read.analyze.ts - reads in a specified time series from a .img file
f.analyze.file.summary - summarises the contents of a .img file

The functions come with help files

EXAMPLES

During the installation the two file example.img and example.hdr will have been unpacked. These are required for the following examples.

The file example.img is a 4D fMRI dataset. There are 21 axial slices each consisting of a 64x64 grid of 4mmx4mmx6mm voxels. There is only
one time point.

For the purpose of this example I assume you have put them in the same directory in which you started an R session.

1.  Load the package AnalyzeReadR  (as described above).

3. Get a summary of the data stored in the .img file using

 >f.analyze.file.summary("./example.img")
[1]
[1]        File name: ./example.img
[1]   Data Dimension: 4-D
[1]      X dimension: 64
[1]      Y dimension: 64
[1]      Z dimension: 21
[1]   Time dimension: 1 time points
[1] Voxel dimensions: 4mmx4mmx6mm
[1]        Data type: signed short (16 bits per voxel)
 

4. Read in the data from the .img file into an array using

 >A<-f.read.analyze.volume("./example.img")

5. Check the dimensions of the array

 >dim(A)
[1] 64 64 21  1

6. Print out a slice of the dataset using

 >image(A[,,10,1])

7. Read in a specific slice

 >B<-f.read.analyze.slice("./example.img",slice=5,tpt=1)

and plot it using

 >image(B)

8. Read in a time series from a given location

 >f.read.analyze.ts("./example.img",x=30,y=30,z=10)

NB. Because example.img consists of only one time point this will only return one value
 

PROBLEMS/SUGGESTIONS

If you have any problems/suggestions using this package, please email me on marchini@stats.ox.ac.uk