Skip to content

Commit

Permalink
ENH: Use 4+ empty sides to detect skull-stripped images
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Nov 9, 2020
1 parent 0a5ae42 commit eea65e7
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions smriprep/workflows/anatomical.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,9 @@ def _is_skull_stripped(imgs):
"""Check if T1w images are skull-stripped."""
def _check_img(img):
data = np.abs(nb.load(img).get_fdata(dtype=np.float32))
sidevals = data[0, :, :].sum() + data[-1, :, :].sum() + \
data[:, 0, :].sum() + data[:, -1, :].sum() + \
data[:, :, 0].sum() + data[:, :, -1].sum()
return sidevals < 10
sides = [data[0, :, :], data[:, 0, :], data[:, :, 0],
data[-1, :, :], data[:, -1, :], data[:, :, -1]]
return sum(np.sum(side) < 10 for side in sides) > 3

return all(_check_img(img) for img in imgs)

Expand Down

0 comments on commit eea65e7

Please sign in to comment.