diff --git a/tedana/io.py b/tedana/io.py index e60559882..b60a41c5c 100644 --- a/tedana/io.py +++ b/tedana/io.py @@ -214,6 +214,10 @@ def save_img(self, data, name): Data to save to a file. name : str Full file path for output file. + + Notes + ----- + Will coerce 64-bit float and int arrays into 32-bit arrays. """ data_type = type(data) if not isinstance(data, np.ndarray): @@ -225,6 +229,14 @@ def save_img(self, data, name): "Data must have number of dimensions in (1, 2), not " f"{data.ndim}" ) + # Coerce data to be 32-bit max in the cases of float64, int64 + # Note that int64 niftis cannot be read by mricroGL, AFNI + vox_type = data.dtype + if vox_type == np.int64: + data = np.int32(data) + elif vox_type == np.float64: + data = np.float32(data) + # Make new img and save img = new_nii_like(self.reference_img, data) img.to_filename(name)