Last data update: 2014.03.03

R: Reduce a MRIaggr
constReduceMRIaggrR Documentation

Reduce a MRIaggr

Description

Construct a MRIaggr object restricted to a subset of observations.

Usage

## S4 method for signature 'MRIaggr'
constReduceMRIaggr(object, mask, numeric2logical = FALSE, keep.index = TRUE)

Arguments

object

an object of class MRIaggr. REQUIRED.

mask

the binary contrast parameter or a vector indicating the observations to be kept. character or logical vector with length equal to the number of observations in object. REQUIRED.

numeric2logical

should mask be converted to logical ? logical.

keep.index

should the previous index parameter be saved in the ls_descStats slot ? logical.

Value

a MRIaggr object.

See Also

calcBrainMask to compute an indicator of the brain observations.

Examples

## load NIFTI files and convert them to MRIaggr
path.Pat1 <- system.file(file.path("nifti"), package = "MRIaggr")
ls.array <- list(readMRI(file.path(path.Pat1, "T2_GRE_t0"), format = "nifti"))
MRIaggr.Pat1 <- constMRIaggr(ls.array, identifier = "Pat1", param = "T2_GRE_t0")

## create the cerebral mask

## Not run: 
res <- calcBrainMask(MRIaggr.Pat1, param = "T2_GRE_t0", type = "kmeans",
                     kmeans.n_groups = 2:4,
                     update.object = TRUE, overwrite = TRUE)

res <- calcSmoothMask(MRIaggr.Pat1, update.object = TRUE, overwrite = TRUE)

## End(Not run)
## display
multiplot(MRIaggr.Pat1, param = "mask", legend = FALSE)					  

## construct the reduced object
MRIaggr.Pat1_red <- constReduceMRIaggr(MRIaggr.Pat1, mask = "mask")

## display
par(mfrow = c(2,4), mar = rep(1.75, 4), mgp = c(2,0.75,0))
multiplot(MRIaggr.Pat1, param = "T2_GRE_t0",
             window = NULL,breaks = seq(0, 300, 1), legend = FALSE)
multiplot(MRIaggr.Pat1_red, param = "T2_GRE_t0",
             window = NULL, breaks = seq(0, 300, 1), legend = FALSE)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(MRIaggr)
Loading required package: Rcpp
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/MRIaggr/MRIaggr-constReduceMRIaggr.Rd_%03d_medium.png", width=480, height=480)
> ### Name: constReduceMRIaggr
> ### Title: Reduce a MRIaggr
> ### Aliases: constReduceMRIaggr constReduceMRIaggr,MRIaggr-method
> ### Keywords: methods
> 
> ### ** Examples
> 
> ## load NIFTI files and convert them to MRIaggr
> path.Pat1 <- system.file(file.path("nifti"), package = "MRIaggr")
> ls.array <- list(readMRI(file.path(path.Pat1, "T2_GRE_t0"), format = "nifti"))
> MRIaggr.Pat1 <- constMRIaggr(ls.array, identifier = "Pat1", param = "T2_GRE_t0")
Merging : (1) T2_GRE_t0 
> 
> ## create the cerebral mask
> ## Don't show: 
> res <- calcBrainMask(MRIaggr.Pat1, param = "T2_GRE_t0", type = "threshold",
+                      th.select_optima = 2, update.object = TRUE, overwrite = TRUE)
Derivative has been smoothed with a Gaussian kernel of width 5 breaks 
Threshold : derivative (selected)
 10.16    : 1440.781
176.48    : 19.375     (*)
252.08    : 711.3125
383.12    : 79.3125
428.48    : 249.2812
allocContrast[MRIaggr] : Cartography "mask" 
                         has been allocated 
> ## End(Don't show)
> ## Not run: 
> ##D res <- calcBrainMask(MRIaggr.Pat1, param = "T2_GRE_t0", type = "kmeans",
> ##D                      kmeans.n_groups = 2:4,
> ##D                      update.object = TRUE, overwrite = TRUE)
> ##D 
> ##D res <- calcSmoothMask(MRIaggr.Pat1, update.object = TRUE, overwrite = TRUE)
> ## End(Not run)
> ## display
> multiplot(MRIaggr.Pat1, param = "mask", legend = FALSE)					  
> 
> ## construct the reduced object
> MRIaggr.Pat1_red <- constReduceMRIaggr(MRIaggr.Pat1, mask = "mask")
supprContrast[MRIaggr] : Cartography "mask" 
                         has been removed 
allocDescStats[MRIaggr] : Element "index_sauve" 
                          has been allocated 
constReduceMRIaggr[MRIaggr] : MRIaggr_red has been created 
> 
> ## display
> par(mfrow = c(2,4), mar = rep(1.75, 4), mgp = c(2,0.75,0))
> multiplot(MRIaggr.Pat1, param = "T2_GRE_t0",
+              window = NULL,breaks = seq(0, 300, 1), legend = FALSE)
> multiplot(MRIaggr.Pat1_red, param = "T2_GRE_t0",
+              window = NULL, breaks = seq(0, 300, 1), legend = FALSE)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>