Learn R Programming

MRIaggr (version 1.1.5)

calcGroupsCoords: Compute spatial groups

Description

Compute the spatial groups using the coordinates of the observations.

Usage

calcGroupsCoords(coords, array = NULL, Neighborhood, max_groups = 10000, verbose = optionsMRIaggr("verbose"))

Arguments

coords
the spatial coordinates of the observations. data.frame. REQUIRED.
array
alternative specification of the spatial coordinates using an array where the non-NA values indicates the points of interest. array or NULL leading to consider the coords argument.
Neighborhood
the type of neighbourhood. character.
max_groups
the maximum number of groups. postive integer.
verbose
should the execution of the function be traced ? logical.

Value

An list containing :
  • [[ls.group]] : lists of the observations of each spatial group.
  • [[df.group]] : a data.frame indicating the position and the group of each observation.
  • [[group_size]] : the size of each spatial group. integer vector.

Details

ARGUMENTS: the Neighborhood argument can be a matrix or an array defining directly the neighbourhood to use (i.e the weight of each neighbor) or a name indicating which type of neighbourhood should be used (see the details section of initNeighborhood).

See Also

initFilter for various pre-stored filters.

Examples

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

optionsMRIaggr(outline.index = TRUE, num.main = FALSE)

## select data
MASK_DWI_t0 <- selectContrast(MRIaggr.Pat1_red, param = "MASK_DWI_t0")
coords <- selectCoords(MRIaggr.Pat1_red)

#### 1- compute spatial groups using coordinates ####
res3DN18 <- calcGroupsCoords(coords = coords[MASK_DWI_t0 == 1,], Neighborhood = "3D_N18")
res3DN18$group_size

## display the lesion spatial groups
multiplot(coords, contrast=MASK_DWI_t0, legend = FALSE, num=2,
          index1=coords[MASK_DWI_t0 == 1,][res3DN18$ls.group[[1]],])

#### 2-compute spatial groups using an array ####
A.MASK_DWI_t0 <- df2array(MASK_DWI_t0,coords = coords)$contrast[[1]]
A.MASK_DWI_t0[A.MASK_DWI_t0 == FALSE] <- NA

## display
graphics::image(A.MASK_DWI_t0[,,3])

## computation of the spatial groups
res3DN18.bis <- calcGroupsCoords(array = A.MASK_DWI_t0, Neighborhood = "3D_N18")

res3DN18$group_size - res3DN18.bis$group_size # same result

Run the code above in your browser using DataLab