supervoxels: supervoxels

View source: R/supervoxels.R

supervoxelsR Documentation

supervoxels

Description

Cluster a NeuroVec instance into a set of spatially constrained clusters.

Usage

supervoxels(
  bvec,
  mask,
  K = 500,
  sigma1 = 1,
  sigma2 = 2.5,
  iterations = 50,
  connectivity = 27,
  use_medoid = FALSE,
  use_gradient = TRUE,
  alpha = 0.5
)

Arguments

bvec

a NeuroVec instance supplying the data to cluster.

mask

a NeuroVol mask defining the voxels to include in the clustering result. If the mask contains numeric data, nonzero values will define the included voxels. If the mask is a LogicalNeuroVol then TRUE will define the set of included voxels.

K

the number of clusters to find.

sigma1

the bandwidth of the heat kernel for computing similarity of the data vectors.

sigma2

the bandwidth of the heat kernel for computing similarity of the coordinate vectors. If this value is small, then relatively larger weights are given to nearby voxels. If is is large, then spatial weights will be less salient. A relatively large sigma1/sigma2 ratio weights data features more than spatial features, whereas as large sigma2/sigma1 ration does the opposite.

iterations

the maximum number of cluster iterations

connectivity

the number of nearest neighbors defining the neighborhood

use_medoid

whether to use the medoids to define cluster centroids

use_gradient

use the image gradient to initialize clusters

alpha

the relative weighting between spatial coherence and feature similarity metrics. alpha = 1, means all feature-weighting, alpha=0 is spatial weighting. Default is .5.

Details

Here's a brief overview of the algorithm: 1. It first scales input data (bvec)

2. It initializes the clusters using the gradient of the image and a furthest neighbor approach.

3. It then runs the "supervoxel_fit" function, which iteratively finds spatially constrained clusters using a combination of feature similarity and spatial similarity. The feature similarity is calculated based on the heat kernel with bandwidth sigma1, while the spatial similarity is calculated based on the heat kernel with bandwidth sigma2. The relative weighting between these two similarities is controlled by the alpha parameter.

4. Finally, it returns a list containing the clustered NeuroVol object (clusvol), cluster assignments for each voxel (cluster), the feature vector for each cluster (centers), and the spatial coordinates of each cluster (coord_centers). This algorithm is particularly suitable for brain data analysis, as it takes both the spatial and feature similarities into account, allowing it to identify clusters that are spatially coherent and share similar features.

Value

a list of class supervoxels_cluster_result with the following elements:

clustervol

an instance of type ClusteredNeuroVol

clusters

a vector of cluster indices equal to the number of voxels in the mask

centers

a matrix of cluster centers with each column representing the feature vector for a cluster

coord_centers

a matrix of spatial coordinates with each row corresponding to a cluster

Examples


mask <- NeuroVol(array(1, c(20,20,20)), NeuroSpace(c(20,20,20)))
bvec <- replicate(10, NeuroVol(array(runif(20*20*20), c(20,20,20)),
NeuroSpace(c(20,20,20))), simplify=FALSE)
bvec <- do.call(concat, bvec)

cres1 <- supervoxels(bvec, mask, K=100, sigma1=1, sigma2=3)

bbuchsbaum/neurocluster documentation built on April 1, 2024, 8:43 p.m.