Learn R Programming

MRIaggr (version 1.1.5)

calcGR: Interface to the Growing Region algorithm

Description

Call the GRalgo function to perform the Growing Region algorithm.

Usage

calcGR(contrast, W, seed, sigma_max, range = c(-Inf, +Inf), range.seed = c(-Inf, +Inf), breaks = 100, rescale = FALSE, iter_max = 100, sd.robust = FALSE, keep.lower = FALSE, keep.upper = FALSE, verbose = TRUE, history.sigma = FALSE, history.step = FALSE, history.front = FALSE)

Arguments

contrast
the contrast value of each observation. numeric vector. REQUIRED.
W
the neighbourhood matrix. dgCMatrix. REQUIRED.
seed
the index of the initial seeds or a binary indicator of the initial seeds. positive integer vector or logical vector. REQUIRED.
sigma_max
the maximum admissible value for the variability of the group contrast. positive numeric. REQUIRED.
range
the range of acceptable contrast values for the growing region group. numeric vector of size 2.
range.seed
the range of acceptable contrast values for the seeds. numeric vector of size 2.
breaks
the break points or the number of break points to use to categorize the contrast distribution. numeric vector or postive integer.
rescale
should the contrast be scaled ? logical.
iter_max
the maximum number of iterations for the expansion of the growing region. postive integer.
sd.robust
should the median absolute deviation be used to estimte the variability of the group contrast, or the standard deviation ? logical.
keep.lower
should removing observations with high intensity of the region be forbidden ? logical.
keep.upper
should removing observations with low intensity of the region be forbidden ? logical.
verbose
should the execution of the function be traced ? logical.
history.sigma
should the values of sigma be recorded ? logical.
history.step
should the number of observations included in the growing region set be recorded ? logical.
history.front
should the propagation front of the GR set be recorded ? logical.

Value

An list containing :
  • [[GR]] : the index of the observations in the growing region. integer vector.
  • [[test.break]] : whether the GR algorithm was interrupted an during execution. logical.
  • [[iter]] : the number of the last iteration of the algorithm. integer.
  • [[test.id]] : whether the GR set has stabilised during the last iteration. logical.
  • [[sigma]] : if history.sigma was set to TRUE, the value of the homogeneity criterion at the begining and the end of each step (in columns) for all steps (in row). numeric matrix.
  • [[history_GR]] : if history.step was set to TRUE, the step when each GR observation was included in the GR set. integer vector.
  • [[breaks]] : if history.front was set to TRUE, the values used to categorize the contrast. numeric vector.

Details

FUNCTION: This implementation of the Growing Region algorithm was been proposed by (Revol et al. 1997).

References

Chantal Revol and Michel Jourlin. A new minimum varance region growing algorithm for image segmentation. Pattern Recognition Letters, 18(3):249-258,1997.

See Also

calcCriteriaGR for an automatic estimate of the sigma value.

Examples

Run this code
## load a MRIaggr object
data(MRIaggr.Pat1_red, package = "MRIaggr")

calcThresholdMRIaggr(MRIaggr.Pat1_red, param = c("TTP_t0","MTT_t0"), threshold = 1:10,
                     name_newparam = c("TTP.th_t0","MTT.th_t0"),
                     update.object = TRUE, overwrite = TRUE)
					 
## display raw parameter
multiplot(MRIaggr.Pat1_red, param = "TTP.th_t0", num = 3, numeric2logical = TRUE,
          index1 = list(coords = "MASK_DWI_t0", outline = TRUE))

## extract raw parameter, coordinates and compute the neighbourhood matrix
carto <- selectContrast(MRIaggr.Pat1_red, num = 3, hemisphere = "lesion",
                         param = c("TTP.th_t0","TTP_t0","MASK_DWI_t0"))
coords <- selectCoords(MRIaggr.Pat1_red, num = 3, hemisphere = "lesion")
W <- calcW(coords, range = sqrt(2))$W

## the seed is taken to be the point with the largest TTP in the lesion mask
indexN <- which(carto$MASK_DWI_t0 == 1)
seed <- indexN[which.max(carto[indexN,"TTP_t0"])] 

## Display step by step the GR algorithm with sigma = 1
for(iter in c(0,1,2,5,10)){
  resGR1 <- calcGR(contrast = carto$TTP.th_t0, W = W, 
                   seed = seed, sigma_max = 1, iter_max = iter, verbose = FALSE)
  
  multiplot(MRIaggr.Pat1_red, param = "TTP.th_t0", num = 3,hemisphere = "lesion", legend = FALSE,
         breaks = seq(0,10,0.1), numeric2logical = TRUE, cex = 2,
		 main = paste("iteration=",iter," - slice ", sep = ""),          
         index1 = list(coords = coords[resGR1$GR,], pch = 20, cex = 1),
         index2 = list(coords = coords[seed,], pch = 20, cex = 1)
  )
}

## Not run: 
# ## GR with sigma = 2.2
# resGR2 <- calcGR(contrast = carto$TTP.th_t0, W = W, 
#                  seed = seed, sigma_max = 2.2, iter_max = 50,
#                  history.step = TRUE, history.front = TRUE)
# 
# ## display 
# # display the GR over the raw contrast
# multiplot(MRIaggr.Pat1_red, param = "TTP.th_t0", num = 3, hemisphere = "lesion", legend = FALSE,
#              breaks = seq(0,10,0.1), numeric2logical = TRUE, cex = 2,            
#              index1 = list(coords = coords[resGR2$GR,], pch = 20, cex = 1)
# )
# 
# # display the step of inclusion in GR group for each observation
# multiplot(coords[resGR2$GR,],
#              resGR2$history.step,breaks = 0:10,
#              index1=list(coords = coords[seed,]),
#              palette = rainbow(10)
# )
# 
# # display the front propagation 
# multiplot(coords[resGR2$GR,],
#              resGR2$Mfront[,7],
#              index1 = list(coords = coords[seed,])
# )
# ## End(Not run)

Run the code above in your browser using DataLab