def test_from_file_apply_invalid_transformation(self): with self.assertRaises(Exception): next( iter( test.PickledDicomoDataSet(dicom_data_set, ["CT"], transform=[], constraints={})))
def test_len(self): dataset = iter( test.PickledDicomoDataSet(dicom_data_set, ["CT"], constraints={})) self.assertEqual(len(dataset), 0) next(dataset) self.assertEqual(len(dataset), 1) next(dataset) next(dataset) self.assertEqual(len(dataset), 3)
def test_from_file_apply_valid_transformation(self): t1 = torchvision.transforms.Compose([ torchvision.transforms.ToPILImage(), torchvision.transforms.Resize((244, 244)), torchvision.transforms.ToTensor() ]) data = next( iter( test.PickledDicomoDataSet(dicom_data_set, ["CT"], transform=t1, constraints={}))) self.assertIsInstance(data, list)
def test_iter(self): dataset = test.PickledDicomoDataSet(dicom_data_set, ["CT"], constraints={}) dataset = iter(dataset) self.assertIsInstance(dataset, test.PickledDicomoDataSet)
def test_next(self): dataset = test.PickledDicomoDataSet(dicom_data_set, ["CT"], constraints={}) data = next(iter(dataset)) self.assertIsInstance(data, list)
def test_classes_correct_usage(self): data = test.PickledDicomoDataSet(dicom_data_set, ["CT"], constraints={}) self.assertIsInstance(data.classes("Modality"), list)
def test_init_wrong_constraints_type(self): with self.assertRaises(TypeError): dataset = test.PickledDicomoDataSet(dicom_data_set, ["CT"], constraints=[])
def test_init_wrong_label_counter_type(self): with self.assertRaises(TypeError): test.PickledDicomoDataSet( dicom_data_set, ["CT"], constraints={}, label_counter_type=TestPickledDicomoDataSet)
def test_init_invalid_file_path(self): with self.assertRaises(FileNotFoundError): test.PickledDicomoDataSet(wrong_dicom_file_path, ["CT"], constraints={})
def test_summarize_wrong_summary_type(self): data = test.PickledDicomoDataSet(dicom_data_set, ["CT"], constraints={}) with self.assertRaises(TypeError): data.summarize("Modality", print_summary=None)
def test_init_correct_usage(self): dataset = test.PickledDicomoDataSet(dicom_data_set, ["CT"], constraints={}) self.assertIsInstance(dataset, test.PickledDicomoDataSet)
def test_summarize_test_CT_constraint(self): data = test.PickledDicomoDataSet(dicom_data_set, ["CT"], constraints={}) summary_1 = data.summarize("Modality", print_summary=False) summary_2 = data.summarize("BodyPartExamined", print_summary=False) self.assertNotEqual(str(summary_1), str(summary_2))
def test_summarize_correct_usage(self): data = test.PickledDicomoDataSet(dicom_data_set, ["CT"], constraints={}) self.assertIsInstance(data.summarize("Modality", print_summary=False), test.gem.LabelCounter)
def test_classes_wrong_label_type(self): data = test.PickledDicomoDataSet(dicom_data_set, ["CT"], constraints={}) with self.assertRaises(TypeError): data.classes(["Modality"])
def test_subset_correct_usage(self): data = test.PickledDicomoDataSet(dicom_data_set, ["CT"], constraints={}) subset = data.subset({"Modality": "asd"}) with self.assertRaises(StopIteration): next(iter(subset))
def test_init_file_has_wrong_type(self): dataset = test.PickledDicomoDataSet(raw_dicom_file_path, ["CT"], constraints={}) with self.assertRaises(test.gem.pickle.UnpicklingError): next(iter(dataset))
def test_subset_wrong_constraint_type(self): data = test.PickledDicomoDataSet(dicom_data_set, ["CT"], constraints={}) with self.assertRaises(TypeError): subset = data.subset(("Modality", 1))
def test_can_be_parallelized(self): data = test.PickledDicomoDataSet(dicom_data_set, ["CT"], constraints={}) self.assertEqual(data.can_be_parallelized(), False)