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

Omit bad channels when gathering data used for decoding #817

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/source/v1.5.md.inc
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,6 @@ All users are encouraged to update.
- Fixed bug where head position files were not written with a proper suffix and extension (#761 by @larsoner)
- Fixed bug where default values for `decoding_csp_times` and `decoding_csp_freqs` were not set dynamically based on the config parameters (#779 by @larsoner)
- Fixed bug where the MNE logger verbosity was not respected inside parallel jobs (#813 by @larsoner)
- A number of processing steps erroneously **always** operated on un-cleaned epochs (`sensor/decoding_full_epochs`, `sensor/decoding_time_by_time`, `sensor/decoding_csp`); or operated on un-cleaned epochs (without PTP rejection) if no ICA or SSP was requested (`sensor/ime_frequency`, `sensor/make_cov`) The bug in `sensor/make_cov` could propagate to the source level, as the covariance matrix is used for inverse modeling. (#796 by @hoechenberger)
- A number of processing steps erroneously **always** operated on un-cleaned epochs (`sensor/decoding_full_epochs`, `sensor/decoding_time_by_time`, `sensor/decoding_csp`); or operated on un-cleaned epochs (without PTP rejection) if no ICA or SSP was requested (`sensor/ime_frequency`, `sensor/make_cov`) The bug in `sensor/make_cov` could propagate to the source level, as the covariance matrix is used for inverse modeling. (#796 by @hoechenberger)
- Bad channels may have been submitted to MVPA (full epochs decoding, time-by-time decoding, CSP-based decoding) when not using Maxwell filtering
(i.e., usually only EEG data was affected). This has now been fixed and data from bad channels is omitted from decoding. (#817 by @hoechenberger)
2 changes: 1 addition & 1 deletion mne_bids_pipeline/steps/sensor/_02_decoding_full_epochs.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def run_epochs_decoding(
n_cond1 = len(epochs[epochs_conds[0]])
n_cond2 = len(epochs[epochs_conds[1]])

X = epochs.get_data()
X = epochs.get_data(picks="data") # omit bad channels
y = np.r_[np.ones(n_cond1), np.zeros(n_cond2)]

classification_pipeline = make_pipeline(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def run_time_decoding(
if cfg.decoding_time_generalization and decim > 1:
epochs.decimate(decim, verbose="error")

X = epochs.get_data()
X = epochs.get_data(picks="data") # omit bad channels
y = np.r_[np.ones(n_cond1), np.zeros(n_cond2)]
# ProgressBar does not work on dask, so only enable it if not using dask
verbose = get_parallel_backend_name(exec_params=exec_params) != "dask"
Expand Down
4 changes: 2 additions & 2 deletions mne_bids_pipeline/steps/sensor/_05_decoding_csp.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def _fmt_contrast(cond1, cond2, fmin, fmax, freq_range_name, tmin=None, tmax=Non
epochs=epochs, contrast=contrast, fmin=fmin, fmax=fmax, cfg=cfg
)
# Get the data for all time points
X = epochs_filt.get_data()
X = epochs_filt.get_data(picks="data") # omit bad channels

# We apply PCA before running CSP:
# - much faster CSP processing
Expand Down Expand Up @@ -327,7 +327,7 @@ def _fmt_contrast(cond1, cond2, fmin, fmax, freq_range_name, tmin=None, tmax=Non
if tmax is not None: # avoid warnings about outside the interval
tmax = min(tmax, epochs_filt.times[-1])
epochs_filt.crop(tmin, tmax)
X = epochs_filt.get_data()
X = epochs_filt.get_data(picks="data") # omit bad channels
X_pca = pca.transform(X)
del X

Expand Down
Loading