Skip to content

Commit d9d041e

Browse files
committed
Update L-ratio normalization method
1 parent ef02966 commit d9d041e

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

ecephys_spike_sorting/modules/quality_metrics/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ Computes quality metrics for sorted units. Similar to the `mean_waveforms` modul
1111
| ISI violations |![](images/isi_viol.png) | Rate of refractory-period violations | |
1212
| Amplitude cutoff |![](images/amp_cut.png) | Estimate of miss rate based on amplitude histogram | |
1313
| Isolation distance |![](images/isol_dist.png) | Distance to nearest cluster in Mahalanobis space | Schmitzer-Torbert et al. (2005) _Neuroscience_ **131**, 1-11 |
14-
| L-ratio | | | " |
14+
| L-ratio<sup>1</sup> | | The Mahalanobis distance and chi-squared inverse cdf (given the assumption that the spikes in the cluster distribute normally in each dimension) are used to find the probability of cluster membership for each spike. | " |
1515
| _d'_ |![](images/d_prime.png) | Classification accuracy based on LDA | Hill et al. (2011) _J Neurosci_ **31**, 8699-9705 |
1616
| Nearest-neighbors |![](images/nn_overlap.png)| Non-parametric estimate of unit contamination | Chung et al. (2017) _Neuron_ **95**, 1381-1394 |
1717
| Silhouette score | | Standard metric for cluster overlap | |
1818
| Maximum drift | | Maximum change in spike depth throughout recording | |
1919
| Cumulative drift | | Cumulative change in spike depth throughout recording | |
2020

21+
<sup>1</sup> algorithm updated on Aug 11, 2020 to fix normalization factor
22+
2123
### A Note on Calculations
2224

2325
For metrics based on waveform principal components (isolation distance, L-ratio, _d'_, and nearest neighbors hit rate and false alarm rate), it is typical to compute the metrics for all pairs of units and report the "worst-case" value. We have found that this tends to under- or over-estimate the degree of contamination when there are large firing rate differences between pairs of units that are being compared. Instead, we compute metrics by sub-selecting spikes from _all_ other units on the same set of channels, which seems to give a more accurate picture of isolation quality. We would appreciate feedback on whether this approach makes sense.

ecephys_spike_sorting/modules/quality_metrics/metrics.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,8 @@ def mahalanobis_metrics(all_pcs, all_labels, this_unit_id):
697697

698698
dof = pcs_for_this_unit.shape[1] # number of features
699699

700-
l_ratio = np.sum(1 - chi2.cdf(pow(mahalanobis_other,2), dof)) / mahalanobis_other.shape[0]
700+
l_ratio = np.sum(1 - chi2.cdf(pow(mahalanobis_other,2), dof)) / \
701+
mahalanobis_self.shape[0] # normalize by size of cluster, not number of other spikes
701702
isolation_distance = pow(mahalanobis_other[n-1],2)
702703

703704
else:

0 commit comments

Comments
 (0)