Skip to content

Commit ffa0325

Browse files
FIX add_label & DOC
1 parent 9301b87 commit ffa0325

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

surfer/viz.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,8 +1016,11 @@ def add_label(self, label, color="crimson", alpha=1, scalar_thresh=None,
10161016
shown. If two hemispheres are being shown, an error will
10171017
be thrown.
10181018
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.
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')``).
10211024
10221025
Notes
10231026
-----
@@ -1030,11 +1033,13 @@ def add_label(self, label, color="crimson", alpha=1, scalar_thresh=None,
10301033
label_name = os.path.basename(filepath).split('.')[1]
10311034
else:
10321035
label_name = label
1033-
filepath = pjoin(self.subjects_dir,
1034-
self.subject_id,
1035-
'label',
1036-
subdir,
1037-
".".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)
10381043
if not os.path.exists(filepath):
10391044
raise ValueError('Label file %s does not exist'
10401045
% filepath)

0 commit comments

Comments
 (0)