Skip to content

Commit 9301b87

Browse files
ENH: specify relative label location using subdir argument
1 parent 3137e98 commit 9301b87

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

surfer/viz.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -991,8 +991,8 @@ def add_annotation(self, annot, borders=True, alpha=1, hemi=None,
991991
self.annot_list = al
992992
self._toggle_render(True, views)
993993

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):
996996
"""Add an ROI label to the image.
997997
998998
Parameters
@@ -1015,6 +1015,9 @@ def add_label(self, label, color="crimson", alpha=1,
10151015
If None, it is assumed to belong to the hemipshere being
10161016
shown. If two hemispheres are being shown, an error will
10171017
be thrown.
1018+
subdir : None | str
1019+
If a label is specified as name, subdir specifies the path of the
1020+
directory containing the label relative to the label directory.
10181021
10191022
Notes
10201023
-----
@@ -1026,11 +1029,11 @@ def add_label(self, label, color="crimson", alpha=1,
10261029
filepath = label
10271030
label_name = os.path.basename(filepath).split('.')[1]
10281031
else:
1029-
dirname, label_name = os.path.split(label)
1032+
label_name = label
10301033
filepath = pjoin(self.subjects_dir,
10311034
self.subject_id,
10321035
'label',
1033-
dirname,
1036+
subdir,
10341037
".".join([hemi, label_name, 'label']))
10351038
if not os.path.exists(filepath):
10361039
raise ValueError('Label file %s does not exist'

0 commit comments

Comments
 (0)