ecephys_spike_sorting icon indicating copy to clipboard operation
ecephys_spike_sorting copied to clipboard

Error calculating d_prime

Open ldclaar opened this issue 3 years ago • 1 comments

I'm running into the following error when I run the quality_metrics module (using the master branch) on a dataset I collected:

d_prime = lda_metrics(all_pcs, all_labels, cluster_id) (from line 278 in metrics.py) ValueError: n_components cannot be larger than min(n_features, n_classes - 1).

I've done a little digging and, from what I can tell, it is failing on clusters that do not have any other units_in_range. One way to avoid the problem is to increase the num_channels_to_compare in the quality_metrics_params. Is this a good solution though? I know this will increase the number of neighboring units each cluster is compared to. Another possible solution would be to set a d_prime value (NaN or some high value?) if there are no units_in_range. Does this make sense? I could also be misdiagnosing the problem, any ideas?

ldclaar avatar Oct 27 '20 22:10 ldclaar

I think the second option makes the most sense. If there's only one unit on a segment of the probe, LDA and other PCA-based metrics are not defined. I would recommend adding an extra check on line 272 of metrics.py to test if len(units_in_range) > 1.

jsiegle avatar Oct 28 '20 19:10 jsiegle