<div dir="ltr"><div><div>Also, can you try something like this?<br><br><font face="Courier New">for ii, ep in enumerate(epochs):</font><br> <font face="Courier New">stc = compute_source_psd_epochs(epochs=ep ...)</font><br>
<br></div>which would not require <font face="Courier New">EpochsArray.<br><br></font>Mainak</div><font face="Courier New"></font><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jul 31, 2014 at 11:31 PM, Eric Larson <span dir="ltr"><<a href="mailto:larson.eric.d@gmail.com" target="_blank">larson.eric.d@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">What are you using for `events`? It should have the same number of entries as the number of epochs (1), I suspect it might not. (We should probably add a check in mne-python that this is the case...)<span class="HOEnZb"><font color="#888888"><br>
<br>
Eric</font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jul 31, 2014 at 3:37 AM, Silfverberg Sebastian <span dir="ltr"><<a href="mailto:sebastian.silfverberg@aalto.fi" target="_blank">sebastian.silfverberg@aalto.fi</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt">This next snippet is from the offline version I've been testing:<br>
<br>
<br>
<font face="Courier New">for ii, data in enumerate(epochs.get_data()):<br>
<br>
# make the 2D epoch to 3D<br>
<br>
data = data[newaxis, ...]<br>
<br>
ep = EpochsArray(data=data, info=<a href="http://raw.info" target="_blank">raw.info</a>, events=events, tmin=0,event_id=event_id, reject=reject)<br>
<br>
stc = compute_source_psd_epochs(epochs=ep, inverse_operator=inverse_operator, lambda2=lambda2,method=method, fmin=15.0, fmax=25.0, pick_ori=None, pca=True,
bandwidth=bandwidth, n_jobs=10, return_generator=False)<br>
</font><br>
and the error comes in the last command. <br>
<br>
What is the best way to iterate over rt_epochs? rt.epochs.next()? I'm now doing just<br>
<br>
<font face="Courier New">for ii, data in enumerate(rt_epochs):</font><br>
<br>
<br>
Sebastian<br>
<br>
<div style="font-family:Times New Roman;color:#000000;font-size:16px">
<hr>
<div style="direction:ltr"><font color="#000000" face="Tahoma"><b>Lähettäjä:</b> <a href="mailto:mne_analysis-bounces@nmr.mgh.harvard.edu" target="_blank">mne_analysis-bounces@nmr.mgh.harvard.edu</a> [<a href="mailto:mne_analysis-bounces@nmr.mgh.harvard.edu" target="_blank">mne_analysis-bounces@nmr.mgh.harvard.edu</a>] käyttäjän Mainak Jas [<a href="mailto:mainakjas@gmail.com" target="_blank">mainakjas@gmail.com</a>] puolesta<br>
<b>Lähetetty:</b> 31. heinäkuuta 2014 12:22<br>
<b>Vastaanottaja:</b> Discussion and support forum for the users of MNE Software<br>
<b>Aihe:</b> Re: [Mne_analysis] Strange errors with calculating source estimates in a frequency band<br>
</font><br>
</div>
<div></div>
<div><div>
<div dir="ltr">
<div>Hi Sebastian,<br>
<br>
</div>
<div>It seems to me that you are somehow iterating over the epochs and stc objects incorrectly. You do not need to use EpochsArray because you can iterate over the Epochs object directly (same with RtEpochs I think). For stc, if you have a single epoch, can
you check if your iterations are correct?<br>
<br>
</div>
<div>A small code snippet / gist that reproduces this issue would be great.<br>
</div>
<div><br>
</div>
<div>Mainak<br>
</div>
</div>
</div><div class="gmail_extra"><br>
<br>
<div class="gmail_quote"><div>On Thu, Jul 31, 2014 at 9:14 AM, Silfverberg Sebastian <span dir="ltr">
<<a href="mailto:sebastian.silfverberg@aalto.fi" target="_blank">sebastian.silfverberg@aalto.fi</a>></span> wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>
<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt"><font color="black" face="Tahoma"><span dir="ltr" style="font-size:10pt">Hi everyone!<br>
<br>
I have been trying to code a program that would enable to plot user selectable time windows of averaged source estimates in a certain frequency band in real time with FieldTrip Buffer. I'm now trying to simulate that in offline mode with looping through the
epochs.get_data() and then building an Epoch from a single epoch with EpochsArray (because that's the way the real time sytem works). I end up with a couple of odd errors using
<i>compute_source_psd_epochs</i> depending on how long my time window is.</span></font><font>
</font>If my time window is shorter than 10 seconds, my error is this:<br>
<br>
<font face="Courier New">/usr/lib/python2.7/dist-packages/IPython/utils/py3compat.pyc in execfile(fname, *where)<br>
173 else:<br>
174 filename = fname<br>
--> 175 __builtin__.execfile(filename, *where)<br>
<br>
/home/silfves1/mne-python/examples/omatfunktiot/jatk_off.py in <module>()<br>
380 <br>
381 <br>
--> 382 stc = compute_source_psd_epochs(epochs=ep, inverse_operator=inverse_operator, lambda2=lambda2, method=method, fmin=15.0, fmax=25.0, pick_ori=None, pca=True, bandwidth=bandwidth, n_jobs=10, return_generator=False)<br>
383 <br>
384 <br>
<br>
/home/silfves1/.local/lib/python2.7/site-packages/mne-0.8.git-py2.7.egg/mne/minimum_norm/time_frequency.pyc in compute_source_psd_epochs(epochs, inverse_operator, lambda2, method, fmin, fmax, pick_ori, label, nave, pca, inv_split, bandwidth, adaptive, low_bias,
return_generator, n_jobs, verbose, pick_normal)<br>
<br>
/home/silfves1/.local/lib/python2.7/site-packages/mne-0.8.git-py2.7.egg/mne/utils.pyc in verbose(function, *args, **kwargs)<br>
549 return ret<br>
550 else:<br>
--> 551 ret = function(*args, **kwargs)<br>
552 return ret<br>
553 <br>
<br>
/home/silfves1/.local/lib/python2.7/site-packages/mne-0.8.git-py2.7.egg/mne/minimum_norm/time_frequency.pyc in compute_source_psd_epochs(epochs, inverse_operator, lambda2, method, fmin, fmax, pick_ori, label, nave, pca, inv_split, bandwidth, adaptive, low_bias,
return_generator, n_jobs, verbose, pick_normal)<br>
669 # return a list<br>
<br>
670 stcs = list()<br>
--> 671 for stc in stcs_gen:<br>
672 stcs.append(stc)<br>
673 <br>
<br>
/home/silfves1/.local/lib/python2.7/site-packages/mne-0.8.git-py2.7.egg/mne/minimum_norm/time_frequency.pyc in _compute_source_psd_epochs(epochs, inverse_operator, lambda2, method, fmin, fmax, pick_ori, label, nave, pca, inv_split, bandwidth, adaptive, low_bias,
n_jobs, verbose)<br>
519 <br>
520 dpss, eigvals = dpss_windows(n_times, half_nbw, n_tapers_max,<br>
--> 521 low_bias=low_bias)<br>
522 n_tapers = len(dpss)<br>
523 <br>
<br>
/home/silfves1/.local/lib/python2.7/site-packages/mne-0.8.git-py2.7.egg/mne/time_frequency/multitaper.pyc in dpss_windows(N, half_nbw, Kmax, low_bias, interp_from, interp_kind)<br>
202 # only calculate the highest Kmax eigenvalues<br>
<br>
203 w = linalg.eigvals_banded(ab, select='i',<br>
--> 204 select_range=(N - Kmax, N - 1))<br>
205 w = w[::-1]<br>
206 <br>
<br>
/usr/lib/python2.7/dist-packages/scipy/linalg/decomp.pyc in eigvals_banded(a_band, lower, overwrite_a_band, select, select_range)<br>
698 return eig_banded(a_band, lower=lower, eigvals_only=1,<br>
699 overwrite_a_band=overwrite_a_band, select=select,<br>
--> 700 select_range=select_range)<br>
701 <br>
702 _double_precision = ['i','l','d']<br>
<br>
/usr/lib/python2.7/dist-packages/scipy/linalg/decomp.pyc in eig_banded(a_band, lower, eigvals_only, overwrite_a_band, select, select_range, max_ev)<br>
490 vl, vu, il, iu = 0.0, 0.0, min(select_range), max(select_range)<br>
491 if min(il, iu) < 0 or max(il, iu) >= a1.shape[1]:<br>
--> 492 raise ValueError('select_range out of bounds')<br>
493 max_ev = iu - il + 1<br>
494 else: # 1, 'v', 'value'<br>
<br>
ValueError: select_range out of bounds</font><br>
<br>
<br>
However, if my time window is 10 seconds, here's the error then:<br>
<br>
<font face="Courier New">error Traceback (most recent call last)<br>
/usr/lib/python2.7/dist-packages/IPython/utils/py3compat.pyc in execfile(fname, *where)<br>
173 else:<br>
174 filename = fname<br>
--> 175 __builtin__.execfile(filename, *where)<br>
<br>
/home/silfves1/mne-python/examples/omatfunktiot/jatk_off.py in <module>()<br>
380 <br>
381 <br>
--> 382 stc = compute_source_psd_epochs(epochs=ep, inverse_operator=inverse_operator, lambda2=lambda2, method=method, fmin=15.0, fmax=25.0, pick_ori=None, pca=True, bandwidth=bandwidth, n_jobs=10, return_generator=False)<br>
383 <br>
384 <br>
<br>
/home/silfves1/.local/lib/python2.7/site-packages/mne-0.8.git-py2.7.egg/mne/minimum_norm/time_frequency.pyc in compute_source_psd_epochs(epochs, inverse_operator, lambda2, method, fmin, fmax, pick_ori, label, nave, pca, inv_split, bandwidth, adaptive, low_bias,
return_generator, n_jobs, verbose, pick_normal)<br>
<br>
/home/silfves1/.local/lib/python2.7/site-packages/mne-0.8.git-py2.7.egg/mne/utils.pyc in verbose(function, *args, **kwargs)<br>
549 return ret<br>
550 else:<br>
--> 551 ret = function(*args, **kwargs)<br>
552 return ret<br>
553 <br>
<br>
/home/silfves1/.local/lib/python2.7/site-packages/mne-0.8.git-py2.7.egg/mne/minimum_norm/time_frequency.pyc in compute_source_psd_epochs(epochs, inverse_operator, lambda2, method, fmin, fmax, pick_ori, label, nave, pca, inv_split, bandwidth, adaptive, low_bias,
return_generator, n_jobs, verbose, pick_normal)<br>
669 # return a list<br>
<br>
670 stcs = list()<br>
--> 671 for stc in stcs_gen:<br>
672 stcs.append(stc)<br>
673 <br>
<br>
/home/silfves1/.local/lib/python2.7/site-packages/mne-0.8.git-py2.7.egg/mne/minimum_norm/time_frequency.pyc in _compute_source_psd_epochs(epochs, inverse_operator, lambda2, method, fmin, fmax, pick_ori, label, nave, pca, inv_split, bandwidth, adaptive, low_bias,
n_jobs, verbose)<br>
545 <br>
546 # compute tapered spectra in sensor space<br>
<br>
--> 547 x_mt, freqs = _mt_spectra(data, dpss, sfreq)<br>
548 <br>
549 if k == 0:<br>
<br>
/home/silfves1/.local/lib/python2.7/site-packages/mne-0.8.git-py2.7.egg/mne/time_frequency/multitaper.pyc in _mt_spectra(x, dpss, sfreq, n_fft)<br>
439 # remove mean (do not use in-place subtraction as it may modify input x)<br>
<br>
440 x = x - np.mean(x, axis=-1)[:, np.newaxis]<br>
--> 441 x_mt = fftpack.fft(x[:, np.newaxis, :] * dpss, n=n_fft)<br>
442 <br>
443 # only keep positive frequencies<br>
<br>
<br>
/usr/lib/python2.7/dist-packages/scipy/fftpack/basic.pyc in fft(x, n, axis, overwrite_x)<br>
213 <br>
214 if axis == -1 or axis == len(tmp.shape) - 1:<br>
--> 215 return work_function(tmp,n,1,0,overwrite_x)<br>
216 <br>
217 tmp = swapaxes(tmp, axis, -1)<br>
<br>
error: failed in converting 1st argument `x' of _fftpack.zrfft to C/Fortran array</font><br>
<br>
I don't know, why these error come up. Do some of you have any ideas to help? Thank you so much!<br>
<br>
Best regards<span><font color="#888888"><br>
<br>
Sebastian<br>
</font></span></div>
</div>
<br></div></div><div>
_______________________________________________<br>
Mne_analysis mailing list<br>
<a href="mailto:Mne_analysis@nmr.mgh.harvard.edu" target="_blank">Mne_analysis@nmr.mgh.harvard.edu</a><br>
<a href="https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis" target="_blank">https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis</a><br>
<br>
<br>
The information in this e-mail is intended only for the person to whom it is<br>
addressed. If you believe this e-mail was sent to you in error and the e-mail<br>
contains patient information, please contact the Partners Compliance HelpLine at<br>
<a href="http://www.partners.org/complianceline" target="_blank">http://www.partners.org/complianceline</a> . If the e-mail was sent to you in error<br>
but does not contain patient information, please contact the sender and properly<br>
dispose of the e-mail.<br>
<br>
</div></blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</div>
<br>_______________________________________________<br>
Mne_analysis mailing list<br>
<a href="mailto:Mne_analysis@nmr.mgh.harvard.edu" target="_blank">Mne_analysis@nmr.mgh.harvard.edu</a><br>
<a href="https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis" target="_blank">https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis</a><br>
<br>
<br>
The information in this e-mail is intended only for the person to whom it is<br>
addressed. If you believe this e-mail was sent to you in error and the e-mail<br>
contains patient information, please contact the Partners Compliance HelpLine at<br>
<a href="http://www.partners.org/complianceline" target="_blank">http://www.partners.org/complianceline</a> . If the e-mail was sent to you in error<br>
but does not contain patient information, please contact the sender and properly<br>
dispose of the e-mail.<br>
<br></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
Mne_analysis mailing list<br>
<a href="mailto:Mne_analysis@nmr.mgh.harvard.edu">Mne_analysis@nmr.mgh.harvard.edu</a><br>
<a href="https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis" target="_blank">https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis</a><br>
<br>
<br>
The information in this e-mail is intended only for the person to whom it is<br>
addressed. If you believe this e-mail was sent to you in error and the e-mail<br>
contains patient information, please contact the Partners Compliance HelpLine at<br>
<a href="http://www.partners.org/complianceline" target="_blank">http://www.partners.org/complianceline</a> . If the e-mail was sent to you in error<br>
but does not contain patient information, please contact the sender and properly<br>
dispose of the e-mail.<br>
<br></blockquote></div><br></div></div>