@@ -307,13 +307,16 @@ class Brain(object):
307
307
this to ``None`` is equivalent to ``(0.5, 0.5, 0.5)``.
308
308
3. The name of a colormap used to render binarized
309
309
curvature values, e.g., ``Grays``.
310
- 4. A container with four entries for colormap (string
310
+ 4. A list of colors used to render binarized curvature
311
+ values. Only the first and last colors are used. E.g.,
312
+ ['red', 'blue'] or [(1, 0, 0), (0, 0, 1)].
313
+ 5. A container with four entries for colormap (string
311
314
specifiying the name of a colormap), vmin (float
312
315
specifying the minimum value for the colormap), vmax
313
316
(float specifying the maximum value for the colormap),
314
317
and reverse (bool specifying whether the colormap
315
318
should be reversed. E.g., ``('Greys', -1, 2, False)``.
316
- 5 . A dict of keyword arguments that is passed on to the
319
+ 6 . A dict of keyword arguments that is passed on to the
317
320
call to surface.
318
321
alpha : float in [0, 1]
319
322
Alpha level to control opacity of the cortical surface.
@@ -577,11 +580,18 @@ def _get_geo_params(self, cortex, alpha=1.0):
577
580
if 'vmax' not in cortex :
578
581
cortex ['vmax' ] = 2
579
582
geo_params = cortex , False , True
580
- elif cortex in colormap_map :
581
- geo_params = colormap_map [cortex ]
582
- elif cortex in lut_manager .lut_mode_list ():
583
- geo_params = dict (colormap = cortex , vmin = - 1 , vmax = 2 ,
584
- opacity = alpha ), False , True
583
+ elif isinstance (cortex , basestring ):
584
+ if cortex in colormap_map :
585
+ geo_params = colormap_map [cortex ]
586
+ elif cortex in lut_manager .lut_mode_list ():
587
+ geo_params = dict (colormap = cortex , vmin = - 1 , vmax = 2 ,
588
+ opacity = alpha ), False , True
589
+ else :
590
+ try :
591
+ color = colorConverter .to_rgb (cortex )
592
+ geo_params = dict (color = color , opacity = alpha ), False , False
593
+ except ValueError :
594
+ pass
585
595
# check for None before checking len:
586
596
elif cortex is None :
587
597
geo_params = dict (color = (0.5 , 0.5 , 0.5 ),
@@ -590,16 +600,20 @@ def _get_geo_params(self, cortex, alpha=1.0):
590
600
# avoid 4 letter strings and 4-tuples not specifying a
591
601
# colormap name in the first position (color can be specified
592
602
# as RGBA tuple, but the A value will be dropped by to_rgb()):
593
- elif (not isinstance (cortex , basestring )) and (len (cortex ) == 4 ) and (
594
- isinstance (cortex [0 ], basestring )):
603
+ elif (len (cortex ) == 4 ) and (isinstance (cortex [0 ], basestring )):
595
604
geo_params = dict (colormap = cortex [0 ], vmin = cortex [1 ],
596
605
vmax = cortex [2 ], opacity = alpha ), cortex [3 ], True
597
606
else :
598
- try :
607
+ try : # check if it's a non-string color specification
599
608
color = colorConverter .to_rgb (cortex )
600
609
geo_params = dict (color = color , opacity = alpha ), False , False
601
610
except ValueError :
602
- geo_params = cortex , False , True
611
+ try :
612
+ lut = create_color_lut (cortex )
613
+ geo_params = dict (colormap = "Greys" , opacity = alpha ,
614
+ lut = lut ), False , True
615
+ except ValueError :
616
+ geo_params = cortex , False , True
603
617
return geo_params
604
618
605
619
def get_data_properties (self ):
@@ -2480,9 +2494,17 @@ def __init__(self, subject_id, hemi, surf, figure, geo, geo_curv,
2480
2494
# add surface normals
2481
2495
self ._geo_mesh .data .point_data .normals = self ._geo .nn
2482
2496
self ._geo_mesh .data .cell_data .normals = None
2497
+ if 'lut' in geo_kwargs :
2498
+ # create a new copy we can modify:
2499
+ geo_kwargs = dict (geo_kwargs )
2500
+ lut = geo_kwargs .pop ('lut' )
2501
+ else :
2502
+ lut = None
2483
2503
self ._geo_surf = mlab .pipeline .surface (self ._geo_mesh ,
2484
2504
figure = self ._f , reset_zoom = True ,
2485
2505
** geo_kwargs )
2506
+ if lut is not None :
2507
+ self ._geo_surf .module_manager .scalar_lut_manager .lut .table = lut
2486
2508
if geo_curv and geo_reverse :
2487
2509
curv_bar = mlab .scalarbar (self ._geo_surf )
2488
2510
curv_bar .reverse_lut = True
0 commit comments