Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions tests/fl/monai_algo/test_fl_monai_algo.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,6 @@
"config_filters_filename": None,
}
]
TEST_TRAIN_3 = [
{
"bundle_root": _data_dir,
"train_workflow": ConfigWorkflow(
config_file=os.path.join(_data_dir, "config_fl_train.json"),
workflow_type="train",
logging_file=_logging_file,
),
"config_evaluate_filename": None,
"config_filters_filename": os.path.join(_data_dir, "config_fl_filters.json"),
}
]

TEST_TRAIN_4 = [
{
Expand Down Expand Up @@ -182,7 +170,7 @@
@SkipIfNoModule("ignite")
@SkipIfNoModule("mlflow")
class TestFLMonaiAlgo(unittest.TestCase):
@parameterized.expand([TEST_TRAIN_1, TEST_TRAIN_2, TEST_TRAIN_3, TEST_TRAIN_4])
@parameterized.expand([TEST_TRAIN_1, TEST_TRAIN_2, TEST_TRAIN_4])
def test_train(self, input_params):
# initialize algo
algo = MonaiAlgo(**input_params)
Expand Down
11 changes: 0 additions & 11 deletions tests/inferers/test_patch_inferer.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,17 +231,6 @@
TEST_CASE_ERROR_8 = [torch.zeros(2, 2), dict(splitter=None), ValueError]
# invalid inputs: split patches MetaTensor without location metadata
TEST_CASE_ERROR_9 = [MetaTensor(torch.zeros(2, 2)), dict(splitter=None), ValueError]
# merged_shape is not provided for the merger
TEST_CASE_ERROR_10 = [
[
(TENSOR_4x4[..., :2, :2], (0, 0)),
(TENSOR_4x4[..., :2, 2:], (0, 2)),
(TENSOR_4x4[..., 2:, :2], (2, 0)),
(TENSOR_4x4[..., 2:, 2:], (2, 2)),
],
dict(splitter=SlidingWindowSplitter(patch_size=(2, 2))),
ValueError,
]


class PatchInfererTests(unittest.TestCase):
Expand Down
2 changes: 0 additions & 2 deletions tests/transforms/spatial/test_grid_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
TEST_CASE_1 = [{"patch_size": (2, 2), "num_patches": 3}, A, [A11, A12, A21]]
TEST_CASE_2 = [{"patch_size": (2, 2), "num_patches": 5}, A, [A11, A12, A21, A22, np.zeros((3, 2, 2))]]
TEST_CASE_3 = [{"patch_size": (2, 2), "offset": (0, 0)}, A, [A11, A12, A21, A22]]
TEST_CASE_4 = [{"patch_size": (2, 2), "offset": (0, 0)}, A, [A11, A12, A21, A22]]
TEST_CASE_5 = [{"patch_size": (2, 2), "offset": (2, 2)}, A, [A22]]
TEST_CASE_6 = [{"patch_size": (2, 2), "offset": (0, 2)}, A, [A12, A22]]
TEST_CASE_7 = [{"patch_size": (2, 2), "offset": (2, 0)}, A, [A21, A22]]
Expand Down Expand Up @@ -81,7 +80,6 @@
TEST_CASES.append([p, *TEST_CASE_1])
TEST_CASES.append([p, *TEST_CASE_2])
TEST_CASES.append([p, *TEST_CASE_3])
TEST_CASES.append([p, *TEST_CASE_4])
TEST_CASES.append([p, *TEST_CASE_5])
TEST_CASES.append([p, *TEST_CASE_6])
TEST_CASES.append([p, *TEST_CASE_7])
Expand Down
2 changes: 0 additions & 2 deletions tests/transforms/spatial/test_grid_patchd.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
TEST_CASE_1 = [{"patch_size": (2, 2), "num_patches": 3}, {"image": A}, [A11, A12, A21]]
TEST_CASE_2 = [{"patch_size": (2, 2), "num_patches": 5}, {"image": A}, [A11, A12, A21, A22, np.zeros((3, 2, 2))]]
TEST_CASE_3 = [{"patch_size": (2, 2), "offset": (0, 0)}, {"image": A}, [A11, A12, A21, A22]]
TEST_CASE_4 = [{"patch_size": (2, 2), "offset": (0, 0)}, {"image": A}, [A11, A12, A21, A22]]
TEST_CASE_5 = [{"patch_size": (2, 2), "offset": (2, 2)}, {"image": A}, [A22]]
TEST_CASE_6 = [{"patch_size": (2, 2), "offset": (0, 2)}, {"image": A}, [A12, A22]]
TEST_CASE_7 = [{"patch_size": (2, 2), "offset": (2, 0)}, {"image": A}, [A21, A22]]
Expand Down Expand Up @@ -61,7 +60,6 @@
TEST_SINGLE.append([p, *TEST_CASE_1])
TEST_SINGLE.append([p, *TEST_CASE_2])
TEST_SINGLE.append([p, *TEST_CASE_3])
TEST_SINGLE.append([p, *TEST_CASE_4])
TEST_SINGLE.append([p, *TEST_CASE_5])
TEST_SINGLE.append([p, *TEST_CASE_6])
TEST_SINGLE.append([p, *TEST_CASE_7])
Expand Down
2 changes: 0 additions & 2 deletions tests/transforms/spatial/test_rand_grid_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
A,
[A11, A12, A21, A22, np.zeros((3, 2, 2))],
]
TEST_CASE_3 = [{"patch_size": (2, 2), "min_offset": 0, "max_offset": 0}, A, [A11, A12, A21, A22]]
TEST_CASE_4 = [{"patch_size": (2, 2)}, A, [A11, A12, A21, A22]]
TEST_CASE_5 = [{"patch_size": (2, 2), "min_offset": 2, "max_offset": 2}, A, [A22]]
TEST_CASE_6 = [{"patch_size": (2, 2), "min_offset": (0, 2), "max_offset": (0, 2)}, A, [A12, A22]]
Expand Down Expand Up @@ -91,7 +90,6 @@
TEST_SINGLE.append([p, *TEST_CASE_0])
TEST_SINGLE.append([p, *TEST_CASE_1])
TEST_SINGLE.append([p, *TEST_CASE_2])
TEST_SINGLE.append([p, *TEST_CASE_3])
TEST_SINGLE.append([p, *TEST_CASE_4])
TEST_SINGLE.append([p, *TEST_CASE_5])
TEST_SINGLE.append([p, *TEST_CASE_6])
Expand Down
2 changes: 0 additions & 2 deletions tests/transforms/spatial/test_rand_grid_patchd.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
{"image": A},
[A11, A12, A21, A22, np.zeros((3, 2, 2))],
]
TEST_CASE_3 = [{"patch_size": (2, 2), "min_offset": 0, "max_offset": 0}, {"image": A}, [A11, A12, A21, A22]]
TEST_CASE_4 = [{"patch_size": (2, 2)}, {"image": A}, [A11, A12, A21, A22]]
TEST_CASE_5 = [{"patch_size": (2, 2), "min_offset": 2, "max_offset": 2}, {"image": A}, [A22]]
TEST_CASE_6 = [{"patch_size": (2, 2), "min_offset": (0, 2), "max_offset": (0, 2)}, {"image": A}, [A12, A22]]
Expand Down Expand Up @@ -71,7 +70,6 @@
TEST_SINGLE.append([p, *TEST_CASE_0])
TEST_SINGLE.append([p, *TEST_CASE_1])
TEST_SINGLE.append([p, *TEST_CASE_2])
TEST_SINGLE.append([p, *TEST_CASE_3])
TEST_SINGLE.append([p, *TEST_CASE_4])
TEST_SINGLE.append([p, *TEST_CASE_5])
TEST_SINGLE.append([p, *TEST_CASE_6])
Expand Down
18 changes: 2 additions & 16 deletions tests/transforms/test_load_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ def get_data(self, _obj):

TEST_CASE_1 = [{}, ["test_image.nii.gz"], (128, 128, 128)]

TEST_CASE_2 = [{}, ["test_image.nii.gz"], (128, 128, 128)]

TEST_CASE_3 = [{}, ["test_image.nii.gz", "test_image2.nii.gz", "test_image3.nii.gz"], (3, 128, 128, 128)]

TEST_CASE_3_1 = [ # .mgz format
Expand All @@ -64,8 +62,6 @@ def get_data(self, _obj):
(3, 128, 128, 128),
]

TEST_CASE_4 = [{}, ["test_image.nii.gz", "test_image2.nii.gz", "test_image3.nii.gz"], (3, 128, 128, 128)]

TEST_CASE_4_1 = [ # additional parameter
{"mmap": False},
["test_image.nii.gz", "test_image2.nii.gz", "test_image3.nii.gz"],
Expand All @@ -92,8 +88,6 @@ def get_data(self, _obj):

TEST_CASE_6 = [{"reader": ITKReader() if has_itk else "itkreader"}, ["test_image.nii.gz"], (128, 128, 128)]

TEST_CASE_7 = [{"reader": ITKReader() if has_itk else "itkreader"}, ["test_image.nii.gz"], (128, 128, 128)]

TEST_CASE_8 = [
{"reader": ITKReader() if has_itk else "itkreader"},
["test_image.nii.gz", "test_image2.nii.gz", "test_image3.nii.gz"],
Expand All @@ -106,12 +100,6 @@ def get_data(self, _obj):
(384, 128, 128),
]

TEST_CASE_9 = [
{"reader": ITKReader() if has_itk else "itkreader"},
["test_image.nii.gz", "test_image2.nii.gz", "test_image3.nii.gz"],
(3, 128, 128, 128),
]

TEST_CASE_10 = [
{"reader": ITKReader(pixel_type=itk_uc) if has_itk else "itkreader"},
"tests/testing_data/CT_DICOM",
Expand Down Expand Up @@ -205,9 +193,7 @@ def tearDownClass(cls):
shutil.rmtree(cls.tmpdir)
super().tearDownClass()

@parameterized.expand(
[TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_3_1, TEST_CASE_4, TEST_CASE_4_1, TEST_CASE_5]
)
@parameterized.expand([TEST_CASE_1, TEST_CASE_3, TEST_CASE_3_1, TEST_CASE_4_1, TEST_CASE_5])
def test_nibabel_reader(self, input_param, filenames, expected_shape):
test_image = np.random.rand(128, 128, 128)
with tempfile.TemporaryDirectory() as tempdir:
Expand Down Expand Up @@ -249,7 +235,7 @@ def test_nibabel_reader_gpu(self, input_param, filenames, expected_shape):
result_cpu = LoadImage(image_only=True, **input_param_cpu)(filenames)
assert_allclose(result_cpu, result.cpu(), atol=1e-6)

@parameterized.expand([TEST_CASE_6, TEST_CASE_7, TEST_CASE_8, TEST_CASE_8_1, TEST_CASE_9])
@parameterized.expand([TEST_CASE_6, TEST_CASE_8, TEST_CASE_8_1])
def test_itk_reader(self, input_param, filenames, expected_shape):
test_image = torch.randint(0, 256, (128, 128, 128), dtype=torch.uint8).numpy()
print("Test image value range:", test_image.min(), test_image.max())
Expand Down
Loading