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

Alternative implementation of causal filter in filter.py #3133

Closed

Conversation

JuanPimientoCaicedo
Copy link
Contributor

@JuanPimientoCaicedo JuanPimientoCaicedo commented Jul 3, 2024

Sorry for the delay, guys. As requested by @samuelgarcia, this is another way to implement causal filtering in filter.py.

Let me know what you think.

PR related to: #2942

Copy link
Member

@alejoe91 alejoe91 left a comment

Choose a reason for hiding this comment

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

Some changes! Also tests are failing because the new arguments are not set in the tests

src/spikeinterface/preprocessing/filter.py Outdated Show resolved Hide resolved
src/spikeinterface/preprocessing/filter.py Outdated Show resolved Hide resolved
src/spikeinterface/preprocessing/filter.py Outdated Show resolved Hide resolved
src/spikeinterface/preprocessing/filter.py Outdated Show resolved Hide resolved
src/spikeinterface/preprocessing/filter.py Outdated Show resolved Hide resolved
src/spikeinterface/preprocessing/filter.py Outdated Show resolved Hide resolved
@alejoe91 alejoe91 added the preprocessing Related to preprocessing module label Jul 4, 2024
@alejoe91
Copy link
Member

alejoe91 commented Jul 5, 2024

@JuanPimientoCaicedo can you make a PR from the alternative_filter_update instead of main?

The problem is that I cannot push to your main branch, but if you make a PR from a different branch I can...and there are a few things to fix (see failing tests)

@alejoe91
Copy link
Member

alejoe91 commented Jul 5, 2024

Otherwise you can fix it yourself here. You can just move the new parameters in the FilterRecordingSegment at the end

Copy link
Member

@alejoe91 alejoe91 left a comment

Choose a reason for hiding this comment

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

Fix tests and add docs to CausalFilter

src/spikeinterface/preprocessing/filter.py Outdated Show resolved Hide resolved
src/spikeinterface/preprocessing/filter.py Outdated Show resolved Hide resolved
src/spikeinterface/preprocessing/filter.py Show resolved Hide resolved
@alejoe91
Copy link
Member

alejoe91 commented Jul 5, 2024

@JuanPimientoCaicedo I was actually able to commit from GitHub :)

@samuelgarcia this looks good to me!

@alejoe91 alejoe91 added this to the 0.101.0 milestone Jul 5, 2024
@@ -291,14 +333,77 @@ def __init__(self, recording, freq=3000, q=30, margin_ms=5.0, dtype=None):
self._kwargs = dict(recording=recording, freq=freq, q=q, margin_ms=margin_ms, dtype=dtype.str)


class CausalFilter(FilterRecording):
Copy link
Member

Choose a reason for hiding this comment

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

Why having this class if the FilterRecording already handle it with specific options ?

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 guess it is for the same reason highpass_filter and bandpass_filter exist. Although it is true that in causal filtering, the users might need to provide some extra parameters compared with these other subclasses...

Copy link
Member

Choose a reason for hiding this comment

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

I agree with @samuelgarcia we don't need the class in this case, since the CasualFilter class is really just instantiating the FilterRecording class (the fix_dtype and kwargs will be handled by the FilterRecording class).

My suggestion is to:

  • remove this class
  • explicittly define the causal_filter function (see my comment)

@h-mayorquin
Copy link
Collaborator

h-mayorquin commented Jul 5, 2024

Should it be added to the rest in the rst in the docs?

Copy link
Member

@alejoe91 alejoe91 left a comment

Choose a reason for hiding this comment

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

@JuanPimientoCaicedo some other requests.

Also, can you add some tests?

@@ -291,14 +333,77 @@ def __init__(self, recording, freq=3000, q=30, margin_ms=5.0, dtype=None):
self._kwargs = dict(recording=recording, freq=freq, q=q, margin_ms=margin_ms, dtype=dtype.str)


class CausalFilter(FilterRecording):
Copy link
Member

Choose a reason for hiding this comment

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

I agree with @samuelgarcia we don't need the class in this case, since the CasualFilter class is really just instantiating the FilterRecording class (the fix_dtype and kwargs will be handled by the FilterRecording class).

My suggestion is to:

  • remove this class
  • explicittly define the causal_filter function (see my comment)

src/spikeinterface/preprocessing/filter.py Outdated Show resolved Hide resolved
src/spikeinterface/preprocessing/filter.py Outdated Show resolved Hide resolved

bandpass_filter.__doc__ = bandpass_filter.__doc__.format(_common_filter_docs)
highpass_filter.__doc__ = highpass_filter.__doc__.format(_common_filter_docs)
causal_filter.__doc__ = causal_filter.__doc__.format(_common_filter_docs)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
causal_filter.__doc__ = causal_filter.__doc__.format(_common_filter_docs)

We don't need this anymore since we redefined the docstring

@alejoe91
Copy link
Member

alejoe91 commented Jul 9, 2024

Also you should add the new function to the API rst.

Again, I think the best would be for you to make a new PR NOT from the main branch, so we can contribute to it.

@alejoe91 alejoe91 removed this from the 0.101.0 milestone Jul 9, 2024
@JuanPimientoCaicedo
Copy link
Contributor Author

closed in favor of #3172.

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

Successfully merging this pull request may close these issues.

4 participants