[Mne_analysis] EEGLAB reader
larson.eric.d at gmail.com
Fri Sep 27 12:49:48 EDT 2019
External Email - Use Caution
> eeg_data = eeg.get_data().reshape((n_chan, n_sample*n_epochs))
data = reshape(EEG.data,nchans,EEG.pnts*EEG.trials);
Have you thought about 1) the dimensions of each thing being reshaped, and
2) how `reshape` handles array order in each language?
For the reshape step:
1. NumPy by default uses C order, meaning the last dimension changes the
2. MATLAB stores data in F/Fortran order, meaning the first dimension
changes the fastest
So, given the same input dimension ordering, the reshaping is not going to
be equivalent here, unless you pass order='F' to np.reshape (or do
something to get MATLAB to change how it reorders).
Regarding input dimension ordering, the dimensions of the Python array are
(n_epochs, n_channels, n_times). Not sure what shape EEGLAB gives you.
Depending on that, you might need to `.transpose([...])` in Python to get
it to the right dimension order, *and *a `np.reshape(..., order='F')` to
then reorder it the same way.
Maybe you've thought about these things and accounted for them already, but
calling eeg.get_data().reshape(n_channels,n_sample*n_epochs) looks a bit
suspicious -- I'm guessing you want the data for each channel across time
(epochs stacked horizontally, basically). To get this you would want to add
a transpose step:
eeg.get_data().transpose([1, 0, 2]).reshape(n_chan, n_epochs*n_sample)
# or just .reshape(n_chan, -1)
So I suspect there are some dimension-order / reshape-order problems
popping up in your code.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Mne_analysis