@@ -991,8 +991,8 @@ 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 ,
995
- scalar_thresh = None , borders = False , hemi = None ):
994
+ def add_label (self , label , color = "crimson" , alpha = 1 , scalar_thresh = None ,
995
+ borders = False , hemi = None , subdir = None ):
996
996
"""Add an ROI label to the image.
997
997
998
998
Parameters
@@ -1015,6 +1015,12 @@ def add_label(self, label, color="crimson", alpha=1,
1015
1015
If None, it is assumed to belong to the hemipshere being
1016
1016
shown. If two hemispheres are being shown, an error will
1017
1017
be thrown.
1018
+ subdir : None | str
1019
+ If a label is specified as name, subdir can be used to indicate
1020
+ that the label file is in a sub-directory of the subject's
1021
+ label directory rather than in the label directory itself (e.g.
1022
+ for ``$SUBJECTS_DIR/$SUBJECT/label/aparc/lh.cuneus.label``
1023
+ ``brain.add_label('cuneus', subdir='aparc')``).
1018
1024
1019
1025
Notes
1020
1026
-----
@@ -1027,10 +1033,13 @@ def add_label(self, label, color="crimson", alpha=1,
1027
1033
label_name = os .path .basename (filepath ).split ('.' )[1 ]
1028
1034
else :
1029
1035
label_name = label
1030
- filepath = pjoin (self .subjects_dir ,
1031
- self .subject_id ,
1032
- 'label' ,
1033
- "." .join ([hemi , label_name , 'label' ]))
1036
+ label_fname = "." .join ([hemi , label_name , 'label' ])
1037
+ if subdir is None :
1038
+ filepath = pjoin (self .subjects_dir , self .subject_id ,
1039
+ 'label' , label_fname )
1040
+ else :
1041
+ filepath = pjoin (self .subjects_dir , self .subject_id ,
1042
+ 'label' , subdir , label_fname )
1034
1043
if not os .path .exists (filepath ):
1035
1044
raise ValueError ('Label file %s does not exist'
1036
1045
% filepath )
0 commit comments