[Mne_analysis] EEGLAB reader
christian.oreilly at gmail.com
Fri Sep 27 13:18:49 EDT 2019
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().
Le ven. 27 sept. 2019 à 12:50, Eric Larson <larson.eric.d at gmail.com> a
> 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.
> Mne_analysis mailing list
> Mne_analysis at nmr.mgh.harvard.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Mne_analysis