From 0726256ce1bb2d81a8bd1413e133b77f52905cd6 Mon Sep 17 00:00:00 2001 From: bruAristimunha Date: Tue, 29 Jul 2025 23:14:18 +0200 Subject: [PATCH 1/3] fixing small problem with new version --- moabb/datasets/braininvaders.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moabb/datasets/braininvaders.py b/moabb/datasets/braininvaders.py index 5eda4bd2e..7b79f962f 100644 --- a/moabb/datasets/braininvaders.py +++ b/moabb/datasets/braininvaders.py @@ -284,7 +284,7 @@ def _bi_data_path( # noqa: C901 zip_ref = z.ZipFile(path_zip, "r") zip_ref.extractall(path_folder) os.makedirs(osp.join(directory, f"Session{i + 1}")) - shutil.copy_tree(path_zip.strip(".zip"), directory) + shutil.copytree(path_zip.strip(".zip"), directory) shutil.rmtree(path_zip.strip(".zip")) # filter the data regarding the experimental conditions From 823fb67bcfe8d84e609668cfe6cd5a015bbfffd9 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 1 Aug 2025 11:17:39 +0000 Subject: [PATCH 2/3] Improve test coverage for pipelines This commit improves the test coverage of the MOABB pipelines. The following changes were made: - Added more pipelines to the test suite, including a Python-based pipeline and a pipeline with a grid search. - Corrected a typo in a test pipeline file name. - Adapted the test pipelines to use the fake paradigms available in the test environment. - Reduced the number of subjects in the fake datasets to speed up the tests. --- moabb/tests/test_benchmark.py | 22 ++++++------- .../{SSVEP_CCA.yml => CCA-SSVEP.yml} | 0 moabb/tests/test_pipelines/CSP_SVM_grid.yml | 31 +++++++++++++++++++ moabb/tests/test_pipelines/WTRCSP.py | 11 +++++++ moabb/tests/test_pipelines/XdawnCov_MDM.yml | 14 +++++++++ 5 files changed, 67 insertions(+), 11 deletions(-) rename moabb/tests/test_pipelines/{SSVEP_CCA.yml => CCA-SSVEP.yml} (100%) create mode 100644 moabb/tests/test_pipelines/CSP_SVM_grid.yml create mode 100644 moabb/tests/test_pipelines/WTRCSP.py create mode 100644 moabb/tests/test_pipelines/XdawnCov_MDM.yml diff --git a/moabb/tests/test_benchmark.py b/moabb/tests/test_benchmark.py index 5425c1b3a..dacbc1875 100644 --- a/moabb/tests/test_benchmark.py +++ b/moabb/tests/test_benchmark.py @@ -23,28 +23,28 @@ def test_benchmark_strdataset(self): pipelines=str(self.pp_dir), evaluations=["WithinSession"], include_datasets=[ - "FakeDataset-imagery-10-2--60-60--120-120--lefthand-righthand--c3-cz-c4", - "FakeDataset-p300-10-2--60-60--120-120--target-nontarget--c3-cz-c4", - "FakeDataset-ssvep-10-2--60-60--120-120--13-15--c3-cz-c4", - "FakeDataset-cvep-10-2--60-60--120-120--10-00--c3-cz-c4", + "FakeDataset-imagery-2-2--60-60--120-120--lefthand-righthand--c3-cz-c4", + "FakeDataset-p300-2-2--60-60--120-120--target-nontarget--c3-cz-c4", + "FakeDataset-ssvep-2-2--60-60--120-120--13-15--c3-cz-c4", + "FakeDataset-cvep-2-2--60-60--120-120--10-00--c3-cz-c4", ], overwrite=True, ) - assert len(res) == 80 + assert len(res) == 24 def test_benchmark_objdataset(self): res = benchmark( pipelines=str(self.pp_dir), evaluations=["WithinSession"], include_datasets=[ - FakeDataset(["left_hand", "right_hand"], paradigm="imagery"), - FakeDataset(["Target", "NonTarget"], paradigm="p300"), - FakeDataset(["13", "15"], paradigm="ssvep"), - FakeDataset(["1.0", "0.0"], paradigm="cvep"), + FakeDataset(["left_hand", "right_hand"], paradigm="imagery", n_subjects=2), + FakeDataset(["Target", "NonTarget"], paradigm="p300", n_subjects=2), + FakeDataset(["13", "15"], paradigm="ssvep", n_subjects=2), + FakeDataset(["1.0", "0.0"], paradigm="cvep", n_subjects=2), ], overwrite=True, ) - assert len(res) == 80 + assert len(res) == 24 def test_nodataset(self): with pytest.raises(ValueError): @@ -61,7 +61,7 @@ def test_selectparadigm(self): paradigms=["FakeImageryParadigm"], overwrite=True, ) - assert len(res) == 40 + assert len(res) == 16 def test_include_exclude(self): with pytest.raises(AttributeError): diff --git a/moabb/tests/test_pipelines/SSVEP_CCA.yml b/moabb/tests/test_pipelines/CCA-SSVEP.yml similarity index 100% rename from moabb/tests/test_pipelines/SSVEP_CCA.yml rename to moabb/tests/test_pipelines/CCA-SSVEP.yml diff --git a/moabb/tests/test_pipelines/CSP_SVM_grid.yml b/moabb/tests/test_pipelines/CSP_SVM_grid.yml new file mode 100644 index 000000000..2486b53f8 --- /dev/null +++ b/moabb/tests/test_pipelines/CSP_SVM_grid.yml @@ -0,0 +1,31 @@ +name: CSP + SVM Grid + +paradigms: + - FakeImageryParadigm + +pipeline: + - name: Covariances + from: pyriemann.estimation + parameters: + estimator: oas + + - name: CSP + from: pyriemann.spatialfilters + parameters: + nfilter: 6 + + - name: SVC + from: sklearn.svm + parameters: + kernel: "linear" + +param_grid: + csp__nfilter: + - 2 + - 4 + - 6 + svc__C: + - 1 + svc__kernel: + - "rbf" + - "linear" diff --git a/moabb/tests/test_pipelines/WTRCSP.py b/moabb/tests/test_pipelines/WTRCSP.py new file mode 100644 index 000000000..05afc42c0 --- /dev/null +++ b/moabb/tests/test_pipelines/WTRCSP.py @@ -0,0 +1,11 @@ +from pyriemann.estimation import Covariances +from sklearn.discriminant_analysis import LinearDiscriminantAnalysis +from sklearn.pipeline import make_pipeline + +from moabb.pipelines.csp import TRCSP + + +pipe = make_pipeline(Covariances("scm"), TRCSP(nfilter=6), LinearDiscriminantAnalysis()) + +# this is what will be loaded +PIPELINE = {"name": "TRCSP + LDA", "paradigms": ["FakeImageryParadigm"], "pipeline": pipe} diff --git a/moabb/tests/test_pipelines/XdawnCov_MDM.yml b/moabb/tests/test_pipelines/XdawnCov_MDM.yml new file mode 100644 index 000000000..12527feda --- /dev/null +++ b/moabb/tests/test_pipelines/XdawnCov_MDM.yml @@ -0,0 +1,14 @@ +name: XdawnCovariances + MDM + +paradigms: + - FakeP300Paradigm + +pipeline: + - name: XdawnCovariances + from: pyriemann.estimation + parameters: + estimator: oas + xdawn_estimator: scm + + - name: MDM + from: pyriemann.classification From 7d24c29c38e90cbd9793fb582ce2185811d3988a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 1 Aug 2025 11:31:48 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks --- moabb/tests/test_benchmark.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/moabb/tests/test_benchmark.py b/moabb/tests/test_benchmark.py index dacbc1875..b307b38b4 100644 --- a/moabb/tests/test_benchmark.py +++ b/moabb/tests/test_benchmark.py @@ -37,7 +37,9 @@ def test_benchmark_objdataset(self): pipelines=str(self.pp_dir), evaluations=["WithinSession"], include_datasets=[ - FakeDataset(["left_hand", "right_hand"], paradigm="imagery", n_subjects=2), + FakeDataset( + ["left_hand", "right_hand"], paradigm="imagery", n_subjects=2 + ), FakeDataset(["Target", "NonTarget"], paradigm="p300", n_subjects=2), FakeDataset(["13", "15"], paradigm="ssvep", n_subjects=2), FakeDataset(["1.0", "0.0"], paradigm="cvep", n_subjects=2),