Learn R Programming

MRIaggr (version 1.1.5)

allocContrast: Allocate new contrast parameters

Description

Allocate one or several contrast parameters to a MRIaggr object.

Usage

"allocContrast"(object, param = NULL, default_value = NULL, overwrite = FALSE, verbose = optionsMRIaggr("verbose")) <- value

Arguments

object
an object of class MRIaggr. REQUIRED.
value
the value of each contrast parameter (in columns) at each voxel (in rows). data.frame. REQUIRED.
param
the names of the contrast parameters. character vector or NULL leading to use the name of the value argument.
default_value
the reference values of the contrast parameters (e.g background values). A one row data.frame where the column length must match the length of the param argument.
overwrite
if a contrast parameters with the same names are already stored in object@data, can they be overwritten ? logical.
verbose
should the execution of the function be traced ? logical.

Value

None.

Details

FUNCTION: If the param argument is not specified then the names of the value argument will be used to define the parameter names.

If the default_value argument is NULL then default values "undefined" are attributed to each parameter.

If a parameter named "mask" is intended to be allocated it must be done alone and it must be of type logical.

Parameter names "index", "i", "j" and "k" are reserved and cannot be modified. Nevertheless if value contains parameters "i", "j" and "k", the correspondance between these coordinates and the object coordinates is tested.

See Also

calcContralateral, calcRegionalContrast, calcFilter and calcTissueType to compute, modify and allocate cartography. selectContrast to select contrast parameters in the MRIaggr object.

Examples

Run this code
## load NIFTI files and convert them to MRIaggr
path.Pat1 <- system.file(file.path("nifti"), package = "MRIaggr")
ls.array <- list()
ls.array[[1]] <- readMRI(file.path(path.Pat1, "DWI_t0"),format = "nifti")
ls.array[[2]] <- readMRI(file.path(path.Pat1, "MASK_DWI_t0"),format = "nifti")
MRIaggr.Pat1 <- constMRIaggr(ls.array, identifier = "Pat1", param = c("DWI_t0", "MASK_DWI_t0"))

## allocate a new contrast parameters
allocContrast(MRIaggr.Pat1, param = "noise", overwrite = TRUE) <- rnorm(selectN(MRIaggr.Pat1))

## perform operations on a contrast parameters and store the results
myCarto <- selectContrast(MRIaggr.Pat1 , param = "DWI_t0")
myCarto <- myCarto * 2 + 1
allocContrast(MRIaggr.Pat1, param = "myCarto", overwrite = TRUE) <- myCarto

## import a contrast parameters in an already existing MRIaggr object
nifti.MTT_t0 <- readMRI(file.path(path.Pat1, "MTT_t0"), format = "nifti")
df.MTT_t0 <- array2df(nifti.MTT_t0, name_newparam = "MTT_t0")$MTT_t0
allocContrast(MRIaggr.Pat1, param = "MTT_t0", overwrite = TRUE) <- df.MTT_t0

## some calc methods automatically save results in the @data slot
calcFilter(MRIaggr.Pat1, param = "MTT_t0", filter = "2D_G3",
           update.object = TRUE, overwrite = TRUE)
res <- selectContrast(MRIaggr.Pat1, param = "MTT_t0_2D_G3")

Run the code above in your browser using DataLab