| @@ 41-53 (lines=13) @@ | ||
| 38 | with self.assertRaises(ValueError): |
|
| 39 | self.dataset[:3] |
|
| 40 | ||
| 41 | def test_save_sample(self): |
|
| 42 | dataset = SubjectsDataset( |
|
| 43 | self.subjects_list, transform=lambda x: x) |
|
| 44 | _ = len(dataset) # for coverage |
|
| 45 | sample = dataset[0] |
|
| 46 | output_path = self.dir / 'test.nii.gz' |
|
| 47 | paths_dict = {'t1': output_path} |
|
| 48 | with self.assertWarns(DeprecationWarning): |
|
| 49 | dataset.save_sample(sample, paths_dict) |
|
| 50 | nii = nib.load(str(output_path)) |
|
| 51 | ndims_output = len(nii.shape) |
|
| 52 | ndims_sample = len(sample['t1'].shape) |
|
| 53 | assert ndims_sample == ndims_output + 1 |
|
| 54 | ||
| 55 | def test_wrong_transform_init(self): |
|
| 56 | with self.assertRaises(ValueError): |
|
| @@ 41-53 (lines=13) @@ | ||
| 38 | with self.assertRaises(ValueError): |
|
| 39 | self.dataset[:3] |
|
| 40 | ||
| 41 | def test_save_sample(self): |
|
| 42 | dataset = SubjectsDataset( |
|
| 43 | self.subjects_list, transform=lambda x: x) |
|
| 44 | _ = len(dataset) # for coverage |
|
| 45 | sample = dataset[0] |
|
| 46 | output_path = self.dir / 'test.nii.gz' |
|
| 47 | paths_dict = {'t1': output_path} |
|
| 48 | with self.assertWarns(DeprecationWarning): |
|
| 49 | dataset.save_sample(sample, paths_dict) |
|
| 50 | nii = nib.load(str(output_path)) |
|
| 51 | ndims_output = len(nii.shape) |
|
| 52 | ndims_sample = len(sample['t1'].shape) |
|
| 53 | assert ndims_sample == ndims_output + 1 |
|
| 54 | ||
| 55 | def test_wrong_transform_init(self): |
|
| 56 | with self.assertRaises(ValueError): |
|