Пример #1
0
 def test_from_file_apply_invalid_transformation(self):
     with self.assertRaises(Exception):
         next(
             iter(
                 test.PickledDicomoDataSet(dicom_data_set, ["CT"],
                                           transform=[],
                                           constraints={})))
Пример #2
0
 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)
Пример #3
0
    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)
Пример #4
0
 def test_iter(self):
     dataset = test.PickledDicomoDataSet(dicom_data_set, ["CT"],
                                         constraints={})
     dataset = iter(dataset)
     self.assertIsInstance(dataset, test.PickledDicomoDataSet)
Пример #5
0
 def test_next(self):
     dataset = test.PickledDicomoDataSet(dicom_data_set, ["CT"],
                                         constraints={})
     data = next(iter(dataset))
     self.assertIsInstance(data, list)
Пример #6
0
 def test_classes_correct_usage(self):
     data = test.PickledDicomoDataSet(dicom_data_set, ["CT"],
                                      constraints={})
     self.assertIsInstance(data.classes("Modality"), list)
Пример #7
0
 def test_init_wrong_constraints_type(self):
     with self.assertRaises(TypeError):
         dataset = test.PickledDicomoDataSet(dicom_data_set, ["CT"],
                                             constraints=[])
Пример #8
0
 def test_init_wrong_label_counter_type(self):
     with self.assertRaises(TypeError):
         test.PickledDicomoDataSet(
             dicom_data_set, ["CT"],
             constraints={},
             label_counter_type=TestPickledDicomoDataSet)
Пример #9
0
 def test_init_invalid_file_path(self):
     with self.assertRaises(FileNotFoundError):
         test.PickledDicomoDataSet(wrong_dicom_file_path, ["CT"],
                                   constraints={})
Пример #10
0
 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)
Пример #11
0
 def test_init_correct_usage(self):
     dataset = test.PickledDicomoDataSet(dicom_data_set, ["CT"],
                                         constraints={})
     self.assertIsInstance(dataset, test.PickledDicomoDataSet)
Пример #12
0
 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))
Пример #13
0
 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)
Пример #14
0
 def test_classes_wrong_label_type(self):
     data = test.PickledDicomoDataSet(dicom_data_set, ["CT"],
                                      constraints={})
     with self.assertRaises(TypeError):
         data.classes(["Modality"])
Пример #15
0
 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))
Пример #16
0
 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))
Пример #17
0
 def test_subset_wrong_constraint_type(self):
     data = test.PickledDicomoDataSet(dicom_data_set, ["CT"],
                                      constraints={})
     with self.assertRaises(TypeError):
         subset = data.subset(("Modality", 1))
Пример #18
0
 def test_can_be_parallelized(self):
     data = test.PickledDicomoDataSet(dicom_data_set, ["CT"],
                                      constraints={})
     self.assertEqual(data.can_be_parallelized(), False)