Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting spike interface QC metrics into Phy #3112

Closed
twheatcroft07 opened this issue Jul 1, 2024 · 3 comments · Fixed by #3123
Closed

Getting spike interface QC metrics into Phy #3112

twheatcroft07 opened this issue Jul 1, 2024 · 3 comments · Fixed by #3123
Assignees
Labels
exporters Related to exporters module qualitymetrics Related to qualitymetrics module

Comments

@twheatcroft07
Copy link

twheatcroft07 commented Jul 1, 2024

Hi there,

I am wondering how to view the quality metrics, computed by spike interface, in Phy. Ideally for each unit in Phy, I would be able to see its computed quality metric scores.

I understand that one can create a sorting analyzer, and compute certain values within that, but I can't see how to associate metrics with a sorting analyzer object, for example.

Thanks,

@alejoe91 alejoe91 self-assigned this Jul 1, 2024
@alejoe91 alejoe91 added exporters Related to exporters module qualitymetrics Related to qualitymetrics module labels Jul 1, 2024
@jakeswann1
Copy link
Contributor

jakeswann1 commented Jul 1, 2024

An easy way to do this is to extract the quality metrics as a DataFrame, then save this to a cluster_something.tsv file. Assuming you alreay have a SortingAnalyzer with metrics computed, should be able to do this as follows:

import pandas as pd

# Create sorting analyzer here

quality_metrics = analyzer.extensions['quality_metrics'].data["metrics"]
quality_metrics.index.name = 'cluster_id'
quality_metrics.to_csv(phy_folder / 'cluster_metrics.tsv', sep='\t')

By default, phy should load columns from any .tsv files it finds in the folder named cluster_xxxx.tsv, with cluster_id as an index column. One thing to note with this approach is that these are not computed dynamically, so if you split or merge units the values won't update for any new cluster IDs.

Hope this helps!

@alejoe91
Copy link
Member

alejoe91 commented Jul 2, 2024

@twheatcroft07 actually if the SortingAnalyzer has the quality_metrics extension, each metric should alreayd be saved as a TSV file and available in Phy:

See this section

In this PR, I added more control also to be able to add any custom property attached to the analyzer.sorting object: #3123

@twheatcroft07
Copy link
Author

@alejoe91, thanks so much for working on this.

As part of export_to_phy(), fitting PCA was slated to take ~3hrs for my example session, so I'll go with @jakeswann1 's option for the time being.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exporters Related to exporters module qualitymetrics Related to qualitymetrics module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants