sgmix: Spatial Gaussian Mixture Model

View source: R/sgmix.R

sgmixR Documentation

Spatial Gaussian Mixture Model

Description

Spatially segment a single-channel image using a Dirichlet Gaussian mixture model (DGMM).

Usage

# Spatial Gaussian mixture model
sgmix(x, y, vals, r = 1, k = 2, group = NULL,
	weights = c("gaussian", "bilateral", "adaptive"),
	metric = "maximum", p = 2, neighbors = NULL,
	annealing = TRUE, niter = 10L, tol = 1e-3,
	compress = FALSE, byrow = FALSE,
	verbose = NA, chunkopts=list(),
	BPPARAM = bpparam(), ...)

## S3 method for class 'sgmix'
fitted(object,
	type = c("mu", "sigma", "class"), channel = NULL, ...)

## S3 method for class 'sgmix'
logLik(object, ...)

Arguments

x, y, vals

Pixel coordinates (x, y) and their intensity values (vals). If multiple image channels should be segmented, then vals can be a list of images or a matrix of flattened image vectors. Alternatively, x can be an array of images, in which case the x and y coordinates are generated from the first 2 dimensions.

r

The spatial smoothing radius.

k

The number of segments (per group, if applicable).

group

A vector of pixel groups. Pixels belonging to each group will be segmented independently, and will be assigned to different segments.

weights

The type of spatial weights to use.

metric

Distance metric to use when finding neighboring pixels. Supported metrics include "euclidean", "maximum", "manhattan", and "minkowski".

p

The power for the Minkowski distance.

neighbors

An optional list giving the neighboring pixel indices for each pixel.

annealing

Should simulated annealing be attempted every iteration? (If FALSE, simulated annealing will still be attempted if the log-likelihood decreases instead of increases during an iteration.)

niter

The maximum number of iterations.

tol

The tolerance for convergence, as measured by the change in log-likelihood in successive iterations.

compress

Should the results be compressed? The resulting sgmix object will be larger than the original image, so compression can be useful. If TRUE, then the class component is compressed using drle, and the probability component is not returned.

byrow

If vals is a matrix of flattened image vectors, should its rows or columns be plotted?

verbose

Should progress be printed for each iteration?

chunkopts

An (optional) list of chunk options including nchunks, chunksize, and serialize. See chunkApply.

BPPARAM

An optional instance of BiocParallelParam. See documentation for bplapply.

...

Ignored.

object

An object inheriting from sgmix.

type

The type of fitted values to extract.

channel

The channel of fitted values to extract.

Details

Spatial segmentation is performed using a Gaussian mixture model from Guo et al. (2019) that uses Dirichlet priors to incorporate spatial dependence. The strength of the spatial smoothing depends on the smoothing radius (r) and the type of spatial weights. The "bilateral" and "adaptive" weights can preserve edges better than the standard "gaussian" weights at the expense of a (potentially) noisier segmentation.

The segmentation is initialized using k-means clustering. An expectation-maximization (E-M) algorithm with gradient descent is then used to estimate the model parameters based on log-likelihood. Optionally, simulated annealing can be used to prevent the model from getting stuck in local maxima.

Value

An object of class sgmix, with the following components:

  • class: A list of class assignments for each channel.

  • probability: (Optional) A matrix or array of posterior class probabilities.

  • mu: The fitted class means.

  • sigma: The fitted class standard deviations.

  • alpha: The fitted Dirichlet priors.

  • beta: The estimated strength of the spatial dependence.

  • group: (Optional) The pixel groups.

Author(s)

Kylie A. Bemis

References

D. Guo, K. Bemis, C. Rawlins, J. Agar, and O. Vitek. “Unsupervised segmentation of mass spectrometric ion images characterizes morphology of tissues” Bioinformatics, vol. 35, issue 14, pp. i208-i217, 2019.

See Also

kmeans

Examples

require(datasets)

set.seed(1)
seg <- sgmix(volcano, k=3)

image(fitted(seg, "class", channel=1L))

kuwisdelu/matter documentation built on Oct. 19, 2024, 10:31 a.m.