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

Add "autoreject_local" as new option for preprocessing/ptp_reject #807

Merged
merged 21 commits into from
Nov 3, 2023

Conversation

hoechenberger
Copy link
Member

@hoechenberger hoechenberger commented Nov 2, 2023

Before merging …

  • Changelog has been updated (docs/source/changes.md)

closes #410

cc @dengemann

@hoechenberger

This comment has been minimized.

@hoechenberger hoechenberger marked this pull request as ready for review November 2, 2023 14:34
@hoechenberger
Copy link
Member Author

Thanks @larsoner

@hoechenberger

This comment has been minimized.

@hoechenberger
Copy link
Member Author

hoechenberger commented Nov 2, 2023

@larsoner I believe the CI error may have to do with mne-tools/mne-python#12156
These errors did not occur before that PR was merged :(

@hoechenberger

This comment was marked as outdated.

hoechenberger added a commit to hoechenberger/mne-python that referenced this pull request Nov 3, 2023
Tries to fix CI error we get for mne-bids-pipeline:
mne-tools/mne-bids-pipeline#807 (comment)

This is a followup-fix for mne-tools#12156
Comment on lines 83 to 110
if cfg.reject == "autoreject_local":
import numpy as np
import autoreject

msg = "Using autoreject to find and repair bad epochs"
logger.info(**gen_log_kwargs(message=msg))

ar = autoreject.AutoReject(
n_interpolate=np.array(cfg.autoreject_n_interpolate),
random_state=cfg.random_state,
n_jobs=exec_params.n_jobs,
verbose=False,
)
n_epochs_before_reject = len(epochs)
epochs, reject_log = ar.fit_transform(epochs, return_log=True)
n_epochs_after_reject = len(epochs)
assert (
n_epochs_before_reject - n_epochs_after_reject
== reject_log.bad_epochs.sum()
)

msg = (
f"autoreject marked {reject_log.bad_epochs.sum()} epochs as bad "
f"(cross-validated n_interpolate limit: {ar.n_interpolate_})"
)
logger.info(**gen_log_kwargs(message=msg))
else:
reject = _get_reject(
Copy link
Member Author

Choose a reason for hiding this comment

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

The diff doesn't look nice here, but I basically just added this new if block and moved the previous code into the else section

@hoechenberger
Copy link
Member Author

We're green!

docs/source/v1.5.md.inc Outdated Show resolved Hide resolved
mne_bids_pipeline/_config.py Outdated Show resolved Hide resolved
mne_bids_pipeline/steps/preprocessing/_08_ptp_reject.py Outdated Show resolved Hide resolved
mne_bids_pipeline/steps/preprocessing/_08_ptp_reject.py Outdated Show resolved Hide resolved
hoechenberger and others added 3 commits November 3, 2023 18:02
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
@hoechenberger
Copy link
Member Author

@larsoner I've addressed your comments

@larsoner larsoner enabled auto-merge (squash) November 3, 2023 17:42
@larsoner larsoner merged commit 418a2e7 into mne-tools:main Nov 3, 2023
47 of 48 checks passed
@hoechenberger hoechenberger deleted the autoreject-local branch November 3, 2023 18:25
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.

Add support for AutoReject local
2 participants