@@ -1317,7 +1317,7 @@ def add_foci(self, coords, coords_as_verts=False, map_surface=None,
1317
1317
1318
1318
def add_contour_overlay (self , source , min = None , max = None ,
1319
1319
n_contours = 7 , line_width = 1.5 , colormap = "YlOrRd_r" ,
1320
- hemi = None ):
1320
+ hemi = None , remove_existing = True , colorbar = True ):
1321
1321
"""Add a topographic contour overlay of the positive data.
1322
1322
1323
1323
Note: This visualization will look best when using the "low_contrast"
@@ -1343,6 +1343,11 @@ def add_contour_overlay(self, source, min=None, max=None,
1343
1343
If None, it is assumed to belong to the hemipshere being
1344
1344
shown. If two hemispheres are being shown, an error will
1345
1345
be thrown.
1346
+ remove_existing : bool
1347
+ If there is an existing contour overlay, remove it before plotting.
1348
+ colorbar : bool
1349
+ If True, show the colorbar for the scalar value.
1350
+
1346
1351
"""
1347
1352
hemi = self ._check_hemi (hemi )
1348
1353
@@ -1354,10 +1359,11 @@ def add_contour_overlay(self, source, min=None, max=None,
1354
1359
scalar_data = _prepare_data (scalar_data )
1355
1360
1356
1361
# Maybe get rid of an old overlay
1357
- if hasattr (self , "contour" ):
1362
+ if hasattr (self , "contour" ) and remove_existing :
1358
1363
for c in self .contour_list :
1359
1364
c ['surface' ].remove ()
1360
- c ['colorbar' ].visible = False
1365
+ if c ['colorbar' ] is not None :
1366
+ c ['colorbar' ].visible = False
1361
1367
1362
1368
# Process colormap argument into a lut
1363
1369
lut = create_color_lut (colormap )
@@ -1369,7 +1375,8 @@ def add_contour_overlay(self, source, min=None, max=None,
1369
1375
cl .append (brain ['brain' ].add_contour_overlay (scalar_data ,
1370
1376
min , max ,
1371
1377
n_contours ,
1372
- line_width , lut ))
1378
+ line_width , lut ,
1379
+ colorbar ))
1373
1380
self .contour_list = cl
1374
1381
self ._toggle_render (True , views )
1375
1382
@@ -2523,7 +2530,8 @@ def add_foci(self, foci_coords, scale_factor, color, alpha, name):
2523
2530
return points
2524
2531
2525
2532
def add_contour_overlay (self , scalar_data , min = None , max = None ,
2526
- n_contours = 7 , line_width = 1.5 , lut = None ):
2533
+ n_contours = 7 , line_width = 1.5 , lut = None ,
2534
+ colorbar = True ):
2527
2535
"""Add a topographic contour overlay of the positive data"""
2528
2536
# Set up the pipeline
2529
2537
mesh = mlab .pipeline .triangular_mesh_source (self ._geo .x , self ._geo .y ,
@@ -2546,6 +2554,8 @@ def add_contour_overlay(self, scalar_data, min=None, max=None,
2546
2554
bar .data_range = min , max
2547
2555
self ._format_cbar_text (bar )
2548
2556
bar .scalar_bar_representation .position2 = .8 , 0.09
2557
+ if not colorbar :
2558
+ bar .visible = False
2549
2559
2550
2560
# Set up a dict attribute with pointers at important things
2551
2561
return dict (surface = surf , colorbar = bar )
0 commit comments