InputOutput-array2dt: Array to data.frame converter

Description Usage Arguments Details Value Examples

Description

Convert observations stored in the array format into the data.frame format.

Usage

1
2
array2dt(array, coords = NULL, name_newparam = "res",
         names_coords = letters[9:(8+ncol(coords))], na.rm = TRUE)

Arguments

array

the array that should be converted into a data.frame. array or matrix. REQUIRED.

coords

the spatial coordinates of the observations contained in array. matrix or NULL.

name_newparam

the name of the contrast parameter to which cooresponds array. character.

names_coords

the name of the coordinates. character vector.

na.rm

should observations with missing values be removed ? logical.

Details

ARGUMENTS :
If coords is set to NULL, the coordinates will be defined by the position of the observations in array.
If na.rm is set to TRUE, the coord argument will only contains the coordinates of the non-NA observations of array.

Value

A dataframe with in columns the coordinates and the parameter values, and in rows the observations.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
 
## load a NIFTI file (array format)
path.Pat1 <- system.file(file.path("nifti"), package = "MRIaggr")
nifti.Pat1_TTP_t0 <- readMRI(file.path(path.Pat1, "TTP_t0"), format = "nifti")
dim(nifti.Pat1_TTP_t0)

## conversion to data frame format
res128 <- array2dt(array = nifti.Pat1_TTP_t0, name_newparam = "TTP_t0")
dim(res128)
head(res128)

## conversion to data frame format with specific coordinates
res256 <- array2dt(array = nifti.Pat1_TTP_t0, name_newparam = "TTP_t0",
                   coords = expand.grid(129:206, 129:228, 1:3, 1))
dim(res256)
head(res256)

bozenne/MRIaggr documentation built on May 13, 2019, 1:39 a.m.