From ad354ae616bdc78b61aa5bdf34302be17491a868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yasser=20Alem=C3=A1n=20G=C3=B3mez?= Date: Thu, 14 Nov 2024 10:29:35 +0100 Subject: [PATCH] Correcting a bug related to the shape for 3D volumes --- clabtoolkit/imagetools.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/clabtoolkit/imagetools.py b/clabtoolkit/imagetools.py index 859b8d7..6757b9f 100644 --- a/clabtoolkit/imagetools.py +++ b/clabtoolkit/imagetools.py @@ -180,6 +180,11 @@ def cropped_to_native(in_image: str, native_image: str, out_image: str): # Get data from IM2 img2_data = img2.get_fdata() + img2_shape = img2_data.shape + + # If the img2 is a 4D add the forth dimension to the shape of the img1 + if len(img2_shape) == 4: + img1_shape = (img1_shape[0], img1_shape[1], img1_shape[2], img2_shape[3]) # Create an empty array with the same dimensions as IM1 new_data = np.zeros(img1_shape)