(self)
| 37 | @SkipIfNoModule("matplotlib") |
| 38 | class TestMatshow3d(unittest.TestCase): |
| 39 | def test_3d(self): |
| 40 | test_root = Path(__file__).parents[2] |
| 41 | testing_dir = os.path.join(test_root, "testing_data") |
| 42 | print("test_root: ", testing_dir) |
| 43 | keys = "image" |
| 44 | xforms = Compose( |
| 45 | [ |
| 46 | LoadImaged(keys=keys), |
| 47 | EnsureChannelFirstd(keys=keys, channel_dim="no_channel"), |
| 48 | ScaleIntensityd(keys=keys), |
| 49 | ] |
| 50 | ) |
| 51 | image_path = os.path.join(testing_dir, "anatomical.nii") |
| 52 | ims = xforms({keys: image_path}) |
| 53 | |
| 54 | fig = pyplot.figure() # external figure |
| 55 | fig, _ = matshow3d(ims[keys], fig=fig, figsize=(2, 2), frames_per_row=5, every_n=2, frame_dim=-1, show=False) |
| 56 | |
| 57 | with tempfile.TemporaryDirectory() as tempdir: |
| 58 | tempimg = f"{tempdir}/matshow3d_test.png" |
| 59 | fig.savefig(tempimg) |
| 60 | comp = compare_images(f"{testing_dir}/matshow3d_test.png", tempimg, 5e-2) |
| 61 | self.assertIsNone(comp, f"value of comp={comp}") # None indicates test passed |
| 62 | |
| 63 | _, axes = pyplot.subplots() |
| 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] |
nothing calls this directly
no test coverage detected