def draw_conns(self, new_edges=None): try: self.thres.set(lower_threshold=self.ds.thresval) lo = self.thres.lower_threshold hi = self.thres.upper_threshold set_lut(self.vectors, self.ds.opts.activation_map) if new_edges is not None: new_starts = self.ds.lab_pos[new_edges[:, 0]] new_vecs = self.ds.lab_pos[new_edges[:, 1]] - new_starts self.vectors.mlab_source.reset(x=new_starts[:, 0], y=new_starts[:, 1], z=new_starts[:, 2], u=new_vecs[:, 0], v=new_vecs[:, 1], w=new_vecs[:, 2]) if self.ds.curr_node is not None: self.vectors.actor.property.opacity = .75 self.txt.set(text=' %s' % self.ds.labnam[self.ds.curr_node]) else: self.vectors.actor.property.opacity = ( .5 if self.ds.opts.tube_conns else .3) self.txt.set(text='') mlab.draw() # In case the user changes the threshold while there are no connections # present and so the VTK objects have not been created yet except AttributeError: pass
def draw_conns(self,new_edges=None): try: self.thres.set(lower_threshold=self.ds.thresval) lo=self.thres.lower_threshold; hi=self.thres.upper_threshold set_lut(self.vectors,self.ds.opts.activation_map) if new_edges is not None: new_starts=self.ds.lab_pos[new_edges[:,0]] new_vecs=self.ds.lab_pos[new_edges[:,1]] - new_starts self.vectors.mlab_source.reset( x=new_starts[:,0],y=new_starts[:,1],z=new_starts[:,2], u=new_vecs[:,0],v=new_vecs[:,1],w=new_vecs[:,2]) if self.ds.curr_node is not None: self.vectors.actor.property.opacity=.75 self.txt.set(text=' %s'%self.ds.labnam[self.ds.curr_node]) else: self.vectors.actor.property.opacity=( .5 if self.ds.opts.tube_conns else .3) self.txt.set(text='') mlab.draw() # In case the user changes the threshold while there are no connections # present and so the VTK objects have not been created yet except AttributeError: pass
def surfs_gen(self): self.syrf_lh = mlab.triangular_mesh( self.ds.srf.lh_verts[:, 0], self.ds.srf.lh_verts[:, 1], self.ds.srf.lh_verts[:, 2], self.ds.srf.lh_tris, opacity=self.ds.opts.surface_visibility, color=self.ds.default_glass_brain_color, ) self.syrf_rh = mlab.triangular_mesh( self.ds.srf.rh_verts[:, 0], self.ds.srf.rh_verts[:, 1], self.ds.srf.rh_verts[:, 2], self.ds.srf.rh_tris, opacity=self.ds.opts.surface_visibility, color=self.ds.default_glass_brain_color, ) #some colors #(.4,.75,0) #DARKISH GREEN #(.82,1,.82) #LIGHTER GREEN #(.82,.82,.82) #GRAY self.surfs_cracked = False for syrf in (self.syrf_lh, self.syrf_rh): syrf.actor.actor.pickable = 0 set_lut(syrf, self.ds.opts.scalar_map) self.ds.chg_lh_surfmask() self.ds.chg_rh_surfmask()
def draw_surfs(self): from parsing_utils import demangle_hemi srf_scalar=self.ds.scalar_display_settings.surf_color if (self.ds.display_mode=='scalar' and srf_scalar): colors_lh=np.zeros((len(self.ds.srf.lh_verts)),) colors_rh=np.zeros((len(self.ds.srf.rh_verts)),) for i,l in enumerate(self.ds.labnam): #assumes that lh labels start with L and so on vertices=self.ds.labv[demangle_hemi(l)] if l[0]=='l': colors_lh[vertices]=self.ds.node_scalars[srf_scalar][i] elif l[0]=='r': colors_rh[vertices]=self.ds.node_scalars[srf_scalar][i] self.syrf_lh.mlab_source.scalars=colors_lh self.syrf_rh.mlab_source.scalars=colors_rh for syrf in (self.syrf_lh,self.syrf_rh): set_lut(syrf,self.ds.opts.scalar_map) syrf.actor.mapper.scalar_visibility=True else: for syrf in (self.syrf_lh,self.syrf_rh): syrf.actor.mapper.scalar_visibility=False
def vectors_gen(self): vectorsrc = mlab.pipeline.vector_scatter( self.ds.starts[:, 0], self.ds.starts[:, 1], self.ds.starts[:, 2], self.ds.vecs[:, 0], self.ds.vecs[:, 1], self.ds.vecs[:, 2], figure=self.scene.mayavi_scene) vectorsrc.mlab_source.dataset.point_data.scalars = self.ds.adjdat #thresholding needs to be cleaned up a little bit. the threshold #filter should only be set in draw_conns #reset_thresh should threshold cleanly such that its a valid value. #if its not a valid value, reset_thresh should error check it and set #it to the min or max value that it can have (but print out a warning #saying it did so) self.ds.reset_thresh() self.thres = mlab.pipeline.threshold(vectorsrc, name='threshold', low=self.ds.thresval, up=np.max(self.ds.adjdat), figure=self.scene.mayavi_scene) self.thres.auto_reset_lower = False self.thres.auto_reset_upper = False self.vectors = mlab.pipeline.vectors( self.thres, colormap='black-white', line_width=self.ds.opts.conns_width, scale_mode='vector', figure=self.scene.mayavi_scene) #set dummy colormap value and immediately call set_lut to handle #custom_heat or other nonstandard values of colormap set_lut(self.vectors, self.ds.opts.activation_map) self.vectors.glyph.glyph.clamping = False self.vectors.actor.property.opacity = .3 self.vectors.actor.actor.pickable = False self.set_tubular_properties() set_lut(self.vectors, self.ds.opts.activation_map) self.ds.chg_conns_colors() self.ds.chg_lh_connmask() self.ds.chg_rh_connmask() self.ds.chg_interhemi_connmask() self.ds.chg_conns_colorbar() self.txt.set(text='')
def cracked_surfs_gen(self): from parsing_utils import demangle_hemi tri_inds_l, tri_inds_r = [], [] #all lh nodes are assumed to start with l for l in self.ds.labnam: if l[0] == 'l': tris = self.ds.srf.lh_tris tri_inds = tri_inds_l elif l[0] == 'r': tris = self.ds.srf.rh_tris tri_inds = tri_inds_r else: self.error_dialog('Bad label name %s' % l) return #get the triangles entirely contained in this set of vertices v_as_set = set(self.ds.labv[demangle_hemi(l)]) ts, = np.where([v_as_set.issuperset(tri) for tri in tris]) tri_inds.extend(ts) self.syrf_lh = mlab.triangular_mesh( self.ds.srf.lh_verts[:, 0], self.ds.srf.lh_verts[:, 1], self.ds.srf.lh_verts[:, 2], self.ds.srf.lh_tris[tri_inds_l], opacity=self.ds.opts.surface_visibility, color=self.ds.default_glass_brain_color, figure=self.scene.mayavi_scene) self.syrf_rh = mlab.triangular_mesh( self.ds.srf.rh_verts[:, 0], self.ds.srf.rh_verts[:, 1], self.ds.srf.rh_verts[:, 2], self.ds.srf.rh_tris[tri_inds_r], opacity=self.ds.opts.surface_visibility, color=self.ds.default_glass_brain_color, figure=self.scene.mayavi_scene) self.surfs_cracked = True for syrf in (self.syrf_lh, self.syrf_rh): syrf.actor.actor.pickable = 0 set_lut(syrf, self.ds.opts.scalar_map) self.ds.chg_lh_surfmask() self.ds.chg_rh_surfmask()
def vectors_gen(self): vectorsrc=mlab.pipeline.vector_scatter( self.ds.starts[:,0],self.ds.starts[:,1],self.ds.starts[:,2], self.ds.vecs[:,0],self.ds.vecs[:,1],self.ds.vecs[:,2], figure=self.scene.mayavi_scene) vectorsrc.mlab_source.dataset.point_data.scalars=self.ds.adjdat #thresholding needs to be cleaned up a little bit. the threshold #filter should only be set in draw_conns #reset_thresh should threshold cleanly such that its a valid value. #if its not a valid value, reset_thresh should error check it and set #it to the min or max value that it can have (but print out a warning #saying it did so) self.ds.reset_thresh() self.thres=mlab.pipeline.threshold(vectorsrc,name='threshold', low=self.ds.thresval,up=np.max(self.ds.adjdat), figure=self.scene.mayavi_scene) self.thres.auto_reset_lower=False self.thres.auto_reset_upper=False self.vectors=mlab.pipeline.vectors(self.thres, colormap='black-white', line_width=self.ds.opts.conns_width, scale_mode='vector',figure=self.scene.mayavi_scene) #set dummy colormap value and immediately call set_lut to handle #custom_heat or other nonstandard values of colormap set_lut(self.vectors,self.ds.opts.activation_map) self.vectors.glyph.glyph.clamping=False self.vectors.actor.property.opacity=.3 self.vectors.actor.actor.pickable=False self.set_tubular_properties() set_lut(self.vectors,self.ds.opts.activation_map) self.ds.chg_conns_colors() self.ds.chg_lh_connmask(); self.ds.chg_rh_connmask() self.ds.chg_interhemi_connmask(); self.ds.chg_conns_colorbar() self.txt.set(text='')
def surfs_gen(self): self.syrf_lh = mlab.triangular_mesh( self.ds.srf.lh_verts[:,0],self.ds.srf.lh_verts[:,1], self.ds.srf.lh_verts[:,2],self.ds.srf.lh_tris, opacity=self.ds.opts.surface_visibility, color=self.ds.default_glass_brain_color,) self.syrf_rh = mlab.triangular_mesh( self.ds.srf.rh_verts[:,0],self.ds.srf.rh_verts[:,1], self.ds.srf.rh_verts[:,2],self.ds.srf.rh_tris, opacity=self.ds.opts.surface_visibility, color=self.ds.default_glass_brain_color,) #some colors #(.4,.75,0) #DARKISH GREEN #(.82,1,.82) #LIGHTER GREEN #(.82,.82,.82) #GRAY self.surfs_cracked=False for syrf in (self.syrf_lh,self.syrf_rh): syrf.actor.actor.pickable=0 set_lut(syrf,self.ds.opts.scalar_map) self.ds.chg_lh_surfmask(); self.ds.chg_rh_surfmask()
def cracked_surfs_gen(self): from parsing_utils import demangle_hemi tri_inds_l,tri_inds_r=[],[] #all lh nodes are assumed to start with l for l in self.ds.labnam: if l[0]=='l': tris=self.ds.srf.lh_tris; tri_inds=tri_inds_l elif l[0]=='r': tris=self.ds.srf.rh_tris; tri_inds=tri_inds_r else: self.error_dialog('Bad label name %s'%l) return #get the triangles entirely contained in this set of vertices v_as_set=set(self.ds.labv[demangle_hemi(l)]) ts,=np.where([v_as_set.issuperset(tri) for tri in tris]) tri_inds.extend(ts) self.syrf_lh=mlab.triangular_mesh( self.ds.srf.lh_verts[:,0],self.ds.srf.lh_verts[:,1], self.ds.srf.lh_verts[:,2],self.ds.srf.lh_tris[tri_inds_l], opacity=self.ds.opts.surface_visibility, color=self.ds.default_glass_brain_color, figure=self.scene.mayavi_scene) self.syrf_rh=mlab.triangular_mesh( self.ds.srf.rh_verts[:,0],self.ds.srf.rh_verts[:,1], self.ds.srf.rh_verts[:,2],self.ds.srf.rh_tris[tri_inds_r], opacity=self.ds.opts.surface_visibility, color=self.ds.default_glass_brain_color, figure=self.scene.mayavi_scene) self.surfs_cracked=True for syrf in (self.syrf_lh,self.syrf_rh): syrf.actor.actor.pickable=0 set_lut(syrf,self.ds.opts.scalar_map) self.ds.chg_lh_surfmask(); self.ds.chg_rh_surfmask()
def draw_nodes(self): nc=self.ds.scalar_display_settings.node_color ns=self.ds.scalar_display_settings.node_size lhn=self.nodes_lh; lhn_ix=self.ds.lhnodes rhn=self.nodes_rh; rhn_ix=self.ds.rhnodes for nodes,ixes in ((lhn,lhn_ix),(rhn,rhn_ix)): nr=len(ixes) #set node size if self.ds.display_mode=='scalar' and ns: nodes.glyph.scale_mode='scale_by_vector' nodes.glyph.glyph.scale_factor=8 nodes.mlab_source.dataset.point_data.vectors=( np.tile(self.ds.node_scalars[ns][ixes],(3,1)).T) else: nodes.glyph.scale_mode='data_scaling_off' nodes.glyph.glyph.scale_factor=3 #set node color -- we dont care about ds.node_colors for mayavi if (self.ds.display_mode=='normal' or (self.ds.display_mode=='scalar' and not nc)): set_lut(nodes,self.ds.opts.default_map) nodes.mlab_source.dataset.point_data.scalars=np.tile(.3,nr) elif self.ds.display_mode=='scalar': #and nc must be true set_lut(nodes,self.ds.opts.scalar_map) nodes.mlab_source.dataset.point_data.scalars=( self.ds.node_scalars[nc][ixes]) elif self.ds.display_mode=='module_single': set_lut(nodes,self.ds.opts.default_map) new_colors=np.tile(.3,self.ds.nr_labels) new_colors[self.ds.get_module()]=.8 nodes.mlab_source.dataset.point_data.scalars=new_colors[ixes] elif self.ds.display_mode=='module_multi': new_colors=np.array(self.ds.module_colors[:self.ds.nr_modules]) manager=nodes.module_manager.scalar_lut_manager #set the mayavi object to the dummy cmap that we hide from user #so that when changed notifications will work correctly manager.lut_mode='black-white' #now adjust its LUT manually manager.number_of_colors=self.ds.nr_modules manager.lut.table=new_colors #set the mayavi scalars to be fractions between 0 and 1 import bct nodes.mlab_source.dataset.point_data.scalars=(bct.ls2ci( self.ds.modules,zeroindexed=True)/self.ds.nr_modules)[ixes] mlab.draw()
def draw_nodes(self): nc = self.ds.scalar_display_settings.node_color ns = self.ds.scalar_display_settings.node_size lhn = self.nodes_lh lhn_ix = self.ds.lhnodes rhn = self.nodes_rh rhn_ix = self.ds.rhnodes for nodes, ixes in ((lhn, lhn_ix), (rhn, rhn_ix)): nr = len(ixes) #set node size if self.ds.display_mode == 'scalar' and ns: scalars = self.ds.node_scalars[ns] #for node size, the scalars need to be scaled to 0-1 scalars = (scalars - np.min(scalars)) / (np.max(scalars) - np.min(scalars)) #logarithmic scaling does a better job of differentiating large nodes scalars = (np.exp(scalars * np.log(2)) - 1) / (np.e - 1) #scalars=(4**(scalars*np.log(3)/np.log(4))-1)/3 #scalars=(4**scalars-1)/3 #scalars**=2 nodes.glyph.scale_mode = 'scale_by_vector' nodes.glyph.glyph.scale_factor = 12 nodes.mlab_source.dataset.point_data.vectors = (np.tile( scalars[ixes], (3, 1)).T) else: nodes.glyph.scale_mode = 'data_scaling_off' nodes.glyph.glyph.scale_factor = 3 #set node color -- we dont care about ds.node_colors for mayavi if (self.ds.display_mode == 'normal' or (self.ds.display_mode == 'scalar' and not nc) or (self.ds.display_mode in ['module_single', 'module_multi'] and self.ds.opts.modules_on_surface)): scalars = np.tile(.3, nr) set_lut(nodes, self.ds.opts.default_map) set_color_range(nodes, (0., 1.)) nodes.mlab_source.dataset.point_data.scalars = scalars elif self.ds.display_mode == 'scalar': #and nc must be true scalars = self.ds.node_scalars[nc] set_lut(nodes, self.ds.opts.scalar_map) set_color_range(nodes, scalars) nodes.mlab_source.dataset.point_data.scalars = scalars[ixes] elif self.ds.display_mode == 'module_single': scalars = np.tile(.3, self.ds.nr_labels) scalars[self.ds.get_module()] = .8 set_lut(nodes, self.ds.opts.default_map) set_color_range(nodes, (0., 1.)) nodes.mlab_source.dataset.point_data.scalars = scalars[ixes] elif self.ds.display_mode == 'module_multi': new_colors = np.array( self.ds.module_colors[:self.ds.nr_modules + 1]) manager = nodes.module_manager.scalar_lut_manager #set the mayavi object to the dummy cmap that we hide from user #so that when changed notifications will work correctly manager.lut_mode = 'black-white' #now adjust its LUT manually manager.number_of_colors = self.ds.nr_modules manager.lut.table = new_colors #set the mayavi scalars to be fractions between 0 and 1 import bct nodes.mlab_source.dataset.point_data.scalars = (bct.ls2ci( self.ds.modules, zeroindexed=True))[ixes] + 1 set_color_range(nodes, (0., self.ds.nr_modules + 1)) mlab.draw()
def draw_surfs(self): from parsing_utils import demangle_hemi srf_scalar = self.ds.scalar_display_settings.surf_color nc = self.ds.scalar_display_settings.node_color if (self.ds.display_mode == 'scalar' and srf_scalar): scalars = self.ds.node_scalars[srf_scalar] colors_lh = np.zeros((len(self.ds.srf.lh_verts)), ) colors_rh = np.zeros((len(self.ds.srf.rh_verts)), ) for i, l in enumerate(self.ds.labnam): #assumes that lh labels start with L and so on vertices = self.ds.labv[demangle_hemi(l)] if l[0] == 'l': colors_lh[vertices] = scalars[i] elif l[0] == 'r': colors_rh[vertices] = scalars[i] self.syrf_lh.mlab_source.scalars = colors_lh self.syrf_rh.mlab_source.scalars = colors_rh for syrf in (self.syrf_lh, self.syrf_rh): set_lut(syrf, self.ds.opts.scalar_map) set_color_range(syrf, scalars) syrf.actor.mapper.scalar_visibility = True #we don't need to set the scalars properly, but lets set the scalar range #of the surface properly so that a colorbar will capture it elif (self.ds.display_mode == 'scalar' and nc): scalars = self.ds.node_scalars[nc] #the scalar colorbar refers to syrf_lh only min_scale, max_scale = np.min(scalars), np.max(scalars) colors = np.tile(min_scale, (len(self.ds.srf.lh_verts), )) colors[0] = max_scale self.syrf_lh.mlab_source.scalars = colors for syrf in (self.syrf_lh, self.syrf_rh): syrf.actor.mapper.scalar_visibility = False elif (self.ds.display_mode == 'module_multi' and self.ds.opts.modules_on_surface): new_colors = np.array(self.ds.module_colors[:self.ds.nr_modules + 1]) for syrf, nodes, letter, verts in ((self.syrf_lh, self.ds.lhnodes, 'l', self.ds.srf.lh_verts), (self.syrf_rh, self.ds.rhnodes, 'r', self.ds.srf.rh_verts)): colors = np.zeros((len(verts)), ) manager = syrf.module_manager.scalar_lut_manager #set the mayavi object to the dummy cmap #so that when changed notifications will work correctly manager.lut_mode = 'black-white' #now adjust its LUT manually manager.number_of_colors = self.ds.nr_modules manager.lut.table = new_colors import bct ci = bct.ls2ci(self.ds.modules, zeroindexed=True)[nodes] i = 0 for l in self.ds.labnam: #assumes that lh labels start with L and so on if not l[0] == letter: continue vertices = self.ds.labv[demangle_hemi(l)] colors[vertices] = ci[i] + 1 i += 1 syrf.mlab_source.scalars = colors set_color_range(syrf, (0., self.ds.nr_modules + 1)) syrf.actor.mapper.scalar_visibility = True else: for syrf in (self.syrf_lh, self.syrf_rh): syrf.actor.mapper.scalar_visibility = False
def draw_nodes(self): nc=self.ds.scalar_display_settings.node_color ns=self.ds.scalar_display_settings.node_size lhn=self.nodes_lh; lhn_ix=self.ds.lhnodes rhn=self.nodes_rh; rhn_ix=self.ds.rhnodes for nodes,ixes in ((lhn,lhn_ix),(rhn,rhn_ix)): nr=len(ixes) #set node size if self.ds.display_mode=='scalar' and ns: scalars = self.ds.node_scalars[ns] #for node size, the scalars need to be scaled to 0-1 scalars = (scalars-np.min(scalars)) / (np.max(scalars)-np.min(scalars)) #logarithmic scaling does a better job of differentiating large nodes scalars = (np.exp(scalars*np.log(2))-1)/(np.e-1) #scalars=(4**(scalars*np.log(3)/np.log(4))-1)/3 #scalars=(4**scalars-1)/3 #scalars**=2 nodes.glyph.scale_mode='scale_by_vector' nodes.glyph.glyph.scale_factor=12 nodes.mlab_source.dataset.point_data.vectors=( np.tile(scalars[ixes],(3,1)).T) else: nodes.glyph.scale_mode='data_scaling_off' nodes.glyph.glyph.scale_factor=3 #set node color -- we dont care about ds.node_colors for mayavi if (self.ds.display_mode=='normal' or (self.ds.display_mode=='scalar' and not nc) or (self.ds.display_mode in ['module_single', 'module_multi'] and self.ds.opts.modules_on_surface)): scalars = np.tile(.3, nr) set_lut(nodes, self.ds.opts.default_map) set_color_range(nodes, (0.,1.)) nodes.mlab_source.dataset.point_data.scalars = scalars elif self.ds.display_mode=='scalar': #and nc must be true scalars = self.ds.node_scalars[nc] set_lut(nodes, self.ds.opts.scalar_map) set_color_range(nodes, scalars) nodes.mlab_source.dataset.point_data.scalars = scalars[ixes] elif self.ds.display_mode=='module_single': scalars = np.tile(.3, self.ds.nr_labels) scalars[self.ds.get_module()]=.8 set_lut(nodes, self.ds.opts.default_map) set_color_range(nodes, (0.,1.)) nodes.mlab_source.dataset.point_data.scalars = scalars[ixes] elif self.ds.display_mode=='module_multi': new_colors=np.array(self.ds.module_colors[ :self.ds.nr_modules+1]) manager=nodes.module_manager.scalar_lut_manager #set the mayavi object to the dummy cmap that we hide from user #so that when changed notifications will work correctly manager.lut_mode='black-white' #now adjust its LUT manually manager.number_of_colors=self.ds.nr_modules manager.lut.table=new_colors #set the mayavi scalars to be fractions between 0 and 1 import bct nodes.mlab_source.dataset.point_data.scalars=(bct.ls2ci( self.ds.modules,zeroindexed=True))[ixes]+1 set_color_range(nodes, (0., self.ds.nr_modules+1)) mlab.draw()
def draw_surfs(self): from parsing_utils import demangle_hemi srf_scalar=self.ds.scalar_display_settings.surf_color nc = self.ds.scalar_display_settings.node_color if (self.ds.display_mode=='scalar' and srf_scalar): scalars = self.ds.node_scalars[srf_scalar] colors_lh=np.zeros((len(self.ds.srf.lh_verts)),) colors_rh=np.zeros((len(self.ds.srf.rh_verts)),) for i,l in enumerate(self.ds.labnam): #assumes that lh labels start with L and so on vertices=self.ds.labv[demangle_hemi(l)] if l[0]=='l': colors_lh[vertices] = scalars[i] elif l[0]=='r': colors_rh[vertices] = scalars[i] self.syrf_lh.mlab_source.scalars=colors_lh self.syrf_rh.mlab_source.scalars=colors_rh for syrf in (self.syrf_lh,self.syrf_rh): set_lut(syrf,self.ds.opts.scalar_map) set_color_range(syrf, scalars) syrf.actor.mapper.scalar_visibility=True #we don't need to set the scalars properly, but lets set the scalar range #of the surface properly so that a colorbar will capture it elif (self.ds.display_mode=='scalar' and nc): scalars = self.ds.node_scalars[nc] #the scalar colorbar refers to syrf_lh only min_scale, max_scale = np.min(scalars), np.max(scalars) colors = np.tile(min_scale, (len(self.ds.srf.lh_verts),)) colors[0] = max_scale self.syrf_lh.mlab_source.scalars = colors for syrf in (self.syrf_lh,self.syrf_rh): syrf.actor.mapper.scalar_visibility=False elif (self.ds.display_mode=='module_multi' and self.ds.opts.modules_on_surface): new_colors=np.array(self.ds.module_colors[:self.ds.nr_modules+1]) for syrf,nodes,letter,verts in ( (self.syrf_lh,self.ds.lhnodes,'l',self.ds.srf.lh_verts), (self.syrf_rh,self.ds.rhnodes,'r',self.ds.srf.rh_verts)): colors=np.zeros((len(verts)),) manager=syrf.module_manager.scalar_lut_manager #set the mayavi object to the dummy cmap #so that when changed notifications will work correctly manager.lut_mode='black-white' #now adjust its LUT manually manager.number_of_colors=self.ds.nr_modules manager.lut.table=new_colors import bct ci = bct.ls2ci(self.ds.modules,zeroindexed=True)[nodes] i = 0 for l in self.ds.labnam: #assumes that lh labels start with L and so on if not l[0]==letter: continue vertices=self.ds.labv[demangle_hemi(l)] colors[vertices] = ci[i]+1 i+=1 syrf.mlab_source.scalars = colors set_color_range(syrf, (0., self.ds.nr_modules+1)) syrf.actor.mapper.scalar_visibility=True else: for syrf in (self.syrf_lh,self.syrf_rh): syrf.actor.mapper.scalar_visibility=False