iData-methods: iData Methods

Description Usage Arguments Details Author(s) Examples

Description

An object that associates demographic and imaging data in such a way that facilitates more convenient manipulation.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## S4 method for signature 'iData'
names(x)

## S4 replacement method for signature 'iData'
names(x) <- value

add(x, iGroup, bool)

substract(x, groups)

getDemog(x, groups, vars)

getGroups(x, groups)

## S4 method for signature 'iData,ANY,ANY'
x[i]

iDataRead(dirname, verbose = TRUE)

iDataWrite(x, dirname, verbose = TRUE)

select(x, groups, vars, na.action = NULL)

isplit(x, nsplit)

Arguments

x, object

Object of class iData.

value

Character vector to replace current iGroup names.

bool

A vector of TRUE/FALSE values with length equal to the number of rows in the demographics data frame and number of TRUE values equal to the number of rows in the image matrix.

groups

Name of iGroup object(s).

vars

Name of varaible(s) from demographics slot.

i

Vector of numeric values representing images to subset in iData.

dirname

Directory to write iData object to.

verbose

Enables verbose output. (default = TRUE).

na.action

If "na.omit" then all images with NA values in corresponding variables are omitted. If a function is specified

nsplit

If greater than one, number of folds to split data into. Otherwise, proportion of rows in training data.

Details

names Retrieve names of iGroups in iList slot.

names<- Replace names of iGroups within iList slot.

add Add iGroup to iList slot.

subtract Subtract iGroup objects with provided names from iList.

getDemog Get variables indexed according to iGroup. indicated by groups

getGroups Retrieve list of iGroups.

iData[i] Subset iData objects.

iDataRead Loads previously saved iData from its set directory.

iDataWrite Write/save iData object to its own directory.

select Select only data that applies to the iGroups and variables included in the arguments.

isplit Splits iData into two groups with specified ratios if nsplit < 1 or into n folds if nsplit > 1.

Author(s)

Zachary P. Christensen

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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# create iGroup object
ilist <- getANTsRData("population")
mask <- getMask(ilist[[1]])
imat <- imageListToMatrix(ilist, mask)
iGroup1 <- iGroup(imat, "pop1", mask, modality = "T1")

# ensure only active voxels are included in mask


ilist <- lappend(ilist, ilist[[1]])
imat <- imageListToMatrix(ilist, mask)
iGroup2 <- iGroup(imat, "pop2", mask, modality = "T1")

# save iGroup object
tmpfile <- tempfile(fileext = ".h5")
iGroupWrite(iGroup1, tmpfile)

# load saved iGroup object
(iGroup1_reload <- iGroupRead(tmpfile))

demog <- data.frame(id = c("A", "B", "C", NA),
  age = c(11, 7, 18, 22), sex = c("M", "M", "F", "F"))
  
bool1 <- c(TRUE, TRUE, TRUE, FALSE)
bool2 <- c(TRUE, TRUE, TRUE, TRUE)

# create iData object that holds demographics info
mydata <- iData(iGroup1, bool1, demog)

# add iGroup object to iData
mydata <- add(mydata, iGroup2, bool1)

# save iData object
tmpdir <- "iData_test"
iDataWrite(mydata, tmpdir)

# load saved iData object
(mydata_reload <- iDataRead(tmpdir))

# split iData object into k-folds or train and test groups
mydatasplit <- iDataSplit(mydata, 0.3)

# retreive demographic information specific to an iGroup
getDemog(mydata, "pop1", c("age", "sex"))

# omit all values that are NA while selecting for specific groups and variables
(mydata_omitted <- select(mydata, groups = "id", vars = "id", na.omit = TRUE))

Tokazama/iClass documentation built on Aug. 18, 2017, 1:12 a.m.