[Mne_analysis] Index errors with PySurfer real-time source estimate visualization
Eric Larson
larson.eric.d at gmail.com
Wed Jul 23 01:48:09 EDT 2014
I'd suggest giving the PySurfer development version a try, and if it
doesn't work, open an issue on the PySurfer github site and we can sort it
out there:
https://github.com/nipy/PySurfer
Working with manually plotting data on surfaces, it can sometimes be tricky
to get the indexing right. Instead of manually calling PySurfer's
`add_data`, does it work if you call `stc.plot()` on the mne-python
SourceEstimate object to display the new data? If so, then you can dig into
the mne-python visualization code to see how the data is being displayed
there in order to figure out what's going wrong.
Eric
On Tue, Jul 22, 2014 at 10:32 PM, Silfverberg Sebastian <
sebastian.silfverberg at aalto.fi> wrote:
> I have version 0.5 which I think is the newest version.
> ------------------------------
> *Lähettäjä:* mne_analysis-bounces at nmr.mgh.harvard.edu [
> mne_analysis-bounces at nmr.mgh.harvard.edu] käyttäjän Denis-Alexander
> Engemann [denis.engemann at gmail.com] puolesta
> *Lähetetty:* 22. heinäkuuta 2014 15:00
> *Vastaanottaja:* Discussion and support forum for the users of MNE
> Software
> *Aihe:* Re: [Mne_analysis] Index errors with PySurfer real-time source
> estimate visualization
>
> Hi Sebastian,
>
> before digging deeper,
> which version of PySurfer are you using.
> In my experience usually many problems dissolve with the latest PySurfer
> code.
>
> Best,
> Denis
>
>
> On Tue, Jul 22, 2014 at 1:44 PM, Silfverberg Sebastian <
> sebastian.silfverberg at aalto.fi> wrote:
>
>> Hi everyone!
>>
>> I have been trying to code a program that would enable to plot trigger
>> spesific source estimates in real time with FieldTrip Buffer. I have
>> managed to do that, but I want to optimize it a little more. I would like
>> the program to be able to plot the initial brain surface with PySurfer and
>> then just add and remove estimates from the cortex when the buffer has
>> received a next epoch. I'm using PySurfers Brain()-class and brain.add_data
>> -method. But the brain.add_data -method doesn't work:
>>
>> It always complains about index errors. I've noticed that the index error
>> happens to be in vertices which have to be given in add_data method. Error
>> is for example this:
>>
>> IndexError Traceback (most recent call
>> last)
>> /usr/lib/python2.7/dist-packages/IPython/utils/py3compat.pyc in
>> execfile(fname, *where)
>> 173 else:
>> 174 filename = fname
>> --> 175 __builtin__.execfile(filename, *where)
>>
>> /home/silfves1/mne-python/examples/omatfunktiot/yks_off.py in <module>()
>> 122 stc.tmin + stc.data.shape[1] *
>> stc.tstep,
>> 123 stc.data.shape[1])
>> --> 124 brain.add_data(stc.data, colormap='hot', vertices = stc.vertno,
>> smoothing_steps=20, time=time, time_label='Time 100.0 ms', hemi=hemi,
>> remove_existing=True)
>>
>> 125
>> 126 # for ii, ev in enumerate(epochs.iter_evoked()):
>>
>>
>> /home/silfves1/.local/lib/python2.7/site-packages/pysurfer-0.5-py2.7.egg/surfer/viz.pyc
>> in add_data(self, array, min, max, thresh, colormap, alpha, vertices,
>> smoothing_steps, time, time_label, colorbar, hemi,
>> remove_existing)
>> 835 adj_mat = utils.mesh_edges(self.geo[hemi].faces)
>> 836 smooth_mat = utils.smoothing_matrix(vertices, adj_mat,
>> --> 837 smoothing_steps)
>> 838 else:
>> 839 smooth_mat = None
>>
>> /home/silfves1/.local/lib/python2.7/site-packages/pysurfer-0.5-py2.7.egg/surfer/utils.pyc
>> in dec(*args, **kwargs)
>> 337 return ret
>> 338 else:
>> --> 339 return function(*args, **kwargs)
>> 340
>> 341 # set __wrapped__ attribute so ?? in IPython gets the right
>> source
>>
>>
>> /home/silfves1/.local/lib/python2.7/site-packages/pysurfer-0.5-py2.7.egg/surfer/utils.pyc
>> in smoothing_matrix(vertices, adj_mat, smoothing_steps,
>> verbose)
>>
>> 512 n_iter = smoothing_steps if smoothing_steps is not None else
>> 1000
>> 513 for k in range(n_iter):
>> --> 514 e_use = e[:, idx_use]
>> 515
>> 516 data1 = e_use * np.ones(len(idx_use))
>>
>> /usr/lib/python2.7/dist-packages/scipy/sparse/csr.pyc in
>> __getitem__(self, key)
>> 218 return self._get_submatrix(row, col)
>> #[1:2,j]
>> 219 else:
>> --> 220 P = extractor(col,self.shape[1]).T
>> #[1:2,[1,2]]
>> 221 return self[row,:]*P
>> 222
>>
>> /usr/lib/python2.7/dist-packages/scipy/sparse/csr.pyc in
>> extractor(indices, N)
>> 186 indices = asindices(indices)
>> 187
>> --> 188 (min_indx,max_indx) = check_bounds(indices,N)
>> 189
>> 190 if min_indx < 0:
>>
>> /usr/lib/python2.7/dist-packages/scipy/sparse/csr.pyc in
>> check_bounds(indices, N)
>> 172 max_indx = indices.max()
>> 173 if max_indx >= N:
>> --> 174 raise IndexError('index (%d) out of range' %
>> max_indx)
>> 175
>> 176 min_indx = indices.min()
>>
>> IndexError: index (215242) out of range
>>
>> I don't know how to fix this. Is the stc.vertno same thing as vertices?
>> I've also tried to remove some indexes from stc.vertno, but it always
>> complains about the ranks not being 1. Do you have any ideas to help me?
>>
>> Best regards
>>
>> Sebastian Silfveberg
>>
>> _______________________________________________
>> Mne_analysis mailing list
>> Mne_analysis at nmr.mgh.harvard.edu
>> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
>>
>>
>> The information in this e-mail is intended only for the person to whom it
>> is
>> addressed. If you believe this e-mail was sent to you in error and the
>> e-mail
>> contains patient information, please contact the Partners Compliance
>> HelpLine at
>> http://www.partners.org/complianceline . If the e-mail was sent to you
>> in error
>> but does not contain patient information, please contact the sender and
>> properly
>> dispose of the e-mail.
>>
>>
>
> _______________________________________________
> Mne_analysis mailing list
> Mne_analysis at nmr.mgh.harvard.edu
> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
>
>
> The information in this e-mail is intended only for the person to whom it
> is
> addressed. If you believe this e-mail was sent to you in error and the
> e-mail
> contains patient information, please contact the Partners Compliance
> HelpLine at
> http://www.partners.org/complianceline . If the e-mail was sent to you in
> error
> but does not contain patient information, please contact the sender and
> properly
> dispose of the e-mail.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20140722/8ebcb26c/attachment.html
More information about the Mne_analysis
mailing list