## 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