<p><span style="padding: 3px 10px; border-radius: 5px; color: #ffffff; font-weight: bold; display: inline-block; background-color: #ff0000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;External Email - Use Caution&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></p><p></p><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">eeg_data = eeg.get_data().reshape((n_chan, n_sample*n_epochs)) </div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"> ...</div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">data = reshape(EEG.data,nchans,EEG.pnts*EEG.trials);<br></div></blockquote><div><br></div><div><div>Have you thought about 1) the dimensions of each thing being reshaped, and 2) how `reshape` handles array order in each language?</div><div><br></div><div>For the reshape step:</div><div><br></div><div>1. NumPy by default uses C order, meaning the last dimension changes the fastest</div><div>2. MATLAB stores data in F/Fortran order, meaning the first dimension changes the fastest</div><div><br></div><div>So, given the same input dimension ordering, the reshaping is not going to be equivalent here, unless you pass order=&#39;F&#39; to np.reshape (or do something to get MATLAB to change how it reorders).</div><div><br></div><div>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, <i>and </i>a `np.reshape(..., order=&#39;F&#39;)` to then reorder it the same way.</div><div><br></div><div>Maybe you&#39;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&#39;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:</div><div></div><div class="markdown-here-wrapper" style=""><pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important">eeg.get_data().transpose([1, 0, 2]).reshape(n_chan, n_epochs*n_sample)  # or just .reshape(n_chan, -1)
</code></pre><div title="MDH:PGRpdj5gYGA8L2Rpdj48ZGl2PmVlZy5nZXRfZGF0YSgpLnRyYW5zcG9zZShbMSwgMCwgMl0pLnJl
c2hhcGUobl9jaGFuLCBuX2Vwb2NocypuX3NhbXBsZSkmbmJzcDsgIyBvciBqdXN0IC5yZXNoYXBl
KG5fY2hhbiwgLTEpPC9kaXY+PGRpdj5gYGA8L2Rpdj48ZGl2PjwvZGl2Pg==" style="height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0"></div></div><div>So I suspect there are some dimension-order / reshape-order problems popping up in your code.</div><div><br></div><div>Eric<br></div><div><br></div></div></div></div>