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

Added filterbanking #158

Merged
merged 5 commits into from
Sep 2, 2020
Merged

Added filterbanking #158

merged 5 commits into from
Sep 2, 2020

Conversation

gemeinl
Copy link
Collaborator

@gemeinl gemeinl commented Aug 31, 2020

Filterbanking can now be used similarly to the other preprocessing steps.
It modifies a mne.io.Raw in-place and adds new channels with the filtered signals.

braindecode/datautil/preprocess.py Outdated Show resolved Hide resolved
braindecode/datautil/preprocess.py Outdated Show resolved Hide resolved
braindecode/datautil/preprocess.py Outdated Show resolved Hide resolved
frequency_bands: list(tuple)
The frequency bands to be fitlered for (e.g. [(4, 8), (8, 13)])
drop_original_signals: bool
Whether to drop the original unfiltered signals
Copy link
Collaborator

Choose a reason for hiding this comment

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

missing many params

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In the docstring above I stated to refer to mne.filter.filter_data() for a description of the parameters. Should I copy the docstring from mne instead and paste it here?

@agramfort
Copy link
Collaborator

agramfort commented Aug 31, 2020 via email

# copy docstring from mne to here
filterbank.__doc__ += mne.io.Raw.filter.__doc__[
mne.io.Raw.filter.__doc__.find("picks : "):
mne.io.Raw.filter.__doc__.find("Returns")].replace(8 * " ", 4 * " ")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Honestly this is black magic. This code in mne barely changes so I would copy the docstring.
YOu can make a test that asserts that docs are in sync. It's much simpler.

Copy link
Contributor

Choose a reason for hiding this comment

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

I feel previous solution to explicitly refer to MNE also has advantages:

  • Less clutter in our code
  • It is more explicit that we just forward these arguments, one does not have to check whether there is any difference between MNE and us

And we anyways build so much around MNE now, pretty much encouraging the user to learn some MNE.


def filterbank(raw, frequency_bands, drop_original_signals=True, n_jobs=1,
method='fir', iir_params=None, phase='zero', fir_window='hamming',
fir_design='firwin', **filter_kwargs):
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not simply having **filter_kwargs and say it supports params of filter function from mne?

if feels you explicit some params and some not.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In another PR you mentioned disliking kwargs and to make arguments explicit. I therefore took the arguments that are relevant for my use case and made them explicit, while at the same time keeping full compatibility with mne through filter_kwargs. I will now update it again to be less explicit and only have the filter_kwargs. The docstring for this parameter will then contain a referral to mne.

Copy link
Collaborator

Choose a reason for hiding this comment

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

arfff to be it's one option or the other. If it was me and I would copy all
the mne parameters and copy the docstring. After updating the docstring
5 times due to mne changes I would reconsider. Note that mne release
are every 6 months so...

@robintibor robintibor merged commit 1d0b299 into braindecode:master Sep 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants