FIX: Ensure anat image is Nifti
@@ -341,6 +341,8 @@ def plot_registration(
if cuts is None:
raise NotImplementedError # TODO
+ anat_nii = _ensure_nii(anat_nii)
+
out_files = []
if estimate_brightness:
plot_params = robust_set_limits(anat_nii.get_fdata().reshape(-1), plot_params)
@@ -714,3 +716,9 @@ def plot_melodic_components(
pad_inches=0.01,
)
fig.clf()
+
+
+def _ensure_nii(img: nb.spatialimages.SpatialImage) -> nb.Nifti1Image:
+ if not isinstance(img, nb.Nifti1Image):
+ img = nb.Nifti1Image(img.dataobj, img.affine, img.header)
+ return img
