Skip to content

Commit

Permalink
Fix isinstance and mask
Browse files Browse the repository at this point in the history
  • Loading branch information
durm2107 committed Feb 11, 2021
1 parent 24e1e94 commit 231a13a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 1 addition & 2 deletions scilpy/image/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@ def _validate_imgs(*imgs):

def _validate_imgs_concat(*imgs):
"""Make sure that all inputs are images."""
ref_img = imgs[-1]
for img in imgs:
if isinstance(img, nib.Nifti1Image):
if not isinstance(img, nib.Nifti1Image):
raise ValueError('Inputs are not all images')


Expand Down
7 changes: 5 additions & 2 deletions scripts/scil_image_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def main():
# Find at least one image for reference
for input_arg in args.in_images:
found_ref = False
if not is_float(input_arg):
if not is_float(input_arg):
ref_img = nib.load(input_arg)
mask = np.zeros(ref_img.shape)
found_ref = True
Expand Down Expand Up @@ -145,7 +145,10 @@ def main():

if isinstance(img, nib.Nifti1Image):
data = img.get_fdata(dtype=np.float64)
mask[data > 0] = 1
if data.ndim == 4:
mask[np.sum(data, axis=3).astype(bool) > 0] = 1
else:
mask[data > 0] = 1
img.uncache()
input_img.append(img)

Expand Down

0 comments on commit 231a13a

Please sign in to comment.