pybemobil 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pybemobil-0.1.0/.gitignore +21 -0
- pybemobil-0.1.0/CITATION.cff +48 -0
- pybemobil-0.1.0/LICENSE +28 -0
- pybemobil-0.1.0/PKG-INFO +178 -0
- pybemobil-0.1.0/README.md +110 -0
- pybemobil-0.1.0/doc/Makefile +15 -0
- pybemobil-0.1.0/doc/make.bat +35 -0
- pybemobil-0.1.0/doc/source/_static/custom.css +18 -0
- pybemobil-0.1.0/doc/source/api/io.rst +56 -0
- pybemobil-0.1.0/doc/source/api/preproc.rst +153 -0
- pybemobil-0.1.0/doc/source/api/viz.rst +59 -0
- pybemobil-0.1.0/doc/source/conf.py +88 -0
- pybemobil-0.1.0/doc/source/guides/bemobil.rst +197 -0
- pybemobil-0.1.0/doc/source/index.rst +132 -0
- pybemobil-0.1.0/doc/source/whats_new.rst +50 -0
- pybemobil-0.1.0/pybemobil/__init__.py +13 -0
- pybemobil-0.1.0/pybemobil/data/montages/README.md +19 -0
- pybemobil-0.1.0/pybemobil/data/montages/standard_MoBI_128.elc +260 -0
- pybemobil-0.1.0/pybemobil/data/montages/standard_MoBI_128_corrected.fif +0 -0
- pybemobil-0.1.0/pybemobil/examples/bids_export_example.py +107 -0
- pybemobil-0.1.0/pybemobil/examples/motion_processing.py +101 -0
- pybemobil-0.1.0/pybemobil/examples/plotting.py +327 -0
- pybemobil-0.1.0/pybemobil/examples/preprocessing.py +255 -0
- pybemobil-0.1.0/pybemobil/examples/xdf_loading.py +103 -0
- pybemobil-0.1.0/pybemobil/io/README.md +378 -0
- pybemobil-0.1.0/pybemobil/io/__init__.py +19 -0
- pybemobil-0.1.0/pybemobil/io/alignment.py +417 -0
- pybemobil-0.1.0/pybemobil/io/bids_export.py +255 -0
- pybemobil-0.1.0/pybemobil/io/utils.py +27 -0
- pybemobil-0.1.0/pybemobil/io/xdf.py +760 -0
- pybemobil-0.1.0/pybemobil/preproc/__init__.py +74 -0
- pybemobil-0.1.0/pybemobil/preproc/epoching.py +207 -0
- pybemobil-0.1.0/pybemobil/preproc/make_report.py +1152 -0
- pybemobil-0.1.0/pybemobil/preproc/motion.py +367 -0
- pybemobil-0.1.0/pybemobil/preproc/preprocessing.py +1536 -0
- pybemobil-0.1.0/pybemobil/preproc/utils.py +1142 -0
- pybemobil-0.1.0/pybemobil/viz/__init__.py +31 -0
- pybemobil-0.1.0/pybemobil/viz/plotting.py +1871 -0
- pybemobil-0.1.0/pybemobil/viz/utils.py +20 -0
- pybemobil-0.1.0/pyproject.toml +131 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
.ruff_cache
|
|
2
|
+
.vscode
|
|
3
|
+
__pycache__
|
|
4
|
+
junit-results.xml
|
|
5
|
+
.pytest_cache
|
|
6
|
+
dist
|
|
7
|
+
.coverage*
|
|
8
|
+
htmlcov
|
|
9
|
+
|
|
10
|
+
build/
|
|
11
|
+
*.spec
|
|
12
|
+
|
|
13
|
+
derivatives/
|
|
14
|
+
results/
|
|
15
|
+
reports/
|
|
16
|
+
qa_reports/
|
|
17
|
+
.claude/
|
|
18
|
+
.claude
|
|
19
|
+
|
|
20
|
+
pyrightconfig.json
|
|
21
|
+
doc/source/api/generated/
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: >-
|
|
3
|
+
If you use pybemobil, please cite it using the metadata below. pybemobil is
|
|
4
|
+
a Python implementation of the BeMoBIL pipeline; please consider also citing
|
|
5
|
+
the BeMoBIL pipeline paper listed under references.
|
|
6
|
+
title: "pybemobil: MoBI data loading, preprocessing, and visualization built on MNE-Python"
|
|
7
|
+
type: software
|
|
8
|
+
authors:
|
|
9
|
+
- family-names: Wieske
|
|
10
|
+
given-names: Roy Eric
|
|
11
|
+
email: eric.wieske@gmail.com
|
|
12
|
+
affiliation: Technische Universität Berlin
|
|
13
|
+
version: 0.1.0
|
|
14
|
+
date-released: 2026-10-19
|
|
15
|
+
license: BSD-3-Clause
|
|
16
|
+
repository-code: "https://github.com/BeMoBIL/pybemobil"
|
|
17
|
+
url: "https://bemobil.github.io/pybemobil/"
|
|
18
|
+
keywords:
|
|
19
|
+
- EEG
|
|
20
|
+
- mobile brain/body imaging
|
|
21
|
+
- MoBI
|
|
22
|
+
- MNE-Python
|
|
23
|
+
- preprocessing
|
|
24
|
+
references:
|
|
25
|
+
- type: article
|
|
26
|
+
title: "The BeMoBIL Pipeline for automated analyses of multimodal mobile brain and body imaging data"
|
|
27
|
+
authors:
|
|
28
|
+
- family-names: Klug
|
|
29
|
+
given-names: Marius
|
|
30
|
+
- family-names: Jeung
|
|
31
|
+
given-names: Sein
|
|
32
|
+
- family-names: Wunderlich
|
|
33
|
+
given-names: Anna
|
|
34
|
+
- family-names: Gehrke
|
|
35
|
+
given-names: Lukas
|
|
36
|
+
- family-names: Protzak
|
|
37
|
+
given-names: Janna
|
|
38
|
+
- family-names: Djebbara
|
|
39
|
+
given-names: Zakaria
|
|
40
|
+
- family-names: Argubi-Wollesen
|
|
41
|
+
given-names: Andreas
|
|
42
|
+
- family-names: Wollesen
|
|
43
|
+
given-names: Bettina
|
|
44
|
+
- family-names: Gramann
|
|
45
|
+
given-names: Klaus
|
|
46
|
+
journal: bioRxiv
|
|
47
|
+
year: 2022
|
|
48
|
+
doi: 10.1101/2022.09.29.510051
|
pybemobil-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026, Roy Eric Wieske and the pybemobil contributors
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
pybemobil-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: pybemobil
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MoBI data loading, preprocessing, and visualization built on MNE-Python
|
|
5
|
+
Project-URL: Bug Tracker, https://github.com/BeMoBIL/pybemobil/issues/
|
|
6
|
+
Project-URL: Documentation, https://bemobil.github.io/pybemobil/
|
|
7
|
+
Project-URL: Source Code, https://github.com/BeMoBIL/pybemobil/
|
|
8
|
+
Author-email: Roy Eric Wieske <eric.wieske@gmail.com>
|
|
9
|
+
Maintainer-email: Roy Eric Wieske <eric.wieske@gmail.com>
|
|
10
|
+
License-Expression: BSD-3-Clause
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: data analysis,eeg,eye-tracking,neuroscience
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Operating System :: MacOS
|
|
16
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
17
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
18
|
+
Classifier: Programming Language :: Python
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
|
|
24
|
+
Classifier: Topic :: Software Development
|
|
25
|
+
Requires-Python: >=3.11
|
|
26
|
+
Requires-Dist: matplotlib
|
|
27
|
+
Requires-Dist: meegkit
|
|
28
|
+
Requires-Dist: mne-bids>=0.18
|
|
29
|
+
Requires-Dist: mne-denoise
|
|
30
|
+
Requires-Dist: mne-faster
|
|
31
|
+
Requires-Dist: mne-icalabel>=0.8
|
|
32
|
+
Requires-Dist: mne>=1.13
|
|
33
|
+
Requires-Dist: nibabel
|
|
34
|
+
Requires-Dist: numpy
|
|
35
|
+
Requires-Dist: onnxruntime
|
|
36
|
+
Requires-Dist: pandas
|
|
37
|
+
Requires-Dist: pybv
|
|
38
|
+
Requires-Dist: pyprep>=0.8
|
|
39
|
+
Requires-Dist: python-picard
|
|
40
|
+
Requires-Dist: pyxdf
|
|
41
|
+
Requires-Dist: scikit-learn
|
|
42
|
+
Provides-Extra: dev
|
|
43
|
+
Requires-Dist: build; extra == 'dev'
|
|
44
|
+
Requires-Dist: ipykernel; extra == 'dev'
|
|
45
|
+
Requires-Dist: ipython; extra == 'dev'
|
|
46
|
+
Requires-Dist: jamica[jax]>=0.3; extra == 'dev'
|
|
47
|
+
Requires-Dist: pre-commit; extra == 'dev'
|
|
48
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
49
|
+
Requires-Dist: pytest-cov; extra == 'dev'
|
|
50
|
+
Requires-Dist: pytest-sugar; extra == 'dev'
|
|
51
|
+
Requires-Dist: pytest-xdist; extra == 'dev'
|
|
52
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
53
|
+
Requires-Dist: twine; extra == 'dev'
|
|
54
|
+
Provides-Extra: docs
|
|
55
|
+
Requires-Dist: numpydoc; extra == 'docs'
|
|
56
|
+
Requires-Dist: pydata-sphinx-theme>=0.15; extra == 'docs'
|
|
57
|
+
Requires-Dist: sphinx-copybutton; extra == 'docs'
|
|
58
|
+
Requires-Dist: sphinx>=7; extra == 'docs'
|
|
59
|
+
Provides-Extra: jamica
|
|
60
|
+
Requires-Dist: jamica[jax]>=0.3; extra == 'jamica'
|
|
61
|
+
Provides-Extra: test
|
|
62
|
+
Requires-Dist: jamica[jax]>=0.3; extra == 'test'
|
|
63
|
+
Requires-Dist: pytest; extra == 'test'
|
|
64
|
+
Requires-Dist: pytest-cov; extra == 'test'
|
|
65
|
+
Requires-Dist: pytest-sugar; extra == 'test'
|
|
66
|
+
Requires-Dist: pytest-xdist; extra == 'test'
|
|
67
|
+
Description-Content-Type: text/markdown
|
|
68
|
+
|
|
69
|
+
# pybemobil
|
|
70
|
+
|
|
71
|
+
MoBI data loading, preprocessing, and visualization built on MNE-Python.
|
|
72
|
+
|
|
73
|
+
## Structure
|
|
74
|
+
|
|
75
|
+
```md
|
|
76
|
+
pybemobil/
|
|
77
|
+
├── io/ # Data I/O
|
|
78
|
+
│ ├── xdf.py # XDFLoader: multimodal XDF loading, stream alignment
|
|
79
|
+
│ ├── alignment.py # align_stream_to_timestamps (timestamp-aware interpolation)
|
|
80
|
+
│ ├── bids_export.py # BIDS export wrappers around mne_bids
|
|
81
|
+
│ └── utils.py # I/O helpers
|
|
82
|
+
├── preproc/ # Preprocessing
|
|
83
|
+
│ ├── preprocessing.py # EEGPreprocessor: ZapLine -> bad ch -> filter -> ASR -> ICA pipeline
|
|
84
|
+
│ ├── epoching.py # EpochPreparer, stimulus renaming helpers
|
|
85
|
+
│ ├── motion.py # Rigid body kinematics (find, process, split)
|
|
86
|
+
│ └── utils.py # ASR, ZapLine, ICA, dipole fitting, provenance, misc
|
|
87
|
+
├── viz/ # Visualization
|
|
88
|
+
│ ├── plotting.py # ERP, PSD, and component plots
|
|
89
|
+
│ └── utils.py # Plot helpers
|
|
90
|
+
├── examples/ # Runnable example scripts
|
|
91
|
+
│ ├── preprocessing.py # Full EEG preprocessing walkthrough
|
|
92
|
+
│ ├── plotting.py # Visualization walkthrough (run preprocessing.py first)
|
|
93
|
+
│ ├── xdf_loading.py # XDF multimodal loading
|
|
94
|
+
│ ├── motion_processing.py # Rigid body kinematics
|
|
95
|
+
│ └── bids_export_example.py # BIDS export
|
|
96
|
+
└── data/
|
|
97
|
+
└── montages/ # EEG electrode montage files (.elc, .fif)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Modules
|
|
101
|
+
|
|
102
|
+
**`io`** - Load XDF multimodal recordings into MNE Raw objects, align auxiliary streams (ECG, gaze, EMG, EDA) to a common time grid, and export datasets to BIDS.
|
|
103
|
+
|
|
104
|
+
**`preproc`** - Full EEG preprocessing pipeline (bandpass, bad channel detection, ASR, ICA, dipole fitting), epoch preparation, and rigid body motion capture kinematics.
|
|
105
|
+
|
|
106
|
+
**`viz`** - ERP and PSD plotting utilities built on MNE and matplotlib.
|
|
107
|
+
|
|
108
|
+
**`examples`** - Self-contained scripts demonstrating major features. Run directly or open as notebooks (percent-format cells).
|
|
109
|
+
|
|
110
|
+
## Installation
|
|
111
|
+
|
|
112
|
+
Install the latest release from PyPI:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
pip install pybemobil
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
To also install the JAX-accelerated AMICA backend (the default ICA method, which falls back to Picard when this is missing):
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
pip install "pybemobil[jamica]"
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Alternatively:
|
|
125
|
+
|
|
126
|
+
- **Latest development version** from GitHub:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
pip install git+https://github.com/BeMoBIL/pybemobil.git
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
- **From source**, in editable mode (for development):
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
git clone https://github.com/BeMoBIL/pybemobil.git
|
|
136
|
+
cd pybemobil
|
|
137
|
+
pip install -e ".[dev]"
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
We recommend installing into a fresh environment, e.g. `conda create -n pybemobil python=3.12`.
|
|
141
|
+
|
|
142
|
+
## Quick start
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
from pybemobil.io import XDFLoader
|
|
146
|
+
from pybemobil.preproc import EEGPreprocessor, find_rigid_bodies
|
|
147
|
+
|
|
148
|
+
# Load a multimodal XDF recording
|
|
149
|
+
loader = XDFLoader(montage="easycap-M1") # or a path to your .elc/.fif
|
|
150
|
+
recording = loader.load("sub-01_task-walk_run-01.xdf")
|
|
151
|
+
raw = recording.raw
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
See `examples/` for complete worked examples:
|
|
155
|
+
|
|
156
|
+
| Feature | Example script |
|
|
157
|
+
| --------- | --------------- |
|
|
158
|
+
| XDF multimodal loading | `examples/xdf_loading.py` |
|
|
159
|
+
| EEG preprocessing pipeline | `examples/preprocessing.py` |
|
|
160
|
+
| Visualization (run preprocessing.py first) | `examples/plotting.py` |
|
|
161
|
+
| Rigid body kinematics | `examples/motion_processing.py` |
|
|
162
|
+
| BIDS export | `examples/bids_export_example.py` |
|
|
163
|
+
|
|
164
|
+
## Citing
|
|
165
|
+
|
|
166
|
+
If you use pybemobil in your work, please cite it. The "Cite this repository" button on GitHub (generated from [`CITATION.cff`](https://github.com/BeMoBIL/pybemobil/blob/main/CITATION.cff)) gives the reference in APA and BibTeX format.
|
|
167
|
+
|
|
168
|
+
pybemobil is a Python implementation of the BeMoBIL pipeline, so please consider also citing:
|
|
169
|
+
|
|
170
|
+
> Klug, M., Jeung, S., Wunderlich, A., Gehrke, L., Protzak, J., Djebbara, Z., Argubi-Wollesen, A., Wollesen, B., & Gramann, K. (2022). The BeMoBIL Pipeline for automated analyses of multimodal mobile brain and body imaging data. *bioRxiv*. https://doi.org/10.1101/2022.09.29.510051
|
|
171
|
+
|
|
172
|
+
## License
|
|
173
|
+
|
|
174
|
+
pybemobil is released under the [BSD 3-Clause License](https://github.com/BeMoBIL/pybemobil/blob/main/LICENSE).
|
|
175
|
+
|
|
176
|
+
## Contributing
|
|
177
|
+
|
|
178
|
+
Contributions are welcome! To report a bug or suggest a feature, please [open an issue](https://github.com/BeMoBIL/pybemobil/issues). For development setup, the pull request workflow, testing and releases, see [CONTRIBUTING.md](https://github.com/BeMoBIL/pybemobil/blob/main/.github/CONTRIBUTING.md).
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# pybemobil
|
|
2
|
+
|
|
3
|
+
MoBI data loading, preprocessing, and visualization built on MNE-Python.
|
|
4
|
+
|
|
5
|
+
## Structure
|
|
6
|
+
|
|
7
|
+
```md
|
|
8
|
+
pybemobil/
|
|
9
|
+
├── io/ # Data I/O
|
|
10
|
+
│ ├── xdf.py # XDFLoader: multimodal XDF loading, stream alignment
|
|
11
|
+
│ ├── alignment.py # align_stream_to_timestamps (timestamp-aware interpolation)
|
|
12
|
+
│ ├── bids_export.py # BIDS export wrappers around mne_bids
|
|
13
|
+
│ └── utils.py # I/O helpers
|
|
14
|
+
├── preproc/ # Preprocessing
|
|
15
|
+
│ ├── preprocessing.py # EEGPreprocessor: ZapLine -> bad ch -> filter -> ASR -> ICA pipeline
|
|
16
|
+
│ ├── epoching.py # EpochPreparer, stimulus renaming helpers
|
|
17
|
+
│ ├── motion.py # Rigid body kinematics (find, process, split)
|
|
18
|
+
│ └── utils.py # ASR, ZapLine, ICA, dipole fitting, provenance, misc
|
|
19
|
+
├── viz/ # Visualization
|
|
20
|
+
│ ├── plotting.py # ERP, PSD, and component plots
|
|
21
|
+
│ └── utils.py # Plot helpers
|
|
22
|
+
├── examples/ # Runnable example scripts
|
|
23
|
+
│ ├── preprocessing.py # Full EEG preprocessing walkthrough
|
|
24
|
+
│ ├── plotting.py # Visualization walkthrough (run preprocessing.py first)
|
|
25
|
+
│ ├── xdf_loading.py # XDF multimodal loading
|
|
26
|
+
│ ├── motion_processing.py # Rigid body kinematics
|
|
27
|
+
│ └── bids_export_example.py # BIDS export
|
|
28
|
+
└── data/
|
|
29
|
+
└── montages/ # EEG electrode montage files (.elc, .fif)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Modules
|
|
33
|
+
|
|
34
|
+
**`io`** - Load XDF multimodal recordings into MNE Raw objects, align auxiliary streams (ECG, gaze, EMG, EDA) to a common time grid, and export datasets to BIDS.
|
|
35
|
+
|
|
36
|
+
**`preproc`** - Full EEG preprocessing pipeline (bandpass, bad channel detection, ASR, ICA, dipole fitting), epoch preparation, and rigid body motion capture kinematics.
|
|
37
|
+
|
|
38
|
+
**`viz`** - ERP and PSD plotting utilities built on MNE and matplotlib.
|
|
39
|
+
|
|
40
|
+
**`examples`** - Self-contained scripts demonstrating major features. Run directly or open as notebooks (percent-format cells).
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
Install the latest release from PyPI:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pip install pybemobil
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
To also install the JAX-accelerated AMICA backend (the default ICA method, which falls back to Picard when this is missing):
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install "pybemobil[jamica]"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Alternatively:
|
|
57
|
+
|
|
58
|
+
- **Latest development version** from GitHub:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pip install git+https://github.com/BeMoBIL/pybemobil.git
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
- **From source**, in editable mode (for development):
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
git clone https://github.com/BeMoBIL/pybemobil.git
|
|
68
|
+
cd pybemobil
|
|
69
|
+
pip install -e ".[dev]"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
We recommend installing into a fresh environment, e.g. `conda create -n pybemobil python=3.12`.
|
|
73
|
+
|
|
74
|
+
## Quick start
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
from pybemobil.io import XDFLoader
|
|
78
|
+
from pybemobil.preproc import EEGPreprocessor, find_rigid_bodies
|
|
79
|
+
|
|
80
|
+
# Load a multimodal XDF recording
|
|
81
|
+
loader = XDFLoader(montage="easycap-M1") # or a path to your .elc/.fif
|
|
82
|
+
recording = loader.load("sub-01_task-walk_run-01.xdf")
|
|
83
|
+
raw = recording.raw
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
See `examples/` for complete worked examples:
|
|
87
|
+
|
|
88
|
+
| Feature | Example script |
|
|
89
|
+
| --------- | --------------- |
|
|
90
|
+
| XDF multimodal loading | `examples/xdf_loading.py` |
|
|
91
|
+
| EEG preprocessing pipeline | `examples/preprocessing.py` |
|
|
92
|
+
| Visualization (run preprocessing.py first) | `examples/plotting.py` |
|
|
93
|
+
| Rigid body kinematics | `examples/motion_processing.py` |
|
|
94
|
+
| BIDS export | `examples/bids_export_example.py` |
|
|
95
|
+
|
|
96
|
+
## Citing
|
|
97
|
+
|
|
98
|
+
If you use pybemobil in your work, please cite it. The "Cite this repository" button on GitHub (generated from [`CITATION.cff`](https://github.com/BeMoBIL/pybemobil/blob/main/CITATION.cff)) gives the reference in APA and BibTeX format.
|
|
99
|
+
|
|
100
|
+
pybemobil is a Python implementation of the BeMoBIL pipeline, so please consider also citing:
|
|
101
|
+
|
|
102
|
+
> Klug, M., Jeung, S., Wunderlich, A., Gehrke, L., Protzak, J., Djebbara, Z., Argubi-Wollesen, A., Wollesen, B., & Gramann, K. (2022). The BeMoBIL Pipeline for automated analyses of multimodal mobile brain and body imaging data. *bioRxiv*. https://doi.org/10.1101/2022.09.29.510051
|
|
103
|
+
|
|
104
|
+
## License
|
|
105
|
+
|
|
106
|
+
pybemobil is released under the [BSD 3-Clause License](https://github.com/BeMoBIL/pybemobil/blob/main/LICENSE).
|
|
107
|
+
|
|
108
|
+
## Contributing
|
|
109
|
+
|
|
110
|
+
Contributions are welcome! To report a bug or suggest a feature, please [open an issue](https://github.com/BeMoBIL/pybemobil/issues). For development setup, the pull request workflow, testing and releases, see [CONTRIBUTING.md](https://github.com/BeMoBIL/pybemobil/blob/main/.github/CONTRIBUTING.md).
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Minimal makefile for Sphinx documentation
|
|
2
|
+
|
|
3
|
+
SPHINXOPTS ?=
|
|
4
|
+
SPHINXBUILD ?= sphinx-build
|
|
5
|
+
SOURCEDIR = source
|
|
6
|
+
BUILDDIR = build
|
|
7
|
+
|
|
8
|
+
help:
|
|
9
|
+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
10
|
+
|
|
11
|
+
.PHONY: help Makefile
|
|
12
|
+
|
|
13
|
+
# route all unknown targets to Sphinx using the "make mode" option
|
|
14
|
+
%: Makefile
|
|
15
|
+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
@ECHO OFF
|
|
2
|
+
|
|
3
|
+
pushd %~dp0
|
|
4
|
+
|
|
5
|
+
REM Command file for Sphinx documentation
|
|
6
|
+
|
|
7
|
+
if "%SPHINXBUILD%" == "" (
|
|
8
|
+
set SPHINXBUILD=sphinx-build
|
|
9
|
+
)
|
|
10
|
+
set SOURCEDIR=source
|
|
11
|
+
set BUILDDIR=build
|
|
12
|
+
|
|
13
|
+
%SPHINXBUILD% >NUL 2>NUL
|
|
14
|
+
if errorlevel 9009 (
|
|
15
|
+
echo.
|
|
16
|
+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
|
17
|
+
echo.installed, then set the SPHINXBUILD environment variable to point
|
|
18
|
+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
|
19
|
+
echo.may add the Sphinx directory to PATH.
|
|
20
|
+
echo.
|
|
21
|
+
echo.If you don't have Sphinx installed, grab it from
|
|
22
|
+
echo.https://www.sphinx-doc.org/
|
|
23
|
+
exit /b 1
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
if "%1" == "" goto help
|
|
27
|
+
|
|
28
|
+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
|
29
|
+
goto end
|
|
30
|
+
|
|
31
|
+
:help
|
|
32
|
+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
|
33
|
+
|
|
34
|
+
:end
|
|
35
|
+
popd
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* Force a hard line break between the version and "documentation" in the
|
|
2
|
+
* header title, rather than relying on the theme's flex layout to wrap it
|
|
3
|
+
* (which fights back: `.navbar-brand` is a flex container with an
|
|
4
|
+
* implicit min-width on its children, and `.navbar-header-items__start`
|
|
5
|
+
* never shrinks). `html_title` in conf.py embeds a literal "\n" between
|
|
6
|
+
* the version and "documentation"; `pre-line` renders that as an actual
|
|
7
|
+
* line break while still collapsing any other whitespace normally. */
|
|
8
|
+
.logo__title {
|
|
9
|
+
white-space: pre-line;
|
|
10
|
+
line-height: 1.25;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/* `.navbar-brand` has a fixed height/max-height matching the theme's
|
|
14
|
+
* single-line header. Let it grow now that the title can be two lines. */
|
|
15
|
+
.navbar-brand {
|
|
16
|
+
height: auto;
|
|
17
|
+
max-height: none;
|
|
18
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
.. _api-io:
|
|
2
|
+
|
|
3
|
+
I/O
|
|
4
|
+
===
|
|
5
|
+
|
|
6
|
+
Functions and classes for loading multimodal XDF recordings, aligning auxiliary
|
|
7
|
+
streams to a common time grid, and exporting datasets to BIDS.
|
|
8
|
+
|
|
9
|
+
----
|
|
10
|
+
|
|
11
|
+
Loading
|
|
12
|
+
-------
|
|
13
|
+
|
|
14
|
+
The central entry point for reading XDF files.
|
|
15
|
+
:class:`~pybemobil.io.XDFLoader` handles stream detection, resampling, and
|
|
16
|
+
multi-stream alignment in one call, returning a
|
|
17
|
+
:class:`~pybemobil.io.MultimodalRecording` that bundles the merged
|
|
18
|
+
:class:`mne.io.Raw` object together with any Tier-2 (high-rate) streams and
|
|
19
|
+
irregular event streams.
|
|
20
|
+
|
|
21
|
+
.. currentmodule:: pybemobil.io
|
|
22
|
+
|
|
23
|
+
.. autosummary::
|
|
24
|
+
:toctree: generated/
|
|
25
|
+
|
|
26
|
+
XDFLoader
|
|
27
|
+
MultimodalRecording
|
|
28
|
+
|
|
29
|
+
----
|
|
30
|
+
|
|
31
|
+
Stream alignment
|
|
32
|
+
----------------
|
|
33
|
+
|
|
34
|
+
Low-level utility for aligning a single auxiliary stream to an existing time
|
|
35
|
+
grid. Used internally by :class:`XDFLoader` but also useful standalone when
|
|
36
|
+
combining data from different acquisition systems.
|
|
37
|
+
|
|
38
|
+
.. autosummary::
|
|
39
|
+
:toctree: generated/
|
|
40
|
+
|
|
41
|
+
align_stream_to_timestamps
|
|
42
|
+
|
|
43
|
+
----
|
|
44
|
+
|
|
45
|
+
BIDS export
|
|
46
|
+
-----------
|
|
47
|
+
|
|
48
|
+
Wrappers around :mod:`mne_bids` for writing cleaned EEG datasets to the
|
|
49
|
+
`Brain Imaging Data Structure <https://bids-specification.readthedocs.io>`_ standard.
|
|
50
|
+
|
|
51
|
+
.. autosummary::
|
|
52
|
+
:toctree: generated/
|
|
53
|
+
|
|
54
|
+
export_to_bids
|
|
55
|
+
batch_export_to_bids
|
|
56
|
+
make_bids_dataset_description
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
.. _api-preproc:
|
|
2
|
+
|
|
3
|
+
Preprocessing
|
|
4
|
+
=============
|
|
5
|
+
|
|
6
|
+
The preprocessing module covers the full EEG pipeline, epoch preparation,
|
|
7
|
+
rigid-body motion kinematics, and a set of lower-level signal-processing
|
|
8
|
+
utilities that the pipeline calls internally but which are also usable
|
|
9
|
+
standalone.
|
|
10
|
+
|
|
11
|
+
----
|
|
12
|
+
|
|
13
|
+
EEG pipeline
|
|
14
|
+
------------
|
|
15
|
+
|
|
16
|
+
:class:`~pybemobil.preproc.EEGPreprocessor` orchestrates the full pipeline:
|
|
17
|
+
ZapLine → bad-channel detection → bandpass filter → ASR → ICA/JAMICA →
|
|
18
|
+
ICLabel classification → dipole fitting → average re-reference → bad-channel
|
|
19
|
+
interpolation. All steps are recorded in a provenance descriptor stored on
|
|
20
|
+
the :class:`mne.io.Raw` object.
|
|
21
|
+
|
|
22
|
+
.. currentmodule:: pybemobil.preproc
|
|
23
|
+
|
|
24
|
+
Outputs are named after BIDS: :func:`get_derivative_paths` lists the
|
|
25
|
+
derivative files written for a given ``fname_out``, and the untouched input is
|
|
26
|
+
written to the raw part of the BIDS dataset.
|
|
27
|
+
|
|
28
|
+
.. autosummary::
|
|
29
|
+
:toctree: generated/
|
|
30
|
+
|
|
31
|
+
EEGPreprocessor
|
|
32
|
+
get_derivative_paths
|
|
33
|
+
|
|
34
|
+
----
|
|
35
|
+
|
|
36
|
+
Reporting
|
|
37
|
+
---------
|
|
38
|
+
|
|
39
|
+
Builds an :class:`mne.Report` summarising a single :class:`EEGPreprocessor` run
|
|
40
|
+
(bad channels, ICA, dipoles, and full-length stream traces for drop-out
|
|
41
|
+
inspection). Called automatically by :meth:`EEGPreprocessor.run_raw` when
|
|
42
|
+
``make_report=True`` (the default); can also be called directly on saved
|
|
43
|
+
pipeline outputs.
|
|
44
|
+
|
|
45
|
+
.. autosummary::
|
|
46
|
+
:toctree: generated/
|
|
47
|
+
|
|
48
|
+
make_report
|
|
49
|
+
|
|
50
|
+
----
|
|
51
|
+
|
|
52
|
+
Bad channel detection
|
|
53
|
+
---------------------
|
|
54
|
+
|
|
55
|
+
Standalone bad-channel detector that combines PyPREP, FASTER, per-channel
|
|
56
|
+
flatline detection, and a line-noise z-score criterion. Called automatically
|
|
57
|
+
by :class:`EEGPreprocessor` but can also be run on any
|
|
58
|
+
:class:`mne.io.Raw` object directly.
|
|
59
|
+
|
|
60
|
+
.. autosummary::
|
|
61
|
+
:toctree: generated/
|
|
62
|
+
|
|
63
|
+
get_bad_chs
|
|
64
|
+
|
|
65
|
+
----
|
|
66
|
+
|
|
67
|
+
Signal cleaning
|
|
68
|
+
---------------
|
|
69
|
+
|
|
70
|
+
Individual signal-processing steps that :class:`EEGPreprocessor` calls
|
|
71
|
+
internally. Useful when building a custom pipeline or applying a single step
|
|
72
|
+
in isolation.
|
|
73
|
+
|
|
74
|
+
.. autosummary::
|
|
75
|
+
:toctree: generated/
|
|
76
|
+
|
|
77
|
+
remove_line
|
|
78
|
+
compute_asr
|
|
79
|
+
compute_ica
|
|
80
|
+
detect_bad_by_line_noise
|
|
81
|
+
compute_mi_reduction
|
|
82
|
+
|
|
83
|
+
----
|
|
84
|
+
|
|
85
|
+
Dipole fitting
|
|
86
|
+
--------------
|
|
87
|
+
|
|
88
|
+
.. autosummary::
|
|
89
|
+
:toctree: generated/
|
|
90
|
+
|
|
91
|
+
fit_dipoles_on_ica
|
|
92
|
+
compute_dipolarity
|
|
93
|
+
auto_coreg_fsaverage
|
|
94
|
+
|
|
95
|
+
----
|
|
96
|
+
|
|
97
|
+
Epoching
|
|
98
|
+
--------
|
|
99
|
+
|
|
100
|
+
Helpers for converting continuous preprocessed data into epochs, including
|
|
101
|
+
stimulus-label renaming utilities for common BPN paradigms.
|
|
102
|
+
|
|
103
|
+
.. autosummary::
|
|
104
|
+
:toctree: generated/
|
|
105
|
+
|
|
106
|
+
EpochPreparer
|
|
107
|
+
get_stimulus_rename_map
|
|
108
|
+
|
|
109
|
+
----
|
|
110
|
+
|
|
111
|
+
Motion capture
|
|
112
|
+
--------------
|
|
113
|
+
|
|
114
|
+
Rigid-body kinematics from XDF motion streams. Works on the motion data
|
|
115
|
+
returned by :class:`~pybemobil.io.XDFLoader` in
|
|
116
|
+
:attr:`~pybemobil.io.MultimodalRecording.motion`.
|
|
117
|
+
|
|
118
|
+
.. autosummary::
|
|
119
|
+
:toctree: generated/
|
|
120
|
+
|
|
121
|
+
find_rigid_bodies
|
|
122
|
+
process_rigid_body
|
|
123
|
+
split_by_rigid_body
|
|
124
|
+
|
|
125
|
+
----
|
|
126
|
+
|
|
127
|
+
Provenance
|
|
128
|
+
----------
|
|
129
|
+
|
|
130
|
+
Lightweight provenance tracking: each pipeline step appends a JSON-serialisable
|
|
131
|
+
descriptor to :attr:`mne.Info.description` so that any saved file carries a
|
|
132
|
+
record of exactly how it was processed.
|
|
133
|
+
|
|
134
|
+
.. autosummary::
|
|
135
|
+
:toctree: generated/
|
|
136
|
+
|
|
137
|
+
init_descriptor
|
|
138
|
+
set_descriptor
|
|
139
|
+
get_descriptor
|
|
140
|
+
append_desc
|
|
141
|
+
sig_params
|
|
142
|
+
|
|
143
|
+
----
|
|
144
|
+
|
|
145
|
+
Utilities
|
|
146
|
+
---------
|
|
147
|
+
|
|
148
|
+
.. autosummary::
|
|
149
|
+
:toctree: generated/
|
|
150
|
+
|
|
151
|
+
StepTimer
|
|
152
|
+
format_duration
|
|
153
|
+
build_sys_info
|