@@ -352,7 +352,8 @@ def get_roi_verts(subject, roi=None, mask=False, overlay_file=None):
352
352
extra_idx = set ()
353
353
for idx in roi_idx :
354
354
extra_idx .update (ii for ii in neighbors_dict [idx ] if ii not in goodpts )
355
- roi_idx = np .unique (np .concatenate ((roi_idx , list (extra_idx )))).astype (int )
355
+ if extra_idx :
356
+ roi_idx = np .unique (np .concatenate ((roi_idx , list (extra_idx )))).astype (int )
356
357
357
358
if mask :
358
359
roidict [name ] = np .zeros (pts .shape [:1 ], dtype = bool )
@@ -673,18 +674,20 @@ def get_roi_masks(subject, xfmname, roi_list=None, gm_sampler='cortical', split_
673
674
for roi in roi_list :
674
675
roi_voxels [roi ][all_mask > 1 ] = False
675
676
# Split left / right hemispheres if desired
676
- # There ought to be a more succinct way to do this - get_hemi_masks only does the cortical
677
- # ribbon, and is not guaranteed to have all voxels in the cortex_mask specified in this fn
678
677
if split_lr :
679
- left_verts , right_verts = db .get_surf (subject , "flat" , merge = False , nudge = True )
678
+ # Use the fiducial surface because we need to have all vertices
679
+ left_verts , _ = db .get_surf (subject , "fiducial" , merge = False , nudge = True )
680
680
left_mask = vox_idx < len (np .unique (left_verts [1 ]))
681
681
right_mask = np .logical_not (left_mask )
682
682
roi_voxels_lr = {}
683
683
for roi in roi_list :
684
- roi_voxels_lr [roi + '_L' ] = copy .copy (roi_voxels [roi ]) # & left_mask
685
- roi_voxels_lr [roi + '_L' ][right_mask ] = False # ?
686
- roi_voxels_lr [roi + '_R' ] = copy .copy (roi_voxels [roi ]) # & right_mask
687
- roi_voxels_lr [roi + '_R' ][left_mask ] = False # ?
684
+ # roi_voxels may contain float values if using a mapper, therefore we need
685
+ # to manually set the voxels in the other hemisphere to False. Then we let
686
+ # numpy do the conversion False -> 0.
687
+ roi_voxels_lr [roi + '_L' ] = copy .copy (roi_voxels [roi ])
688
+ roi_voxels_lr [roi + '_L' ][right_mask ] = False
689
+ roi_voxels_lr [roi + '_R' ] = copy .copy (roi_voxels [roi ])
690
+ roi_voxels_lr [roi + '_R' ][left_mask ] = False
688
691
output = roi_voxels_lr
689
692
else :
690
693
output = roi_voxels
0 commit comments