Skip to content

Commit e03c9f8

Browse files
ENH Brain.add_label(): when plotting Label instance, use label.hemi attribute
1 parent 1655e0f commit e03c9f8

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

surfer/viz.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,8 +1026,8 @@ def add_label(self, label, color="crimson", alpha=1, scalar_thresh=None,
10261026
-----
10271027
To remove previously added labels, run Brain.remove_labels().
10281028
"""
1029-
hemi = self._check_hemi(hemi)
10301029
if isinstance(label, basestring):
1030+
hemi = self._check_hemi(hemi)
10311031
if os.path.isfile(label):
10321032
filepath = label
10331033
label_name = os.path.basename(filepath).split('.')[1]
@@ -1052,7 +1052,7 @@ def add_label(self, label, color="crimson", alpha=1, scalar_thresh=None,
10521052
else:
10531053
# try to extract parameters from label instance
10541054
try:
1055-
lhemi = label.hemi
1055+
hemi = label.hemi
10561056
ids = label.vertices
10571057
if label.name is None:
10581058
label_name = 'unnamed'
@@ -1066,9 +1066,8 @@ def add_label(self, label, color="crimson", alpha=1, scalar_thresh=None,
10661066
'must have attributes "hemi", "vertices", '
10671067
'"name", and (if scalar_thresh is not None)'
10681068
'"values"')
1069-
if not lhemi == hemi:
1070-
raise ValueError('label hemisphere (%s) and brain hemisphere '
1071-
'(%s) must match' % (lhemi, hemi))
1069+
hemi = self._check_hemi(hemi)
1070+
10721071
if scalar_thresh is not None:
10731072
ids = ids[scalars >= scalar_thresh]
10741073

0 commit comments

Comments
 (0)