Skip to content

Commit

Permalink
update: added support for mne 1.9 to sample eeg data
Browse files Browse the repository at this point in the history
- Mne 1.9 changes how cropping works to include file checks
- Sample data is stored in pickle so does not come from disk
- Change removes previous existing filenames from eeg sample data
  • Loading branch information
DerAndereJohannes committed Feb 11, 2025
1 parent 4a028ba commit 2db1331
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions neurokit2/data/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import pickle
import urllib

import mne
import pandas as pd

from sklearn import datasets as sklearn_datasets


Expand Down Expand Up @@ -194,9 +196,7 @@ def data(dataset="bio_eventrelated_100hz"):
# Dataframes ===============================
if dataset == "iris":
info = sklearn_datasets.load_iris()
data = pd.DataFrame(
info.data, columns=["Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width"]
)
data = pd.DataFrame(info.data, columns=["Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width"])
data["Species"] = info.target_names[info.target]
return data

Expand Down Expand Up @@ -225,12 +225,19 @@ def data(dataset="bio_eventrelated_100hz"):
# TODO: Add more EEG (fif and edf datasets)
if dataset in ["eeg_1min_200hz"]:

return pickle.load(
eeg_object = pickle.load(
urllib.request.urlopen(
"https://github.com/neuropsychology/NeuroKit/blob/dev/data/eeg_1min_200hz.pickle?raw=true"
)
)

# Pickle includes filename which MNE (1.9) now checks when cropping signal
# see https://github.com/mne-tools/mne-python/pull/12843
if tuple(map(int, mne.__version__.split("."))) >= (1, 9, 0):
eeg_object.filenames = (None,)

return eeg_object

# General case
file, ext = os.path.splitext(dataset) # pylint: disable=unused-variable
if ext == "":
Expand Down

0 comments on commit 2db1331

Please sign in to comment.