[Mne_analysis] EEGLAB reader

Christian O'Reilly christian.oreilly at gmail.com
Fri Sep 27 13:18:49 EDT 2019
Search archives:

        External Email - Use Caution        

Thanks Eric. I got tripped down by the quasi direct translation of code
from Matlab to Numpy. Your intuition was right, it was an issue related to
differences in reshape ordering. Worked well (and I think it makes the code
more readable) with np.hstack(eeg.get_data()) instead of .reshape().

Best wishes,


Le ven. 27 sept. 2019 à 12:50, Eric Larson <larson.eric.d at gmail.com> a
écrit :

>         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
> fastest
> 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.
> Eric
> _______________________________________________
> Mne_analysis mailing list
> Mne_analysis at nmr.mgh.harvard.edu
> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20190927/37446f34/attachment.html 

More information about the Mne_analysis mailing list