load.4dfp: Read a 4dfp MRI Image.

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Returns a loaded 4dfp MRI image, either loaded or memory-mapped.

Usage

1
2
3
R4dfp.Load(file,direct.read=FALSE,direct.write=FALSE)
R4dfp.Print(x)
is.4dfp(unknown)

Arguments

file

Path name of the image to load.

direct.read

Flag indicating if the .img should be loaded with ‘mmap’ for reading.

direct.write

Flag indicating if the .img should be loaded with ‘mmap’ for writing. This implies direct.read, also.

x

Object of class ‘R4dfp’.

unknown

An object to check for class ‘R4dfp’ or a string to check for 4dfp file-name format.

Details

The header/image file pair corresponding to the file-name given will be loaded. The object returned should not be copied directly with <- after the initial assignment; use R4dfp.Copy instead!

If direct.read or direct.write are specified, the header information cannot be edited. See R4dfp.Recycle for info about switching to a fully-editable copy. As these options imply, all changes made to the image will be written directly to the file, and all reads will be read from the file as it exists at the time of the read.

Voxel access is via the [...] operator:

  1. To access a single voxel, specify 4 scalars, e.g. myimage[1,1,1,1].

  2. To access the time-series of a single voxel, leave out the time, e.g. myimage[1,1,1].

  3. To access a range of voxels (i.e. a rectangle,) use sequences or vectors for each applicable position, e.g. myimage[1:10,2:5,1] or myimage[c(1,2,4),1,1].

  4. To access a list of specific voxels, use a single Nx4 matrix.

  5. To access the time-series of a list of specific voxels, use a single Nx3 matrix. Optionally, provide a t argument to specify frames.

  6. Use a 3- or 4-D logical matrix to choose specific voxels, e.g. myimage[myimage[,,,]==NaN] <- 0. Optionally, provide a t argument to specify specific frames with a 3-D matrix.

Value

Object of class ‘R4dfp’.

Author(s)

Kevin P. Barry <ta0kira@users.berlios.de> with contributions from Avi Z. Snyder <avi@npg.wustl.edu>

See Also

R4dfp.Save R4dfp.Copy R4dfp.Close R4dfp.Recycle

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
myimage <- R4dfp.Blank333("myimage.4dfp.ifh")
R4dfp.Save(myimage)

#3 different ways to load an image
myimage <- R4dfp.Load("myimage.4dfp.ifh")
myimage <- R4dfp.Load("myimage.4dfp.ifh",direct.read=TRUE)
myimage <- R4dfp.Load("myimage.4dfp.ifh",direct.write=TRUE)

#retrieve a 3x3x3 cube of voxels
myimage[1:3,1:3,1:3,1]

#set a list of voxels to 0 for all frames
voxels <- NULL
voxels <- rbind(voxels,c(1,1,1))
voxels <- rbind(voxels,c(1,1,2))
voxels <- rbind(voxels,c(1,2,1))
voxels <- rbind(voxels,c(1,2,2))
myimage[voxels] <- 0

#set all voxels to something random
myimage[,,,] <- array(rnorm(prod(myimage$dims)),myimage$dims)

#set everything less than 0 to 0
myimage[myimage[,,,]<0] <- 0

Example output

$internal
<pointer: 0x16dc320>

$file
[1] "myimage.4dfp.ifh"

$dims
[1] 48 64 48  1

$scale
[1] 3 3 3 0

$mmppix
[1]  3 -3 -3

$center
[1]  73.5 -87.0 -84.0

attr(,"class")
[1] "R4dfp"
attr(,"direct.read")
[1] FALSE
attr(,"direct.write")
[1] FALSE
, , 1, 1

     [,1] [,2] [,3]
[1,]    0    0    0
[2,]    0    0    0
[3,]    0    0    0

, , 2, 1

     [,1] [,2] [,3]
[1,]    0    0    0
[2,]    0    0    0
[3,]    0    0    0

, , 3, 1

     [,1] [,2] [,3]
[1,]    0    0    0
[2,]    0    0    0
[3,]    0    0    0

R4dfp documentation built on May 1, 2019, 8:41 p.m.

Related to load.4dfp in R4dfp...