(self)
| 64 | matshow3d(ims[keys], fig=axes, figsize=(2, 2), frames_per_row=5, every_n=2, frame_dim=-1, show=False) |
| 65 | |
| 66 | def test_samples(self): |
| 67 | test_root = Path(__file__).parents[2] |
| 68 | testing_dir = os.path.join(test_root, "testing_data") |
| 69 | keys = "image" |
| 70 | xforms = Compose( |
| 71 | [ |
| 72 | LoadImaged(keys=keys), |
| 73 | EnsureChannelFirstd(keys=keys), |
| 74 | ScaleIntensityd(keys=keys), |
| 75 | RandSpatialCropSamplesd(keys=keys, roi_size=(8, 8, 5), random_size=True, num_samples=10), |
| 76 | ] |
| 77 | ) |
| 78 | image_path = os.path.join(testing_dir, "anatomical.nii") |
| 79 | xforms.set_random_state(0) |
| 80 | ims = xforms({keys: image_path}) |
| 81 | fig, mat = matshow3d( |
| 82 | [im[keys] for im in ims], title=f"testing {keys}", figsize=(2, 2), frames_per_row=5, every_n=2, show=False |
| 83 | ) |
| 84 | self.assertEqual(mat.dtype, np.float32) |
| 85 | |
| 86 | with tempfile.TemporaryDirectory() as tempdir: |
| 87 | tempimg = f"{tempdir}/matshow3d_patch_test.png" |
| 88 | fig.savefig(tempimg) |
| 89 | comp = compare_images(f"{testing_dir}/matshow3d_patch_test.png", tempimg, 5e-2, in_decorator=True) |
| 90 | if comp: |
| 91 | print("not none comp: ", comp) # matplotlib 3.2.2 |
| 92 | np.testing.assert_allclose(comp["rms"], 30.786983, atol=1e-3, rtol=1e-3) |
| 93 | else: |
| 94 | self.assertIsNone(comp, f"value of comp={comp}") # None indicates test passed |
| 95 | |
| 96 | def test_3d_rgb(self): |
| 97 | test_dir = Path(__file__).parents[2].as_posix() |
nothing calls this directly
no test coverage detected