Skip to content

Commit af9f5de

Browse files
Merge branch 'develop' into add-weibo2014-test
2 parents 68d37d6 + dba8a44 commit af9f5de

File tree

15 files changed

+901
-109
lines changed

15 files changed

+901
-109
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ exclude: ".*svg"
1515

1616
repos:
1717
- repo: https://github.com/pre-commit/pre-commit-hooks
18-
rev: v5.0.0
18+
rev: v6.0.0
1919
hooks:
2020
- id: check-yaml
2121
- id: check-json
@@ -34,22 +34,22 @@ repos:
3434
args: [ "--autofix", "--no-sort-keys", "--indent=4" ]
3535

3636

37-
- repo: https://github.com/psf/black
38-
rev: 25.1.0
37+
- repo: https://github.com/psf/black-pre-commit-mirror
38+
rev: 25.9.0
3939
hooks:
4040
- id: black
4141
language_version: python3
4242
args: [ --line-length=90, --target-version=py38 ]
4343

4444
- repo: https://github.com/asottile/blacken-docs
45-
rev: 1.19.1
45+
rev: 1.20.0
4646
hooks:
4747
- id: blacken-docs
4848
additional_dependencies: [black==23.3.0]
4949
exclude: ^.github/
5050

5151
- repo: https://github.com/PyCQA/isort
52-
rev: 6.0.1
52+
rev: 6.1.0
5353
hooks:
5454
- id: isort
5555

@@ -69,7 +69,7 @@ repos:
6969
exclude: ^docs/ | ^setup\.py$ |
7070

7171
- repo: https://github.com/astral-sh/ruff-pre-commit
72-
rev: v0.12.2
72+
rev: v0.13.3
7373
hooks:
7474
- id: ruff
7575
args: [ --fix, --exit-non-zero-on-fix, --ignore, E501 ]

docs/source/api.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ ERP/P300 Datasets
8888
ErpCore2021_N170
8989
ErpCore2021_N400
9090
ErpCore2021_P3
91+
Kojima2024A
92+
Kojima2024B
9193

9294
--------------
9395
SSVEP Datasets

docs/source/whats_new.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
What's new
66
==========
77

8+
89
.. NOTE: there are 3 separate sections for changes, based on type:
910
1011
- "Enhancements" for new features
@@ -18,11 +19,13 @@ Develop branch - 1.4 (dev)
1819
--------------------------------------
1920
Enhancements
2021
~~~~~~~~~~~~
21-
22+
- Adding :class:`moabb.datasets.Kojima2024A` (:gh:`807` by `Simon Kojima`_)
23+
- Adding :class:`moabb.datasets.Kojima2024B` (:gh:`806` by `Simon Kojima`_)
2224
- Add new dataset :class:`moabb.datasets.BNCI2003_IVa` dataset (:gh:`811` by `Griffin Keeler`_)
2325

2426
Bugs
2527
~~~~
28+
- Fixing label swapped issue with :class:`moabb.datasets.Kalunga2016` dataset (:gh:`814` by `Griffin Keeler`_)
2629

2730
API changes
2831
~~~~~~~~~~~
@@ -596,4 +599,6 @@ API changes
596599
.. _Radovan Vodila: https://github.com/rvodila
597600
.. _Ulysse Durand: https://github.com/UlysseDurand
598601
.. _Lucas Heck: https://github.com/lucas-heck
602+
.. _Simon Kojima: https://github.com/simonkojima
599603
.. _Griffin Keeler: https://github.com/griffinkeeler
604+
.. _ Kosei Nakada: https://github.com/ponpopon

moabb/datasets/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
from .gigadb import Cho2017
7373
from .hinss2021 import Hinss2021
7474
from .huebner_llp import Huebner2017, Huebner2018
75+
from .kojima2024a import Kojima2024A
76+
from .kojima2024b import Kojima2024B
7577
from .Lee2019 import Lee2019_ERP, Lee2019_MI, Lee2019_SSVEP
7678
from .liu2024 import Liu2024
7779
from .mpi_mi import MunichMI # noqa: F401

moabb/datasets/base.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from typing import Any, Dict, Union
1414

1515
import mne_bids
16+
import numpy as np
1617
import pandas as pd
1718
from sklearn.pipeline import Pipeline
1819

@@ -404,6 +405,50 @@ def _create_process_pipeline(self):
404405
]
405406
)
406407

408+
def _block_rep(self, block, repetition):
409+
raise NotImplementedError()
410+
411+
def get_block_repetition(self, paradigm, subjects, block_list, repetition_list):
412+
"""Select data for all provided subjects, blocks and repetitions.
413+
414+
subject -> session -> run -> block -> repetition
415+
416+
See also
417+
--------
418+
BaseDataset.get_data
419+
420+
Parameters
421+
----------
422+
subjects: List of int
423+
List of subject number
424+
block_list: List of int
425+
List of block number
426+
repetition_list: List of int
427+
List of repetition number inside a block
428+
429+
Returns
430+
-------
431+
data: Dict
432+
dict containing the raw data
433+
"""
434+
X, labels, meta = paradigm.get_data(self, subjects)
435+
X_select = []
436+
labels_select = []
437+
meta_select = []
438+
for block in block_list:
439+
for repetition in repetition_list:
440+
run = self._block_rep(block, repetition)
441+
X_select.append(X[meta["run"] == run])
442+
labels_select.append(labels[meta["run"] == run])
443+
meta_select.append(meta[meta["run"] == run])
444+
X_select = np.concatenate(X_select)
445+
labels_select = np.concatenate(labels_select)
446+
meta_select = np.concatenate(meta_select)
447+
df = pd.DataFrame(meta_select, columns=meta.columns)
448+
meta_select = df
449+
450+
return X_select, labels_select, meta_select
451+
407452
def get_data(
408453
self,
409454
subjects=None,

moabb/datasets/braininvaders.py

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import mne
99
import numpy as np
10-
import pandas as pd
1110
import yaml
1211
from mne.channels import make_standard_montage
1312
from mne.utils import _open_lock
@@ -852,50 +851,5 @@ def data_path(
852851
):
853852
return _bi_data_path(self, subject, path, force_update, update_path, verbose)
854853

855-
def get_block_repetition(self, paradigm, subjects, block_list, repetition_list):
856-
"""Select data for all provided subjects, blocks and repetitions. Each
857-
subject has 12 blocks of 5 repetitions.
858-
859-
The returned data is a dictionary with the following structure::
860-
861-
data = {'subject_id' :
862-
{'session_id':
863-
{'run_id': raw}
864-
}
865-
}
866-
867-
See also
868-
--------
869-
BaseDataset.get_data
870-
871-
Parameters
872-
----------
873-
subjects: List of int
874-
List of subject number
875-
block_list: List of int
876-
List of block number (from 0 to 11)
877-
repetition_list: List of int
878-
List of repetition number inside a block (from 0 to 4)
879-
880-
Returns
881-
-------
882-
data: Dict
883-
dict containing the raw data
884-
"""
885-
X, labels, meta = paradigm.get_data(self, subjects)
886-
X_select = []
887-
labels_select = []
888-
meta_select = []
889-
for block in block_list:
890-
for repetition in repetition_list:
891-
run = block_rep(block, repetition, self.n_repetitions)
892-
X_select.append(X[meta["run"] == run])
893-
labels_select.append(labels[meta["run"] == run])
894-
meta_select.append(meta[meta["run"] == run])
895-
X_select = np.concatenate(X_select)
896-
labels_select = np.concatenate(labels_select)
897-
meta_select = np.concatenate(meta_select)
898-
df = pd.DataFrame(meta_select, columns=meta.columns)
899-
meta_select = df
900-
901-
return X_select, labels_select, meta_select
854+
def _block_rep(self, block, repetition):
855+
return block_rep(block, repetition, self.n_repetitions)

moabb/datasets/fake.py

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from mne.io import RawArray
99

1010
from moabb.datasets.base import BaseDataset
11-
from moabb.datasets.braininvaders import Cattan2019_VR
1211
from moabb.datasets.utils import block_rep
1312

1413

@@ -197,37 +196,5 @@ def _get_single_subject_data(self, subject):
197196
] = self._generate_raw(n, d)
198197
return data
199198

200-
def get_block_repetition(self, paradigm, subjects, block_list, repetition_list):
201-
"""Select data for all provided subjects, blocks and repetitions. Each
202-
subject has 5 blocks of 12 repetitions.
203-
204-
The returned data is a dictionary with the following structure::
205-
206-
data = {'subject_id' :
207-
{'session_id':
208-
{'run_id': raw}
209-
}
210-
}
211-
212-
See also
213-
--------
214-
BaseDataset.get_data
215-
Cattan2019_VR.get_block_repetition
216-
217-
Parameters
218-
----------
219-
subjects: List of int
220-
List of subject number
221-
block_list: List of int
222-
List of block number (from 1 to 5)
223-
repetition_list: List of int
224-
List of repetition number inside a block (from 1 to 12)
225-
226-
Returns
227-
-------
228-
data: Dict
229-
dict containing the raw data
230-
"""
231-
return Cattan2019_VR.get_block_repetition(
232-
self, paradigm, subjects, block_list, repetition_list
233-
)
199+
def _block_rep(self, block, repetition):
200+
return block_rep(block, repetition, self.n_repetitions)

0 commit comments

Comments
 (0)