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

Method setUp

tests/transforms/inverse/test_inverse.py:367–395  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

365 """
366
367 def setUp(self):
368 if not has_nib:
369 self.skipTest("nibabel required for test_inverse")
370
371 set_determinism(seed=0)
372
373 self.all_data = {}
374
375 affine = make_rand_affine()
376 affine[0] *= 2
377
378 for size in [10, 11]:
379 # pad 5 onto both ends so that cropping can be lossless
380 im_1d = np.pad(np.arange(size), 5)[None]
381 name = "1D even" if size % 2 == 0 else "1D odd"
382 self.all_data[name] = {
383 "image": torch.as_tensor(np.array(im_1d, copy=True)),
384 "label": torch.as_tensor(np.array(im_1d, copy=True)),
385 "other": torch.as_tensor(np.array(im_1d, copy=True)),
386 }
387
388 im_2d_fname, seg_2d_fname = (make_nifti_image(i) for i in create_test_image_2d(101, 100))
389 im_3d_fname, seg_3d_fname = (make_nifti_image(i, affine) for i in create_test_image_3d(100, 101, 107))
390
391 load_ims = Compose(
392 [LoadImaged(KEYS), EnsureChannelFirstd(KEYS, channel_dim="no_channel"), FromMetaTensord(KEYS)]
393 )
394 self.all_data["2D"] = load_ims({"image": im_2d_fname, "label": seg_2d_fname})
395 self.all_data["3D"] = load_ims({"image": im_3d_fname, "label": seg_3d_fname})
396
397 def tearDown(self):
398 set_determinism(seed=None)

Callers

nothing calls this directly

Calls 11

set_determinismFunction · 0.90
make_rand_affineFunction · 0.90
make_nifti_imageFunction · 0.90
create_test_image_2dFunction · 0.90
create_test_image_3dFunction · 0.90
ComposeClass · 0.90
LoadImagedClass · 0.90
EnsureChannelFirstdClass · 0.90
FromMetaTensordClass · 0.90
as_tensorMethod · 0.80
arrayMethod · 0.80

Tested by

no test coverage detected