Skip to content

Commit bf8d8fc

Browse files
authored
Merge branch 'main' into fix-show-channel-names-rendering
2 parents 54595aa + 9b14298 commit bf8d8fc

41 files changed

Lines changed: 718 additions & 163 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

doc/api/reading_raw_data.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Reading raw data
1616
read_raw
1717
read_raw_ant
1818
read_raw_artemis123
19+
read_raw_bci2k
1920
read_raw_bdf
2021
read_raw_boxy
2122
read_raw_brainvision

doc/changes/dev/13619.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix bug with :func:`mne.make_forward_solution` when no MEG channels are present where ``dev_head_t`` was errantly set, by `Eric Larson`_.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add support for reading BCI2000 ``.dat`` files via :func:`mne.io.read_raw_bci2k`, and an example :file:`examples/io/read_bci2k.py` for downloading and visualizing BCI2000 data, by :newcontrib:`Hansuja Budhiraja`.

doc/changes/dev/13753.other.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improved internal functions for inspecting MATLAB v7.3 (HDF5) files in :func:`mne.io.read_raw_eeglab`, by `Bruno Aristimunha`_.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added ``cmap`` parameter to ``Evoked.animate_topomap`` to allow user-specified colormaps., by :newcontrib:`Hansuja Budhiraja`.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added a ``font_file`` parameter to :meth:`mne.viz.Brain.add_text` to support rendering glyphs not available in the default font, by `Pragnya Khandelwal`_.

doc/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@
291291
"EpochsEEGLAB": "mne.Epochs",
292292
"EpochsKIT": "mne.Epochs",
293293
"RawANT": "mne.io.Raw",
294+
"RawBCI2k": "mne.io.Raw",
294295
"RawBOXY": "mne.io.Raw",
295296
"RawBrainVision": "mne.io.Raw",
296297
"RawBTi": "mne.io.Raw",

doc/sphinxext/related_software_nodeps.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ cross-domain-saliency-maps
33
fsleyes
44
mne-kit-gui
55
mne-videobrowser
6+
hedtools # because it limits our Pandas version currently

examples/inverse/multi_dipole_model.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
cov_fname = meg_path / "sample_audvis-shrunk-cov.fif"
4646
bem_dir = data_path / "subjects" / "sample" / "bem"
4747
bem_fname = bem_dir / "sample-5120-5120-5120-bem-sol.fif"
48+
trans_fname = meg_path / "sample_audvis_raw-trans.fif"
4849

4950
###############################################################################
5051
# Read the MEG data from the audvis experiment. Make epochs and evokeds for the
@@ -102,8 +103,9 @@
102103
cov_fit_right["projs"] = evoked_fit_right.info["projs"]
103104

104105
# Fit the dipoles with the subset of sensors.
105-
dip_left, _ = mne.fit_dipole(evoked_fit_left, cov_fit_left, bem)
106-
dip_right, _ = mne.fit_dipole(evoked_fit_right, cov_fit_right, bem)
106+
kwargs = dict(bem=bem, trans=trans_fname)
107+
dip_left, _ = mne.fit_dipole(evoked_fit_left, cov_fit_left, **kwargs)
108+
dip_right, _ = mne.fit_dipole(evoked_fit_right, cov_fit_right, **kwargs)
107109

108110
###############################################################################
109111
# Now that we have the location and orientations of the dipoles, compute the

examples/io/read_bci2k.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
"""
2+
======================
3+
Reading BCI2000 files
4+
======================
5+
6+
In this example, we use MNE-Python to read a BCI2000 ``.dat`` file.
7+
BCI2000 is a general-purpose brain-computer interface (BCI) system widely
8+
used in EEG research. The file is downloaded from the MNE testing data
9+
repository using ``pooch``.
10+
""" # noqa: D205 D400
11+
12+
# Authors: The MNE-Python contributors.
13+
# License: BSD-3-Clause
14+
# Copyright the MNE-Python contributors.
15+
16+
import pooch
17+
18+
import mne
19+
20+
# %%
21+
# First, we download the sample BCI2000 ``.dat`` file using ``pooch``.
22+
23+
data_dir = mne.datasets.default_path() / "bci2k_data"
24+
data_dir.mkdir(exist_ok=True)
25+
26+
fname = pooch.retrieve(
27+
url="https://raw.githubusercontent.com/mne-tools/mne-testing-data/master/BCI2k/bci2k_test.dat",
28+
known_hash="sha256:8efc7b5f700660a044086cb1449806ca408c2e6d32d9338c32e1bf31ce3ca9cb",
29+
path=data_dir,
30+
)
31+
32+
# %%
33+
# Now we can read the file using :func:`mne.io.read_raw_bci2k`.
34+
# Note that ``preload=True`` is required for BCI2000 files.
35+
36+
raw = mne.io.read_raw_bci2k(fname, preload=True)
37+
print(raw.info)
38+
39+
# %%
40+
# We can inspect the object representation, channel names, types, sampling
41+
# frequency, and recording duration.
42+
43+
print(raw)
44+
print(f"Channel names : {raw.ch_names}")
45+
print(f"Channel types : {raw.get_channel_types()}")
46+
print(f"Sampling freq : {raw.info['sfreq']} Hz")
47+
print(f"Duration : {raw.times[-1]:.2f} s")
48+
print(f"n_channels : {raw.info['nchan']}")
49+
print(f"Data shape : {raw.get_data().shape} (n_channels, n_samples)")
50+
51+
# %%
52+
# If the BCI2000 file contains a ``StimulusCode`` state, it is automatically
53+
# mapped to a ``STI 014`` stim channel. We can extract events from it using
54+
# :func:`mne.find_events`.
55+
56+
if "STI 014" in raw.ch_names:
57+
events = mne.find_events(raw, shortest_event=1)
58+
print(f"Found {len(events)} events")
59+
print(mne.count_events(events))
60+
else:
61+
print("No stim channel found in this file.")
62+
63+
# %%
64+
# Finally, we can visualize the raw data.
65+
66+
raw.plot(duration=5, n_channels=len(raw.ch_names), scalings="auto")

0 commit comments

Comments
 (0)