From d631b01baa554ed9491d0aeb650d9d37f6a4ccb1 Mon Sep 17 00:00:00 2001 From: ncullen93 Date: Thu, 30 May 2024 11:34:23 +0200 Subject: [PATCH] expand tests --- ants/ops/crop_image.py | 3 ++- tests/test_utils.py | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ants/ops/crop_image.py b/ants/ops/crop_image.py index 9120fbc1..b945ec2f 100644 --- a/ants/ops/crop_image.py +++ b/ants/ops/crop_image.py @@ -95,7 +95,8 @@ def crop_indices(image, lowerind, upperind): >>> decropped = ants.decrop_image( cropped, fi ) """ if image.has_components: - return ants.merge_channels([crop_indices(img, lowerind, upperind) for img in ants.split_channels(image)]) + return ants.merge_channels([crop_indices(img, lowerind, upperind) for img in ants.split_channels(image)], + channels_first=image.channels_first) inpixeltype = 'float' if image.pixeltype != 'float': diff --git a/tests/test_utils.py b/tests/test_utils.py index edcfc132..3e0a1b10 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -232,6 +232,13 @@ def test_crop_indices_example(self): cropped = ants.crop_indices(fi, (10, 10, 10), (100, 100)) cropped = ants.crop_indices(fi, (10, 10), (100, 100, 100)) + # vector images + fi = ants.image_read( ants.get_ants_data("r16")) + cropped = ants.crop_indices( fi, (10,10), (100,100) ) + fi2 = ants.merge_channels([fi,fi]) + cropped2 = ants.crop_indices( fi, (10,10), (100,100) ) + self.assertEqual(cropped.shape, cropped2.shape) + def test_decrop_image_example(self): fi = ants.image_read(ants.get_ants_data("r16")) mask = ants.get_mask(fi)