@@ -1196,7 +1196,7 @@ def time_label(x):
1196
1196
self ._toggle_render (True , views )
1197
1197
1198
1198
def add_annotation (self , annot , borders = True , alpha = 1 , hemi = None ,
1199
- remove_existing = True ):
1199
+ remove_existing = True , color = None ):
1200
1200
"""Add an annotation file.
1201
1201
1202
1202
Parameters
@@ -1220,6 +1220,10 @@ def add_annotation(self, annot, borders=True, alpha=1, hemi=None,
1220
1220
for both hemispheres.
1221
1221
remove_existing : bool
1222
1222
If True (default), remove old annotations.
1223
+ color : matplotlib-style color code
1224
+ If used, show all annotations in the same (specified) color.
1225
+ Probably useful only when showing annotation borders.
1226
+
1223
1227
"""
1224
1228
hemis = self ._check_hemis (hemi )
1225
1229
@@ -1292,6 +1296,12 @@ def add_annotation(self, annot, borders=True, alpha=1, hemi=None,
1292
1296
alpha_vec = cmap [:, 3 ]
1293
1297
alpha_vec [alpha_vec > 0 ] = alpha * 255
1294
1298
1299
+ # Override the cmap when a single color is used
1300
+ if color is not None :
1301
+ from matplotlib .colors import colorConverter
1302
+ rgb = np .round (np .multiply (colorConverter .to_rgb (color ), 255 ))
1303
+ cmap [:, :3 ] = rgb .astype (cmap .dtype )
1304
+
1295
1305
for brain in self ._brain_list :
1296
1306
if brain ['hemi' ] == hemi :
1297
1307
self .annot_list .append (
0 commit comments