def test_set_group_structure_ungrouped(): """ check if the set_group_structure method works as intended when data is not grouped """ dir_path = "./data/test/nifti/paired/test" name = "fixed_images" loader = NiftiFileLoader(dir_path=dir_path, name=name, grouped=False) loader.set_group_structure() with pytest.raises(AttributeError) as execinfo: loader.group_ids msg = " ".join(execinfo.value.args[0].split()) assert "object has no attribute" in msg
def test_set_group_structure(): """ check if the set_group_structure method works as intended when data is grouped """ dir_path = "./data/test/nifti/grouped/test" name = "images" loader = NiftiFileLoader(dir_path=dir_path, name=name, grouped=True) loader.set_group_structure() got = [loader.group_ids, loader.group_sample_dict] expected = [ ["./data/test/nifti/grouped/test/images/group1"], { "./data/test/nifti/grouped/test/images/group1": [ "./data/test/nifti/grouped/test/images/group1/case000025.nii.gz", "./data/test/nifti/grouped/test/images/group1/case000026.nii.gz", ] }, ] loader.close() assert got == expected