Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: nk.data import of eeg sample data #1072

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
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
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
Loading