Skip to content
This repository was archived by the owner on Dec 27, 2022. It is now read-only.

Commit 367a57d

Browse files
author
Adam Richie-Halford
committed
In drop_outliers_fn, check for Nifti1 vs Nifti2 format
1 parent 4f9c93b commit 367a57d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

dmriprep/run.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,16 @@ def drop_outliers_fn(in_file, in_bval, in_bvec, drop_scans):
489489
img = nib.load(op.abspath(in_file))
490490
img_data = img.get_fdata()
491491
img_data_thinned = np.delete(img_data, drop_scans, axis=3)
492-
img_thinned = nib.Nifti1Image(img_data_thinned.astype(np.float64), img.affine, header=img.header)
492+
if isinstance(img, nib.nifti1.Nifti1Image):
493+
img_thinned = nib.Nifti1Image(img_data_thinned.astype(np.float64),
494+
img.affine,
495+
header=img.header)
496+
elif isinstance(img, nib.nifti2.Nifti2Image):
497+
img_thinned = nib.Nifti2Image(img_data_thinned.astype(np.float64),
498+
img.affine,
499+
header=img.header)
500+
else:
501+
raise TypeError("in_file does not contain Nifti image datatype.")
493502

494503
out_file = fname_presuffix(in_file, suffix="_thinned", newpath=op.abspath('.'))
495504
nib.save(img_thinned, op.abspath(out_file))

0 commit comments

Comments
 (0)