-
Notifications
You must be signed in to change notification settings - Fork 202
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 preprocessing on dicts of recordings #3711
base: main
Are you sure you want to change the base?
Allow preprocessing on dicts of recordings #3711
Conversation
Also I think this was Sam who liked keeping this around right @alejoe91 ? I only ever use the function version of all the classes. And I remember a discussion somewhere on the repo about removing classes from init and only exposing the functions moving forward. |
Had another go and it feels more beautiful! Added the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple naming things to think about while you wait for Alessio and Sam.
return preprocessed_recordings_dict | ||
|
||
|
||
def define_rec_or_dict_function(source_class, name): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same for symmetry maybe define_rec_or_dict_function_from_class
so that we see that this function is the same as below function but to have a dict_function
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about: define_function_or_dict_from_class
, which is the same as below, but I think is more accurate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me. I guess the real full name would be define_function_or_dict_of_function_from_class
but at some point the name is just too long :P.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can keep tho original name qnd explain what it does on the docstting for simplicity :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Zach is right: it's nice to have the same grammar as define_function_from_class
. Also added docstrings to both new functions
src/spikeinterface/preprocessing/tests/test_grouped_preprocessing.py
Outdated
Show resolved
Hide resolved
This looks good. |
I think we should limit it to recordings or dicts of recordings. It encourages the user to label groups of recordings. Also, if we use lists, we'd probably add a key when we save to keep track of things. But when a user loads it, they'd expect a list. To me, it complexifies the saving/loading. Anyone have a good use case for lists? |
This PR would allow user to pass dicts of recordings to all preprocessing classes (for now: just common reference!)
This would allow for the following syntax:
which can be chained without problem. Also allows for users to take in two sessions from e.g. different days and ensure the same preprocessing steps are applied to them. Or helpful if you want to split your recording in half and sort seperately (UnitMatch almost do this).
This would certainly remove a few annoying for loops from our labs' pipeline.
We agreed to not touch the
BaseRecording
class. I made thedefine_function_or_dict_from_class
, which looks through theargs
andkwargs
for a recording or dict of recordings, then applies either the normal function (e.g.CommonReferenceRecording
) or produces a dict, where each recording has had the normal function applied to it, keeping the original keys. I've copied the signature, doc and set a new name in the function, rather than calling another decorator (alaspikeinterface/spikeinterface/core/core_tools.py
Line 25 in c837b3b
Also, note that this only works for the functions. So
common_reference(dict_of_recs)
is good butCommonReferenceRecording(dict_of_recs)
does not work. This seems ok from the user point of view, but maybe there's some deeper issue with loading that I'm not thinking of??