MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / test_3d_rgb

Method test_3d_rgb

tests/visualize/utils/test_matshow3d.py:96–129  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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()
98 testing_dir = os.path.join(test_dir, "testing_data")
99 keys = "image"
100 xforms = Compose(
101 [
102 LoadImaged(keys=keys),
103 EnsureChannelFirstd(keys=keys, channel_dim="no_channel"),
104 ScaleIntensityd(keys=keys),
105 # change to RGB color image
106 RepeatChanneld(keys=keys, repeats=3),
107 ]
108 )
109 image_path = os.path.join(testing_dir, "anatomical.nii")
110 ims = xforms({keys: image_path})
111
112 fig = pyplot.figure() # external figure
113 fig, _ = matshow3d(
114 volume=ims[keys],
115 fig=fig,
116 figsize=(2, 2),
117 frames_per_row=5,
118 every_n=2,
119 frame_dim=-1,
120 channel_dim=0,
121 fill_value=0,
122 show=False,
123 )
124
125 with tempfile.TemporaryDirectory() as tempdir:
126 tempimg = f"{tempdir}/matshow3d_rgb_test.png"
127 fig.savefig(tempimg)
128 comp = compare_images(f"{testing_dir}/matshow3d_rgb_test.png", tempimg, 5e-2)
129 self.assertIsNone(comp, f"value of comp={comp}") # None indicates test passed
130
131
132if __name__ == "__main__":

Callers

nothing calls this directly

Calls 6

ComposeClass · 0.90
LoadImagedClass · 0.90
EnsureChannelFirstdClass · 0.90
ScaleIntensitydClass · 0.90
RepeatChanneldClass · 0.90
matshow3dFunction · 0.90

Tested by

no test coverage detected