@@ -1010,8 +1010,10 @@ def add_label(self, label, color=None, alpha=1, scalar_thresh=None,
1010
1010
threshold the label ids using this value in the label
1011
1011
file's scalar field (i.e. label only vertices with
1012
1012
scalar >= thresh)
1013
- borders : bool
1014
- show only label borders
1013
+ borders : bool | int
1014
+ Show only label borders. If int, specify the number of steps
1015
+ along the cortical mesh to include in the border definition
1016
+ (higher numbers create thicker borders).
1015
1017
hemi : str | None
1016
1018
If None, it is assumed to belong to the hemipshere being
1017
1019
shown. If two hemispheres are being shown, an error will
@@ -1093,12 +1095,22 @@ def add_label(self, label, color=None, alpha=1, scalar_thresh=None,
1093
1095
i += 1
1094
1096
label_name = name % i
1095
1097
1098
+ if not isinstance (borders , (bool , int )) or borders < 0 :
1099
+ raise TypeError ('borders must be a bool or int' )
1096
1100
if borders :
1097
1101
n_vertices = label .size
1098
1102
edges = utils .mesh_edges (self .geo [hemi ].faces )
1099
1103
border_edges = label [edges .row ] != label [edges .col ]
1100
1104
show = np .zeros (n_vertices , dtype = np .int )
1101
- show [np .unique (edges .row [border_edges ])] = 1
1105
+ keep_idx = np .unique (edges .row [border_edges ])
1106
+ if isinstance (borders , int ):
1107
+ for _ in range (borders ):
1108
+ keep_idx = np .in1d (self .geo [hemi ].faces .ravel (), keep_idx )
1109
+ keep_idx .shape = self .geo [hemi ].faces .shape
1110
+ keep_idx = self .geo [hemi ].faces [np .any (keep_idx ,
1111
+ axis = 1 )].ravel ()
1112
+ keep_idx = keep_idx [np .in1d (keep_idx , ids )]
1113
+ show [keep_idx ] = 1
1102
1114
label *= show
1103
1115
1104
1116
# make a list of all the plotted labels
0 commit comments