@@ -284,8 +284,8 @@ def __init__(self, name, voxel=None, vertex=None, affine=None,
284284 if name not in self .name :
285285 del self .nvertices [name ]
286286
287- is_surface = self .is_surface
288- if is_surface .all ():
287+ surface_mask = self .surface_mask
288+ if surface_mask .all ():
289289 self .affine = None
290290 self .volume_shape = None
291291 else :
@@ -295,9 +295,9 @@ def __init__(self, name, voxel=None, vertex=None, affine=None,
295295 self .affine = affine
296296 self .volume_shape = volume_shape
297297
298- if np .any (self .vertex [is_surface ] < 0 ):
298+ if np .any (self .vertex [surface_mask ] < 0 ):
299299 raise ValueError ('Undefined vertex indices found for surface elements' )
300- if np .any (self .voxel [~ is_surface ] < 0 ):
300+ if np .any (self .voxel [~ surface_mask ] < 0 ):
301301 raise ValueError ('Undefined voxel indices found for volumetric elements' )
302302
303303 for check_name in ('name' , 'voxel' , 'vertex' ):
@@ -523,12 +523,19 @@ def to_cifti_brain_structure_name(name):
523523 return proposed_name
524524
525525 @property
526- def is_surface (self ):
526+ def surface_mask (self ):
527527 """
528528 (N, ) boolean array which is true for any element on the surface
529529 """
530530 return np .vectorize (lambda name : name in self .nvertices .keys ())(self .name )
531531
532+ @property
533+ def volume_mask (self ):
534+ """
535+ (N, ) boolean array which is true for any element on the surface
536+ """
537+ return np .vectorize (lambda name : name not in self .nvertices .keys ())(self .name )
538+
532539 _affine = None
533540
534541 @property
@@ -586,13 +593,13 @@ def __eq__(self, other):
586593 if xor (self .affine is None , other .affine is None ):
587594 return False
588595 return (
589- (self .affine is None or
596+ (self .affine is None or
590597 np .allclose (self .affine , other .affine ) and
591598 self .volume_shape == other .volume_shape ) and
592- self .nvertices == other .nvertices and
593- np .array_equal (self .name , other .name ) and
594- np .array_equal (self .voxel [~ self .is_surface ], other .voxel [~ other .is_surface ]) and
595- np .array_equal (self .vertex [self .is_surface ], other .vertex [other .is_surface ])
599+ self .nvertices == other .nvertices and
600+ np .array_equal (self .name , other .name ) and
601+ np .array_equal (self .voxel [~ self .surface_mask ], other .voxel [~ other .surface_mask ]) and
602+ np .array_equal (self .vertex [self .surface_mask ], other .vertex [other .surface_mask ])
596603 )
597604
598605 def __add__ (self , other ):
@@ -763,7 +770,7 @@ def from_brain_models(cls, named_brain_models):
763770 for idx_parcel , (parcel_name , bm ) in enumerate (named_brain_models ):
764771 all_names .append (parcel_name )
765772
766- voxels = bm .voxel [~ bm .is_surface ]
773+ voxels = bm .voxel [~ bm .surface_mask ]
767774 if voxels .shape [0 ] != 0 :
768775 if affine is None :
769776 affine = bm .affine
0 commit comments