@@ -991,18 +991,19 @@ def add_annotation(self, annot, borders=True, alpha=1, hemi=None,
991
991
self .annot_list = al
992
992
self ._toggle_render (True , views )
993
993
994
- def add_label (self , label , color = "crimson" , alpha = 1 , scalar_thresh = None ,
994
+ def add_label (self , label , color = None , alpha = 1 , scalar_thresh = None ,
995
995
borders = False , hemi = None , subdir = None ):
996
996
"""Add an ROI label to the image.
997
997
998
998
Parameters
999
999
----------
1000
1000
label : str | instance of Label
1001
1001
label filepath or name. Can also be an instance of
1002
- an object with attributes "hemi", "vertices", "name",
1003
- and (if scalar_thresh is not None) "values" .
1002
+ an object with attributes "hemi", "vertices", "name", and
1003
+ optionally "color" and "values" (if scalar_thresh is not None).
1004
1004
color : matplotlib-style color
1005
- anything matplotlib accepts: string, RGB, hex, etc.
1005
+ anything matplotlib accepts: string, RGB, hex, etc. (default
1006
+ "crimson")
1006
1007
alpha : float in [0, 1]
1007
1008
alpha level to control opacity
1008
1009
scalar_thresh : None or number
@@ -1028,6 +1029,9 @@ def add_label(self, label, color="crimson", alpha=1, scalar_thresh=None,
1028
1029
"""
1029
1030
if isinstance (label , basestring ):
1030
1031
hemi = self ._check_hemi (hemi )
1032
+ if color is None :
1033
+ color = "crimson"
1034
+
1031
1035
if os .path .isfile (label ):
1032
1036
filepath = label
1033
1037
label_name = os .path .basename (filepath ).split ('.' )[1 ]
@@ -1058,6 +1062,13 @@ def add_label(self, label, color="crimson", alpha=1, scalar_thresh=None,
1058
1062
label_name = 'unnamed'
1059
1063
else :
1060
1064
label_name = str (label .name )
1065
+
1066
+ if color is None :
1067
+ if hasattr (label , 'color' ) and label .color is not None :
1068
+ color = label .color
1069
+ else :
1070
+ color = "crimson"
1071
+
1061
1072
if scalar_thresh is not None :
1062
1073
scalars = label .values
1063
1074
except Exception :
0 commit comments