Repository: Project-MONAI/MONAI
File: tests/test_deepgrow_transforms.py (Python)

Code before:
]

SPATIAL_CROP_GUIDANCE_TEST_CASE_3 = [
    {"keys": ["image"], "guidance": "guidance", "spatial_size": [3, 3], "margin": 0},
    DATA_8,
    np.array(
        [
            [
                [[47, 48, 49], [57, 58, 59], [67, 68, 69]],
                [[147, 148, 149], [157, 158, 159], [167, 168, 169]],
                [[247, 248, 249], [257, 258, 259], [267, 268, 269]],
                [[347, 348, 349], [357, 358, 359], [367, 368, 369]],
                [[447, 448, 449], [457, 458, 459], [467, 468, 469]],
            ]
        ]
    ),
]

RESIZE_GUIDANCE_TEST_CASE_1 = [
    {"ref_image": "image", "guidance": "guidance"},
    DATA_9,
    [[[3, 5, 7], [4, 5, 7]], [[4, 5, 8]]],
]

RESTORE_LABEL_TEST_CASE_1 = [
    {"keys": ["pred"], "ref_image": "image", "mode": "nearest", "restore_resize": True, "restore_crop": True, "restore_spacing": True, "restore_slicing": True},
    DATA_10,
    np.array([[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]),
]

RESULT = np.zeros((10, 20, 20))
RESULT[4:8, 4:8, 4:8] = np.array(
    [
        [[1.0, 1.0, 2.0, 2.0], [1.0, 1.0, 2.0, 2.0], [3.0, 3.0, 4.0, 4.0], [3.0, 3.0, 4.0, 4.0]],
        [[1.0, 1.0, 2.0, 2.0], [1.0, 1.0, 2.0, 2.0], [3.0, 3.0, 4.0, 4.0], [3.0, 3.0, 4.0, 4.0]],
        [[5.0, 5.0, 6.0, 6.0], [5.0, 5.0, 6.0, 6.0], [7.0, 7.0, 8.0, 8.0], [7.0, 7.0, 8.0, 8.0]],
        [[5.0, 5.0, 6.0, 6.0], [5.0, 5.0, 6.0, 6.0], [7.0, 7.0, 8.0, 8.0], [7.0, 7.0, 8.0, 8.0]],
    ]
)

RESTORE_LABEL_TEST_CASE_2 = [
    {"keys": ["pred"], "ref_image": "image", "mode": "nearest"},
    DATA_11,
    RESULT
]

RESTORE_LABEL_TEST_CASE_3_RESULT = np.zeros((10, 20, 20))
for layer in range(5):
    RESTORE_LABEL_TEST_CASE_3_RESULT[layer, 0:10, 0:10] = 1
    RESTORE_LABEL_TEST_CASE_3_RESULT[layer, 0:10, 10:20] = 2
    RESTORE_LABEL_TEST_CASE_3_RESULT[layer, 10:20, 0:10] = 3

Review comment (suggestion):
I don't think changing this dictionary affects anything, it just adds the default values for these parameters. The addition here I think can be omitted.
```suggestion
    {"keys": ["pred"], "ref_image": "image", "mode": "nearest"},
```

Code after:
    np.array([[[[357, 358]], [[457, 458]]]]),
]

SPATIAL_CROP_GUIDANCE_TEST_CASE_2 = [
    {"keys": ["image"], "guidance": "guidance", "spatial_size": [2, 2], "margin": 1},
    DATA_8,
    np.array(
        [
            [
                [[246, 247, 248, 249], [256, 257, 258, 259], [266, 267, 268, 269]],
                [[346, 347, 348, 349], [356, 357, 358, 359], [366, 367, 368, 369]],
                [[446, 447, 448, 449], [456, 457, 458, 459], [466, 467, 468, 469]],
            ]
        ]
    ),
]

SPATIAL_CROP_GUIDANCE_TEST_CASE_3 = [
    {"keys": ["image"], "guidance": "guidance", "spatial_size": [3, 3], "margin": 0},
    DATA_8,
    np.array(
        [
            [
                [[47, 48, 49], [57, 58, 59], [67, 68, 69]],
                [[147, 148, 149], [157, 158, 159], [167, 168, 169]],
                [[247, 248, 249], [257, 258, 259], [267, 268, 269]],
                [[347, 348, 349], [357, 358, 359], [367, 368, 369]],
                [[447, 448, 449], [457, 458, 459], [467, 468, 469]],
            ]
        ]
    ),
]

RESIZE_GUIDANCE_TEST_CASE_1 = [
    {"ref_image": "image", "guidance": "guidance"},
    DATA_9,
    [[[3, 5, 7], [4, 5, 7]], [[4, 5, 8]]],
]

RESTORE_LABEL_TEST_CASE_1 = [
    {"keys": ["pred"], "ref_image": "image", "mode": "nearest"},
    DATA_10,
    np.array([[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]),
]

RESULT = np.zeros((10, 20, 20))
RESULT[4:8, 4:8, 4:8] = np.array(
    [
        [[1.0, 1.0, 2.0, 2.0], [1.0, 1.0, 2.0, 2.0], [3.0, 3.0, 4.0, 4.0], [3.0, 3.0, 4.0, 4.0]],
        [[1.0, 1.0, 2.0, 2.0], [1.0, 1.0, 2.0, 2.0], [3.0, 3.0, 4.0, 4.0], [3.0, 3.0, 4.0, 4.0]],
        [[5.0, 5.0, 6.0, 6.0], [5.0, 5.0, 6.0, 6.0], [7.0, 7.0, 8.0, 8.0], [7.0, 7.0, 8.0, 8.0]],