[Mne_analysis] Index errors with PySurfer real-time source estimate visualization

Silfverberg Sebastian sebastian.silfverberg at aalto.fi
Tue Jul 22 07:44:58 EDT 2014
Search archives:

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20140722/5088b27d/attachment.html 


More information about the Mne_analysis mailing list