[Proposal] Generic preprocessing function for arbitrary preprocessing steps #2813
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements a generic preprocessing step that is implemented as a function. The user defines a pre-processing step with a function that is applied to a data chunk and then that function is called every time the user calls
get_traces
. The implementation usespartial
from the functools in the standard library to separate (possible) heavy computation at the__init__
from the one atget_traces
but that's it, otherwise it is very simple.Here a quick example of how it would look like. I am working for a project where I need to use a bandpass filter that is a bit different from the one in the library:
I am aware that we could use filter design and the API of spikeinterface to implement something similar but let me use this example as an illustration for how to integrate any generic pre-processing step. My desire would be to to test this specific way of filtering with a couple of functions of spikeinterface, let's say peak detection.
With the PR here this looks like the following:
Whereas otherwise I would need to do something like this:
I claim that the way of this PR is way simpler, allows users to tests their ideas quicker and requires them to know less about Spikeinterface internals to do what they want to do.
Some drawbacks:
Thoughts?