From 28185c4b7ed0325b9a2c9e14237dee0c364f001c Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 10 Jan 2018 23:49:36 +0200 Subject: [PATCH] added test for cropping multiple patches --- prediction/src/tests/test_cropping.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/prediction/src/tests/test_cropping.py b/prediction/src/tests/test_cropping.py index 3e456bbe..bc0fc4fe 100644 --- a/prediction/src/tests/test_cropping.py +++ b/prediction/src/tests/test_cropping.py @@ -43,3 +43,23 @@ def test_patches_from_ct(ct_path, luna_nodules): assert isinstance(patches, list) assert len(patches) == 3 assert all(patch.shape == (12, 12, 12) for patch in patches) + + +def test_patches_on_multiple_centroids(dicom_paths): + ct_path = dicom_paths[2] + few_centroids = [{'x': 50, 'y': 50, 'z': 21}, {'x': 367, 'y': 349, 'z': 75}] + + preprocess = PreprocessCT(clip_lower=-1200., clip_upper=600., spacing=True, order=1, + min_max_normalize=True, scale=255, dtype='uint8') + + # convert the image to voxels(apply the real spacing between pixels) + ct_array, meta = preprocess(*load_ct(ct_path)) + + patches = patches_from_ct(ct_array, meta, 96, few_centroids, + stride=4, pad_value=160) + + assert len(patches) == 2 + + for patch in patches: + assert len(patch) == 2 + assert patch[0].shape == (96, 96, 96)