Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
7dcda25
Update dependencies
PierreGtch Jun 22, 2023
3a03c98
First draft (cant handle multi bands)
PierreGtch Jun 23, 2023
d5510f7
Fix process_raw when multiple filters
PierreGtch Jun 24, 2023
f5b79f5
Reorganise structure
PierreGtch Jun 24, 2023
9bbb1ae
Fix consistency
PierreGtch Jun 24, 2023
bf3afda
Change logic
PierreGtch Jun 24, 2023
4a28f6d
Merge branch 'develop' into disk-cache
bruAristimunha Jun 26, 2023
367647b
Use BIDSPath.rm
PierreGtch Jun 30, 2023
cbf46aa
Fix filter missing key padlen
PierreGtch Jun 30, 2023
14a0527
Fix __le__ comparison with None
PierreGtch Jun 30, 2023
cc4b651
Fix test type
PierreGtch Jun 30, 2023
74fa4b2
Fix make dataset description missing directory
PierreGtch Jun 30, 2023
aa35b26
Update FakeDataset code to have a unique cache
PierreGtch Jun 30, 2023
4743469
Create temp dir for FakeDataset
PierreGtch Jun 30, 2023
afddf54
Update test cache dataset
PierreGtch Jun 30, 2023
7f84cd0
Restore old picks
PierreGtch Jun 30, 2023
d9c7dc0
Fix fakedataset key
PierreGtch Jun 30, 2023
0cf357d
Add datetime now to bids
PierreGtch Jun 30, 2023
10e5678
Merge branch 'develop' into disk-cache
bruAristimunha Jul 4, 2023
4038519
Use dict to pass parameters
PierreGtch Jul 5, 2023
e50c9b7
Remove duplicate line
PierreGtch Jul 5, 2023
5aad788
Update usage
PierreGtch Jul 5, 2023
eae36a6
Use pipeline to process raws
PierreGtch Jul 5, 2023
fd565cb
Add verbose param
PierreGtch Jul 5, 2023
4b4ded0
Fix prepare_dataset
PierreGtch Jul 5, 2023
633bb00
Only filter and keep eeg channels (not stim) and fix corresponding tests
PierreGtch Jul 5, 2023
88f0357
More informative message when save fails
PierreGtch Jul 5, 2023
84e1b4d
Fix python 3.8 syntax
PierreGtch Jul 5, 2023
20b4629
Fix removeprefix missing in python 3.8
PierreGtch Jul 5, 2023
6b1ab91
Fix unexplained bug with resting paradigm
PierreGtch Jul 5, 2023
bb9c016
Merge branch 'develop' into disk-cache
bruAristimunha Jul 8, 2023
0db47d6
Fixing test_fake_dataset
bruAristimunha Jul 8, 2023
e39a93a
Fixing test_fake_dataset
bruAristimunha Jul 8, 2023
98b5448
Add possibility to also save epochs and arrays
PierreGtch Jul 11, 2023
585b565
Improve warning
PierreGtch Jul 13, 2023
8c88349
Move preprocessing steps into pipelines
PierreGtch Jul 13, 2023
7822a49
Update BaseParadigm.get_data
PierreGtch Jul 14, 2023
dca3903
Restructure base paradigm, Fixes #425
PierreGtch Jul 14, 2023
0514ce0
get events before RawToEpochs pipeline
PierreGtch Jul 14, 2023
39a165e
Add FixedIntervalWindowsProcessing, Closes #424
PierreGtch Jul 14, 2023
129348f
Merge branch 'NeuroTechX:develop' into disk-cache
PierreGtch Jul 14, 2023
86a38c5
Fix process_raw in P300 special case
PierreGtch Jul 14, 2023
c232487
Catch empty epochs
PierreGtch Jul 14, 2023
6bc0131
Fix tuple type for python 3.8
PierreGtch Jul 14, 2023
10846f0
Pass events instead of labels with arrays
PierreGtch Jul 14, 2023
3f843c7
Add test for fixed interval windows
PierreGtch Jul 14, 2023
2755199
Fix test of empty pipeline case
PierreGtch Jul 19, 2023
f232601
Fix stop offset of fixed interval epoching
PierreGtch Jul 19, 2023
8f1c47b
Add FilterBankFixedIntervalWindowsProcessing
PierreGtch Jul 19, 2023
cc3aa00
Always overwrite meas date
PierreGtch Jul 19, 2023
d5bd2ce
Add example_fixed_interval_windows.py
PierreGtch Jul 19, 2023
e02e363
Add example_bids_conversion.py
PierreGtch Jul 19, 2023
a09717e
remove separation
PierreGtch Jul 19, 2023
c596604
Simplify test cache
PierreGtch Jul 20, 2023
385ebc4
Improve BIDS log
PierreGtch Jul 20, 2023
0372120
Fix missing annotations in stim datasets
PierreGtch Jul 20, 2023
504e95c
Update cache test
PierreGtch Jul 20, 2023
fec6db2
Add paradigm cache test
PierreGtch Jul 20, 2023
909b148
Add cache example
PierreGtch Jul 20, 2023
96a7dd2
Fix TypeError python 3.8
PierreGtch Jul 20, 2023
74110fd
Merge branch 'NeuroTechX:develop' into disk-cache
PierreGtch Jul 21, 2023
12e39dc
Fix TypeError python 3.8
PierreGtch Jul 21, 2023
95bc281
Fix TypeError python 3.8
PierreGtch Jul 21, 2023
aabe9bb
Simplify "empty" processing pipeline case
PierreGtch Jul 21, 2023
c9a62fb
Un-break "empty" processing pipeline case
PierreGtch Jul 21, 2023
8a87cf7
Comment benchmark tests
PierreGtch Jul 21, 2023
9ecad11
Fix dataset list overwritten in benchmark
PierreGtch Jul 21, 2023
3381963
Fix benchmark test
PierreGtch Jul 21, 2023
3310cd2
Remove unnecessary test exceptions
PierreGtch Jul 21, 2023
b05b456
Remove unused function
PierreGtch Jul 21, 2023
5730da4
Update whats_new.rst
PierreGtch Jul 21, 2023
52df723
Clean CacheConfig docstring
PierreGtch Jul 21, 2023
ba86fa7
Add new paradigms to doc
PierreGtch Jul 21, 2023
59c7ec8
Fix docs synthax
PierreGtch Jul 21, 2023
cce0d6b
Rename BIDS example
PierreGtch Jul 21, 2023
7fbc6a8
Rename cache example
PierreGtch Jul 21, 2023
fd98870
Rename interval processing example
PierreGtch Jul 21, 2023
dd678d2
Fix example links
PierreGtch Jul 21, 2023
71cb7f9
Add CacheConfig to doc
PierreGtch Jul 21, 2023
ff8d335
Fix doc typos
PierreGtch Jul 26, 2023
f242507
Merge branch 'develop' into disk-cache
bruAristimunha Jul 31, 2023
91ad0bc
Fixing typos
bruAristimunha Jul 31, 2023
2e443f3
Updating the tutorial with my review
bruAristimunha Jul 31, 2023
1af4f18
Perfect tutorial
bruAristimunha Jul 31, 2023
842efa7
small typos and details, nice tutorial
bruAristimunha Jul 31, 2023
5d1496e
Fixing 79 space
bruAristimunha Jul 31, 2023
7e754b6
Fixing formation
bruAristimunha Jul 31, 2023
53750c7
Adding more comments and docs
bruAristimunha Jul 31, 2023
20c9ff3
fixing E501
bruAristimunha Jul 31, 2023
a717dd6
pylinting
bruAristimunha Jul 31, 2023
6690148
fixing line size
bruAristimunha Jul 31, 2023
50b4895
pylinter
bruAristimunha Jul 31, 2023
c91089b
Fixing docs
bruAristimunha Jul 31, 2023
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
1 change: 1 addition & 0 deletions docs/source/datasets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ Base & Utils
:template: class.rst

base.BaseDataset
base.CacheConfig
fake.FakeDataset
fake.FakeVirtualRealityDataset

Expand Down
25 changes: 19 additions & 6 deletions docs/source/paradigms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ P300 Paradigms
:toctree: generated/
:template: class.rst

SinglePass
P300
SinglePass
P300

---------------
SSVEP Paradigms
Expand All @@ -39,8 +39,19 @@ SSVEP Paradigms
:toctree: generated/
:template: class.rst

SSVEP
FilterBankSSVEP
SSVEP
FilterBankSSVEP

--------------
Fixed Interval Windows Processings
--------------

.. autosummary::
:toctree: generated/
:template: class.rst

FixedIntervalWindowsProcessing
FilterBankFixedIntervalWindowsProcessing

------------
Base & Utils
Expand All @@ -53,6 +64,8 @@ Base & Utils
motor_imagery.BaseMotorImagery
motor_imagery.SinglePass
motor_imagery.FilterBank
p300.BaseP300
ssvep.BaseSSVEP
p300.BaseP300
ssvep.BaseSSVEP
BaseFixedIntervalWindowsProcessing
base.BaseParadigm
base.BaseProcessing
21 changes: 16 additions & 5 deletions docs/source/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,36 @@ Enhancements
- Adding example to load different type of models (:gh:`401` by `Bruno Aristimunha`_ and `Igor Carrara`_)
- Add resting state paradigm with dataset and example (:gh:`400` by `Gregoire Cattan`_ and `Pedro L. C. Rodrigues`_)
- Speeding the augmentation method by 400% with NumPy vectorization (:gh:`419` by `Bruno Aristimunha`_)
- Improving the review processing with more pre-commit bots (:gh:`434` by `Bruno Aristimunha`_)
- Add possibility to convert datasets to BIDS, plus `example <examples/example_bids_conversion.py>`_ (PR :gh:`408`, PR :gh:`391` by `Pierre Guetschel`_ and `Bruno Aristimunha`_)
- Allow caching intermediate processing steps on disk, plus `example <examples/example_disk_cache.py>`_ (PR :gh:`408`, issue :gh:`385` by `Pierre Guetschel`_)
- Restructure the paradigms and datasets to move all preprocessing steps to :mod:`moabb.datasets.preprocessing` and as sklearn pipelines (PR :gh:`408` by `Pierre Guetschel`_)
- Add :func:`moabb.paradigms.FixedIntervalWindowsProcessing` and :func:`moabb.paradigms.FilterBankFixedIntervalWindowsProcessing`, plus `example <examples/example_fixed_interval_windows.py>`_ (PR :gh:`408`, issue :gh:`424` by `Pierre Guetschel`_)
- Define :func:`moabb.paradigms.base.BaseProcessing`, common parent to :func:`moabb.paradigms.base.BaseParadigm` and :func:`moabb.paradigms.BaseFixedIntervalWindowsProcessing` (PR :gh:`408` by `Pierre Guetschel`_)
- Allow passing a fixed processing pipeline to :func:`moabb.paradigms.base.BaseProcessing.get_data` and cache its result on disk (PR :gh:`408`, issue :gh:`367` by `Pierre Guetschel`_)
- Update :func:`moabb.datasets.fake.FakeDataset`'s code to be unique for each parameter combination (PR :gh:`408` by `Pierre Guetschel`_)
- Systematically set the annotations when loading data, eventually using the stim channel (PR :gh:`408` by `Pierre Guetschel`_)
- Allow :func:`moabb.datasets.utils.dataset_search` to search across paradigms ``paradigm=None`` (PR :gh:`408` by `Pierre Guetschel`_)
- Improving the review processing with more pre-commit bots (:gh:`435` by `Bruno Aristimunha`_)

Bugs
~~~~

- Restore 3 subject from Cho2017 (:gh:`392` by `Igor Carrara`_ and `Sylvain Chevallier`_)
- Correct downloading with VirtualReality BrainInvaders dataset (:gh:`393` by `Gregoire Cattan`_)
- Rename event `substraction` to `subtraction` in :func:`moabb.dataset.Shin2017B` (:gh:`397` by `Pierre Guetschel`_)
- Save parameters of :func:`moabb.dataset.PhysionetMI` (:gh:`403` by `Pierre Guetschel`_)
- Rename event `substraction` to `subtraction` in :func:`moabb.datasets.Shin2017B` (:gh:`397` by `Pierre Guetschel`_)
- Save parameters of :func:`moabb.datasets.PhysionetMI` (:gh:`403` by `Pierre Guetschel`_)
- Fixing issue with parallel evaluation (:gh:`401` by `Bruno Aristimunha`_ and `Igor Carrara`_)
- Fixing SSLError from BCI competition IV (:gh:`404` by `Bruno Aristimunha`_)
- Fixing :func:`moabb.dataset.bnci.MNEBNCI.data_path` that returned the data itself instead of paths (:gh:`412` by `Pierre Guetschel`_)
- Fixing :func:`moabb.datasets.bnci.MNEBNCI.data_path` that returned the data itself instead of paths (:gh:`412` by `Pierre Guetschel`_)
- Adding :func:`moabb.datasets.fake` in the init file to use in braindecode object (:gh:`414` by `Bruno Aristimunha`_)
- Fixing the parallel download issue when the dataset have the same directory (:gh:`421` by `Sara Sedlar`_)
- Fixing fixes the problem with the annotation loading for the P300 datasets Sosulski2019, Huebner2017 and Huebner2018 (:gh:`396` by `Sara Sedlar`_)
- Removing the print in the dataset list (:gh:`423` by `Bruno Aristimunha`_)
- Fixing bug in :func:`moabb.pipeline.utils_pytorch.BraindecodeDatasetLoader` where incorrect y was used in transform calls (:gh:`426` by `Gabriel Schwartz`_)
- Fixing one test in :func:`moabb.pipeline.utils_pytorch.BraindecodeDatasetLoader` (:gh:`426` by `Bruno Aristimunha`_)

- Fix :func:`moabb.benchmark` overwriting ``include_datasets`` list (:gh:`408` by `Pierre Guetschel`_)
- Fix :func:`moabb.paradigms.base.BaseParadigm` using attributes before defining them (PR :gh:`408`, issue :gh:`425` by `Pierre Guetschel`_)
- Fix :func:`moabb.paradigms.FakeImageryParadigm`, :func:`moabb.paradigms.FakeP300Paradigm` and :func:`moabb.paradigms.FakeSSVEPParadigm` ``is_valid`` methods to only accept the correct datasets (PR :gh:`408` by `Pierre Guetschel`_)

API changes
~~~~~~~~~~~
Expand Down
133 changes: 133 additions & 0 deletions examples/plot_bids_conversion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
"""
===============================
Convert a MOABB dataset to BIDS
===============================

The Brain Imaging Data Structure (BIDS) format
is standard for storing neuroimaging data.
It follows fixed principles to facilitate the
sharing of neuroimaging data between researchers.

The MOABB library allows to convert any MOABB dataset to
BIDS [1]_ and [2]_.

In this example, we will convert the AlexMI dataset to BIDS using the
option `cache_config=dict(path=temp_dir, save_raw=True)` of the get_data
method from the dataset object.

This will automatically save the raw data in the BIDS format and allow to use
a cache for the next time the dataset is used.

We will use the AlexMI dataset [3]_, one of the smallest in
people and one that can be downloaded quickly.

References
-----------

.. [1] Pernet, C.R., Appelhoff, S., Gorgolewski, K.J. et al. EEG-BIDS,
An extension to the brain imaging data structure for
electroencephalography. Sci Data 6, 103 (2019).
https://doi.org/10.1038/s41597-019-0104-8

.. [2] Appelhoff et al., (2019). MNE-BIDS: Organizing electrophysiological
data into the BIDS format and facilitating their analysis.
Journal of Open Source Software, 4(44), 1896,
https://doi.org/10.21105/joss.01896

.. [3] Barachant, A., 2012. Commande robuste d'un effecteur par une
interface cerveau machine EEG asynchrone (Doctoral dissertation,
Université de Grenoble).
https://tel.archives-ouvertes.fr/tel-01196752

"""
# Authors: Pierre Guetschel <[email protected]>
#
# License: BSD (3-clause)

import shutil
import tempfile
from pathlib import Path

import mne

from moabb import set_log_level
from moabb.datasets import AlexMI


set_log_level("info")

###############################################################################
# Basic usage
# -----------
#
# Here, we will save the BIDS version of the dataset in a temporary folder
temp_dir = Path(tempfile.mkdtemp())
# The conversion of any MOABB dataset to a BIDS-compliant structure can be done
# by simply calling its ``get_data`` method and using the ``cache_config``
# parameter. This parameter is a dictionary.
dataset = AlexMI()
_ = dataset.get_data(cache_config=dict(path=temp_dir, save_raw=True))


###############################################################################
# Before / after folder structure
# -----------------------------
#
# To investigate what was saved, we will first define a function to print
# the folder structure of a given path:
def print_tree(p: Path, last=True, header=""):
elbow = "└──"
pipe = "│ "
tee = "├──"
blank = " "
print(header + (elbow if last else tee) + p.name)
if p.is_dir():
children = list(p.iterdir())
for i, c in enumerate(children):
print_tree(
c, header=header + (blank if last else pipe), last=i == len(children) - 1
)


###############################################################################
# Now, we will retrieve the location of the original dataset. It is stored
# in the MNE data directory, which can be found with the ``"MNE_DATA"`` key:
mne_data = Path(mne.get_config("MNE_DATA"))
print(f"MNE data directory: {mne_data}")

###############################################################################
# Now, we can print the folder structure of the original dataset:
print("Before conversion:")
print_tree(mne_data / "MNE-alexeeg-data")

###############################################################################
# As we can see, before conversion, all the data (i.e. from all subjects,
# sessions and runs) is stored in a single folder. This follows no particular
# standard and can vary from one dataset to another.
#
# After conversion, the data is stored in a BIDS-compliant way:
print("After conversion:")
print_tree(temp_dir / "MNE-alexandre motor imagery-bids-cache")

###############################################################################
# In the BIDS version of our dataset, the raw files are saved in EDF.
# The data is organized in a hierarchy of folders,
# starting with the subjects, then the sessions, and then the runs. Metadata
# files are stored to describe the data. For more details on the BIDS
# structure, please refer to the `BIDS website <https://bids.neuroimaging.io>`_
# and the `BIDS spec <https://bids-specification.readthedocs.io/en/stable/>`_.
#
# Under the hood, saving datasets to BIDS is done through the caching system
# of MOABB. Only raw EEG files are officially supported by the BIDS
# specification.
# However, MOABB's caching mechanism also offers the possibility to save
# the data in a pseudo-BIDS after different preprocessing steps.
# In particular, we can save :class:`mne.Epochs` and ``np.ndarray`` objects.
# For more details on the caching system,
# please refer to the tutorial :doc:`./plot_disk_cache`.
#
# Cleanup
# -------
#
# Finally, we can delete the temporary folder:
shutil.rmtree(temp_dir)
Loading