@@ -172,20 +172,16 @@ def __init__(self, img, full_surface=False):
172
172
# Assign remaining args to class
173
173
self .full_surface = full_surface
174
174
175
+ # Extract structure information into dict
176
+ self .struct_info = {name :(slice_ , model ) for (name , slice_ , model ) \
177
+ in self .axis1 .iter_structures ()}
178
+
175
179
def _get_struct_info (self , struct_name ):
176
180
"""
177
- Return structure indices and axis model for given structure
181
+ Get slice, axis model, and resolved structure name for given structure
178
182
"""
179
- # Check name
180
183
struct_name = self .axis1 .to_cifti_brain_structure_name (struct_name )
181
-
182
- # Loop structures, return matching one
183
- for name , struct_indices , model in self .axis1 .iter_structures ():
184
- if name == struct_name :
185
- return struct_indices , model , struct_name
186
-
187
- # If we reach here then structure doesn't exist - raise error
188
- raise Exception (f'No data found for structure: { struct_name } ' )
184
+ return * self .struct_info [struct_name ], struct_name
189
185
190
186
def _get_volume_mask (self ):
191
187
"""
@@ -398,8 +394,8 @@ class CiftiMasker(object):
398
394
Arguments
399
395
---------
400
396
mask_img : str, Cifti2Image, or CiftiHandler
401
- Path to input mask (likely a dlabel CIFTI file), long or short name
402
- of a CIFTI structure (e.g. 'CIFTI_STRUCTURE_LEFT_HIPPOCAMPUS' or
397
+ Path to input mask (likely a dlabel or dscalar CIFTI file), name of a
398
+ CIFTI structure (e.g., 'CIFTI_STRUCTURE_LEFT_HIPPOCAMPUS' or
403
399
'left hippocampus'), or Cifti2Image or CiftiHandler object containing
404
400
mask data.
405
401
0 commit comments