From 40c22a3452bdf14f34c88f1049e912954afcb38f Mon Sep 17 00:00:00 2001 From: Martin Wimpff <42936990+martinwimpff@users.noreply.github.com> Date: Thu, 26 Sep 2024 15:31:48 +0200 Subject: [PATCH] bugfixes in Stieger2021 (#651) * bugfixes in Stieger2021 https://github.com/NeuroTechX/moabb/issues/650 Signed-off-by: Martin Wimpff <42936990+martinwimpff@users.noreply.github.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks * Update whats_new.rst Signed-off-by: Martin Wimpff <42936990+martinwimpff@users.noreply.github.com> --------- Signed-off-by: Martin Wimpff <42936990+martinwimpff@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- docs/source/whats_new.rst | 2 ++ moabb/datasets/stieger2021.py | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/source/whats_new.rst b/docs/source/whats_new.rst index 40a3161b6..2ae601cc8 100644 --- a/docs/source/whats_new.rst +++ b/docs/source/whats_new.rst @@ -21,6 +21,8 @@ Enhancements Bugs ~~~~ +- Fix Stieger2021 dataset bugs (:gh:`651` by `Martin Wimpff`_) + API changes ~~~~~~~~~~~ diff --git a/moabb/datasets/stieger2021.py b/moabb/datasets/stieger2021.py index ae9305857..808e4ccb3 100644 --- a/moabb/datasets/stieger2021.py +++ b/moabb/datasets/stieger2021.py @@ -227,8 +227,9 @@ def _get_single_subject_data(self, subject): and (container.TrialData[i].triallength + 2) > self.interval[1] ): # this should be the cue time-point - if container.time[i][2 * srate] == 0: - raise ValueError("This should be the cue time-point,") + assert ( + container.time[i][2 * srate] == 0 + ), "This should be the cue time-point" stim[2 * srate] = y X_flat.append(x) stim_flat.append(stim[None, :]) @@ -263,7 +264,11 @@ def _get_single_subject_data(self, subject): badchanidxs = [] for idx in badchanidxs: - used_channels = ch_names if self.channels is None else self.channels + used_channels = ( + ch_names + if (not hasattr(self, "channels") or self.channels is None) + else self.channels + ) if eeg_ch_names[idx - 1] in used_channels: raw.info["bads"].append(eeg_ch_names[idx - 1]) @@ -276,5 +281,5 @@ def _get_single_subject_data(self, subject): bad_info=raw.info["bads"], ) - subject_data[session] = {"run_0": raw} + subject_data[str(session)] = {"0": raw} return subject_data