Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions tests/transforms/test_inverse_collation.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,22 @@
class TestInverseCollation(unittest.TestCase):
"""Test collation for of random transformations with prob == 0 and 1."""

def setUp(self):
@classmethod
def setUpClass(cls):
super().setUpClass()
if not has_nib:
self.skipTest("nibabel required for test_inverse")

raise unittest.SkipTest("nibabel required for test_inverse")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using SkipIfNoModule on the class itself should have the same effect.

set_determinism(seed=0)

b_size = 11
im_fname, seg_fname = (make_nifti_image(i) for i in create_test_image_3d(101, 100, 107))
load_ims = Compose([LoadImaged(KEYS), EnsureChannelFirstd(KEYS, channel_dim="no_channel")])
self.data_3d = [load_ims({"image": im_fname, "label": seg_fname}) for _ in range(b_size)]

b_size = 8
im_fname, seg_fname = (make_nifti_image(i) for i in create_test_image_3d(101, 100, 107))
cls.base_3d = load_ims({"image": im_fname, "label": seg_fname})
im_fname, seg_fname = (make_nifti_image(i) for i in create_test_image_2d(62, 37, rad_max=10))
load_ims = Compose([LoadImaged(KEYS), EnsureChannelFirstd(KEYS, channel_dim="no_channel")])
self.data_2d = [load_ims({"image": im_fname, "label": seg_fname}) for _ in range(b_size)]
cls.base_2d = load_ims({"image": im_fname, "label": seg_fname})
Comment thread
ericspod marked this conversation as resolved.

def setUp(self):
set_determinism(seed=0)
self.data_3d = [dict(self.base_3d) for _ in range(11)]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any real point in loading data from nifti files? I think we can just get away with creating MetaTensors here and populate their meta dictionaries with some dummy data to ensure it gets collated, but otherwise the whole nifti process seems unnecessary.

self.data_2d = [dict(self.base_2d) for _ in range(8)]
self.batch_size = 7

def tearDown(self):
Expand Down
Loading