@@ -1249,7 +1249,8 @@ def add_foci(self, coords, coords_as_verts=False, map_surface=None,
1249
1249
self ._toggle_render (True , views )
1250
1250
1251
1251
def add_contour_overlay (self , source , min = None , max = None ,
1252
- n_contours = 7 , line_width = 1.5 , hemi = None ):
1252
+ n_contours = 7 , line_width = 1.5 , colormap = "RdBu_r" ,
1253
+ hemi = None ):
1253
1254
"""Add a topographic contour overlay of the positive data.
1254
1255
1255
1256
Note: This visualization will look best when using the "low_contrast"
@@ -1267,6 +1268,10 @@ def add_contour_overlay(self, source, min=None, max=None,
1267
1268
number of contours to use in the display
1268
1269
line_width : float
1269
1270
width of contour lines
1271
+ colormap : string, list of colors, or array
1272
+ name of matplotlib colormap to use, a list of matplotlib colors,
1273
+ or a custom look up table (an n x 4 array coded with RBGA values
1274
+ between 0 and 255).
1270
1275
hemi : str | None
1271
1276
If None, it is assumed to belong to the hemipshere being
1272
1277
shown. If two hemispheres are being shown, an error will
@@ -1287,14 +1292,17 @@ def add_contour_overlay(self, source, min=None, max=None,
1287
1292
c ['surface' ].remove ()
1288
1293
c ['colorbar' ].visible = False
1289
1294
1295
+ # Process colormap argument into a lut
1296
+ lut = create_color_lut (colormap )
1297
+
1290
1298
views = self ._toggle_render (False )
1291
1299
cl = []
1292
1300
for brain in self ._brain_list :
1293
1301
if brain ['hemi' ] == hemi :
1294
1302
cl .append (brain ['brain' ].add_contour_overlay (scalar_data ,
1295
1303
min , max ,
1296
1304
n_contours ,
1297
- line_width ))
1305
+ line_width , lut ))
1298
1306
self .contour_list = cl
1299
1307
self ._toggle_render (True , views )
1300
1308
@@ -2243,7 +2251,7 @@ def add_foci(self, foci_coords, scale_factor, color, alpha, name):
2243
2251
return points
2244
2252
2245
2253
def add_contour_overlay (self , scalar_data , min = None , max = None ,
2246
- n_contours = 7 , line_width = 1.5 ):
2254
+ n_contours = 7 , line_width = 1.5 , lut = None ):
2247
2255
"""Add a topographic contour overlay of the positive data"""
2248
2256
# Set up the pipeline
2249
2257
mesh = mlab .pipeline .triangular_mesh_source (self ._geo .x , self ._geo .y ,
@@ -2254,6 +2262,8 @@ def add_contour_overlay(self, scalar_data, min=None, max=None,
2254
2262
thresh = mlab .pipeline .threshold (mesh , low = min )
2255
2263
surf = mlab .pipeline .contour_surface (thresh , contours = n_contours ,
2256
2264
line_width = line_width )
2265
+ if lut is not None :
2266
+ surf .module_manager .scalar_lut_manager .lut .table = lut
2257
2267
2258
2268
# Set the colorbar and range correctly
2259
2269
bar = mlab .scalarbar (surf ,
0 commit comments