Isolation distance (isolation_distance
)¶
Calculation¶
\(C\) : cluster of interest.
\(N_s\) : number of spikes within cluster \(C\).
\(N_n\) : number of spikes outside of cluster \(C\).
\(N_{min}\) : minimum of \(N_s\) and \(N_n\).
\(\mu_C\), \(\Sigma_C\) : mean vector and covariance matrix for spikes within \(C\) (where each spike within \(C\) is represented by a vector of principal components (PCs)).
\(D_{i,C}^2\) : for every spike \(i\) (represented by vector \(x_i\)) outside of cluster \(C\), the Mahalanobis distance (as below) between \(\mu_c\) and \(x_i\) is calculated. These distances are ordered from smallest to largest. The \(N_{min}\)’th entry in this list is the isolation distance.
Geometrically, the isolation distance for cluster \(C\) is the radius of the circle which contains \(N_{min}\) spikes from cluster \(C\) and \(N_{min}\) spikes outside of the cluster \(C\).
Expectation and use¶
Isolation distance can be interpreted as a measure of distance from the cluster to the nearest other cluster. A well isolated unit should have a large isolation distance.
Example code¶
import spikeinterface.qualitymetrics as sqm
iso_distance, _ = sqm.isolation_distance(all_pcs=all_pcs, all_labels=all_labels, this_unit_id=0)
References¶
- spikeinterface.qualitymetrics.pca_metrics.mahalanobis_metrics(all_pcs, all_labels, this_unit_id)¶
Calculates isolation distance and L-ratio (metrics computed from Mahalanobis distance)
- Parameters
- all_pcs2d array
The PCs for all spikes, organized as [num_spikes, PCs].
- all_labels1d array
The cluster labels for all spikes. Must have length of number of spikes.
- this_unit_idint
The ID for the unit to calculate these metrics for.
- Returns
- isolation_distancefloat
Isolation distance of this unit.
- l_ratiofloat
L-ratio for this unit.
References
Based on metrics described in [Schmitzer-Torbert]
Literature¶
Introduced by [Harris].