catmssim_3d_slice: Multiscale Categorical Structural Similarity Index Measure by...

Description Usage Arguments Value Examples

View source: R/catsim.R

Description

The categorical structural similarity index measure for 3D categorical or binary images for multiple scales. The default is to compute over 5 scales. This computes a 2D measure for each x-y slice of the z-axis and then averages over the z-axis.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
catmssim_3d_slice(
  x,
  y,
  levels = NULL,
  weights = NULL,
  window = 11,
  method = "Cohen",
  ...,
  random = "random"
)

Arguments

x

a binary or categorical image

y

a binary or categorical image

levels

how many levels of downsampling to use. By default, 5. If weights is specified and this is left blank, the argument will be inferred from the number of weights specified.

weights

a vector of weights for the different scales. By default, equal to rep(1,levels)/levels. If specified, there must at least as many weights as there are levels and the first levels weights will be used.

window

by default 11 for 2D and 5 for 3D images, but can be specified as a vector if the window sizes differ by dimension. The vector must have the same number of dimensions as the inputted x and y.

method

whether to use Cohen's kappa (Cohen), Jaccard Index (Jaccard), Dice index (Dice), accuracy (accuracy), Rand index (Rand), Adjusted Rand Index (AdjRand or ARI), normalized mutual information (NMI or MI) or the adjusted mutual information, AMI and ami, as the similarity index. Note Jaccard and Dice should only be used on binary data.

...

additional constants can be passed to internal functions.

random

whether to have deterministic PRNG (pseudo) or to use sample() (random). If NULL, will choose the first mode. For complete reproducibility, use pseudo or NULL.

Value

a value less than 1 indicating the similarity between the images.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
set.seed(20181207)
dim <- 8
x <- array(sample(0:4, dim^5, replace = TRUE), dim = c(dim^2, dim^2, dim))
y <- x
for (j in 1:(dim)) {
  for (i in 1:(dim^2)) y[i, i, j] <- 0
  for (i in 1:(dim^2 - 1)) y[i, i + 1, j] <- 0
}
catmssim_3d_slice(x, y, weights = c(.75, .25)) # by default method = "Cohen"
# compare to some simple metric:
mean(x == y)

Example output

[1] 0.8923996
[1] 0.9750671

catsim documentation built on Jan. 13, 2021, 7:45 p.m.