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

Allow export_to_phy to work with fast_templates #2549

Merged
merged 15 commits into from Mar 27, 2024

Conversation

DradeAW
Copy link
Contributor

@DradeAW DradeAW commented Mar 6, 2024

No description provided.

@samuelgarcia
Copy link
Member

Salut Aurelien.
Ok for me.
I made a few comments.

@DradeAW
Copy link
Contributor Author

DradeAW commented Mar 6, 2024

Done!

I also implemented a function get_unit_template because I find it very useful :)

@samuelgarcia
Copy link
Member

This is OK for me.
@alejoe91 : do you want to have a look ?

src/spikeinterface/exporters/to_phy.py Show resolved Hide resolved
src/spikeinterface/core/analyzer_extension_core.py Outdated Show resolved Hide resolved

Parameters
----------
unit_id:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this an int or a string?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well it depends,

There is currently no defined type for unit_id in SpikeInterface

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't they strings | int. Right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe they are, but who says that won't change in the future?

Copy link
Collaborator

@zm711 zm711 Mar 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You. Right now. Lock it in and take control. :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

str | int
Alessio is fighting for str only but I strongly resist.

DradeAW and others added 3 commits March 6, 2024 14:34
Co-authored-by: Zach McKenzie <92116279+zm711@users.noreply.github.com>
Co-authored-by: Zach McKenzie <92116279+zm711@users.noreply.github.com>
DradeAW added a commit to DradeAW/spikeinterface that referenced this pull request Mar 6, 2024
Depends on SpikeInterface#2549 (which needs to be merged before)
@zm711 zm711 added the exporters Related to exporters module label Mar 8, 2024
Copy link
Collaborator

@zm711 zm711 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick question @DradeAW for the assert check in this PR :)

Comment on lines 193 to 195
assert (
templates_ext is not None
), "export_to_phy requires SortingAnalyzer with either extension 'templates' or 'fast_templates'"
Copy link
Collaborator

@zm711 zm711 Mar 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about this and templates_ext cannot be None, because if it is None above the templates_ext.get_templates will fail. Or am I misreading this? It seems to me that it would be better to do a check for none after line 185. Something like

if templates_ext is None:
    raise ValueError('Must have either calculated templates or fast_templates')

That way regardless of if the | notation is accepted you have the check in place.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, nice catch!

But as you said, I'm waiting for the | PR to be merged, to re-write this more cleanly :)

@DradeAW
Copy link
Contributor Author

DradeAW commented Mar 27, 2024

Ok I updated the implementation to be cleaner, and follow what we agreed to follow in #2570

This is ready on my end :)

@DradeAW
Copy link
Contributor Author

DradeAW commented Mar 27, 2024

@alejoe91 The test failed for some weird reason (not my fault), and I don't have the permissions to re-launch the test :/

@@ -180,8 +180,10 @@ def export_to_phy(

# export templates/templates_ind/similar_templates
# shape (num_units, num_samples, max_num_channels)
templates_ext = sorting_analyzer.get_extension("templates")
templates_ext is not None, "export_to_phy need SortingAnalyzer with extension 'templates'"
templates_ext = sorting_analyzer.get_extension("templates") or sorting_analyzer.get_extension("fast_templates")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

@alejoe91 alejoe91 merged commit 93f9cc5 into SpikeInterface:main Mar 27, 2024
11 checks passed
@DradeAW DradeAW deleted the fix_export_phy_templates branch March 27, 2024 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exporters Related to exporters module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants