Skip to content

Commit d0b4c0f

Browse files
authored
[FIX] handle index errors (#839)
* handle index errors * fix black error
1 parent 32577f7 commit d0b4c0f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

nimare/diagnostics.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -476,11 +476,13 @@ def transform(self, dataset):
476476
dset_ijk = mm2vox(dset_xyz, masker.mask_img.affine)
477477

478478
# Only retain coordinates inside the brain mask
479-
keep_idx = [
480-
i
481-
for i, coord in enumerate(dset_ijk)
482-
if masker_array[coord[0], coord[1], coord[2]] == 1
483-
]
479+
def check_coord(coord):
480+
try:
481+
return masker_array[coord[0], coord[1], coord[2]] == 1
482+
except IndexError:
483+
return False
484+
485+
keep_idx = [i for i, coord in enumerate(dset_ijk) if check_coord(coord)]
484486

485487
LGR.info(
486488
f"{dset_ijk.shape[0] - len(keep_idx)}/{dset_ijk.shape[0]} coordinates fall outside of "

0 commit comments

Comments
 (0)