Skip to content

Commit c3b2c0f

Browse files
mgxdeffigies
authored andcommitted
FIX: Ensure anat image is Nifti
1 parent 174c541 commit c3b2c0f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

niworkflows/viz/utils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,8 @@ def plot_registration(
341341
if cuts is None:
342342
raise NotImplementedError # TODO
343343

344+
anat_nii = _ensure_nii(anat_nii)
345+
344346
out_files = []
345347
if estimate_brightness:
346348
plot_params = robust_set_limits(anat_nii.get_fdata().reshape(-1), plot_params)
@@ -714,3 +716,9 @@ def plot_melodic_components(
714716
pad_inches=0.01,
715717
)
716718
fig.clf()
719+
720+
721+
def _ensure_nii(img: nb.spatialimages.SpatialImage) -> nb.Nifti1Image:
722+
if not isinstance(img, nb.Nifti1Image):
723+
img = nb.Nifti1Image(img.dataobj, img.affine, img.header)
724+
return img

0 commit comments

Comments
 (0)