## Module: kMeans Clustering On Label Analysis (
)

### Description:

> This is an experimental module from the Xtra Library: https://xtras.amira-avizo.com.
> The k-means algorithm divides a set of N samples X into K disjoint clusters C, each described by the mean μ j of the samples in the cluster. The means are commonly called the cluster “centroids”; note that they are not, in general, points from X, although they live in the same space. The input is a label analysis spreadsheet that is first read into a matrix and then sent to the kMeans function from sklearn and then a label map is created to assign the newly computed labels.
> Computational time : Note that while one may use one or many measures to perform the clustering, it is worthwhile thinking about which label measures to use in order to get the result of your choice. For instance, spatial label measures such as BaryCenterX, BaryCenterY and BaryCenterZ will allow for spatially clustering many labels. Using a larger set and more complex label measures such as shape measures can lead to slower computation of the final clustered label map. The script loops through every unique label in the input label map and maps that to a new label based on the clustering result. This involves creating a label map and temporary arrays that will cause the computation to be slower than some other modules. It is advised to try the measures on a very small region-of-interest first to get an intuition of the groups of measures to select before proceeding with the final computation on the entire 3D dataset.
> Memory Usage : Since the script creates intermediate arrays in order to remap the labels, typically this takes about 35% more main memory than the input image. Running out of main memory will result in an error of allocation in Python

### Connections:

> Label Image: `[required]`
> Separated objects or integer valued label map
> Label Analysis Spreadsheet: `[required]`
> Label Analysis Spreadsheet (output of Label Analysis) output of input label image
> numClasses: `[required]`
> Number of user specified classes to cluster into : Integer valued (>0)

### Citations:

> [1] Scikit-learn: Machine Learning in Python, Pedregosa et al., JMLR 12, pp. 2825-2830, 2011.