diff --git a/scilpy/image/operations.py b/scilpy/image/operations.py index b9c3a195e..37f951696 100644 --- a/scilpy/image/operations.py +++ b/scilpy/image/operations.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- """ -Utility operations provided for scil_image_math.py and scil_connectivity_math.py +Utility operations provided for scil_image_math.py +and scil_connectivity_math.py They basically act as wrappers around numpy to avoid installing MRtrix/FSL to apply simple operations on nibabel images or numpy arrays. """ @@ -511,23 +512,23 @@ def concatenate(input_list, ref_img): concatenate: IMGs Concatenate a list of 3D and 4D images into a single 4D image. """ - + _validate_imgs_concat(*input_list, ref_img) if len(input_list[0].header.get_data_shape()) > 4: raise ValueError('Concatenate require 3D or 4D arrays.') - + input_data = [] for img in input_list: data = img.get_fdata(dtype=np.float64) - + if len(img.header.get_data_shape()) == 4: data = np.rollaxis(data, 3) for i in range(0, len(data)): input_data.append(data[i]) else: - input_data.append(data) - + input_data.append(data) + img.uncache() return np.rollaxis(np.stack(input_data), axis=0, start=4) diff --git a/scripts/scil_image_math.py b/scripts/scil_image_math.py index e26ca6b12..766312bea 100755 --- a/scripts/scil_image_math.py +++ b/scripts/scil_image_math.py @@ -107,13 +107,14 @@ def main(): found_ref = True break - # If there's a 4D image, replace the previous 3D image with this one for reference + # If there's a 4D image, replace the previous 3D image with + # this one for reference for input_arg in args.in_images: if not is_float(input_arg): ref_img = nib.load(input_arg) if len(ref_img.shape) == 4: mask = np.zeros(ref_img.shape) - break + break if not found_ref: raise ValueError('Requires at least one nifti image.')