2
$\begingroup$

I have EEG data that comes in the form of a 3D numpy array (epoch * channel * timepoint). timepoint is a 256 element array containing each sampled timepoint (1s total, at 256Hz). epoch is an experimental trial.

I'm trying to import the numpy array into a form Python-MNE (http://martinos.org/mne/stable/mne-python.html) understands, but I'm having some trouble

First, I'm not sure if I should be importing this raw data as a RawArray or an EpochsArray. I tried the latter with this:

ch_names = list containing my 64 eeg channel names
allData = 3d numpy array as described above

info = mne.create_info(ch_names, 256, ch_types='eeg')

event_id = 1

#I got this from a tutorial but really unsure what it does and I think this may be the problem
events = np.array([200, event_id])  #I got this from a tutorial but really unsure what it does and I think this may be the problem

raw = mne.EpochsArray(allData, info, events=events)

picks = mne.pick_types(info, meg=False, eeg=True, misc=False)

raw.plot(picks=picks, show=True, block=True)

When I run this I get an index error: "too many indices for array"

Ultimately I want to do some STFT and CSP analysis on the data, but right now I'm in need of some help with the initial restructuring and importing into MNE.

Whats the correct way to import this numpy data that would make it easiest to complete my intended analyses?

$\endgroup$

1 Answer 1

1
$\begingroup$

mne.EpochsArray is for 3-D data (epochs * channels * times). mne.RawArray is for 2-D data. Use EpochsArray.

events is an n * 3 integer array. The 3 columns are: time (in sampling points), length (you can put a dummy here - it is almost never checked - but you still need 3 columns), value (e.g. condition). You fed it a 1 * 2 array.

Try it:

import numpy as np
from mne import create_info, EpochsArray
n_epochs = 100
channels = ["a", "b", "c", "d"]
n_channels = len(channels)
events = np.array([np.arange(n_epochs), np.ones(n_epochs), np.ones(n_epochs)]).T.astype(int)
d = np.random.random((n_epochs, n_channels, 256))

info = create_info(channels, 256, "eeg")
epochs = EpochsArray(d, info, events)

epochs.plot(show=True, block=True)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.