def test_subset_correct_usage(self): data = test.ConcurrentPickledDicomObjectTaskSplitter(dicom_directory, ["CT"], constraints={}) subset = data.subset({"Modality": "asd"}) with self.assertRaises(StopIteration): next(iter(subset))
def test_summarize_test_CT_constraint(self): data = test.ConcurrentPickledDicomObjectTaskSplitter(dicom_directory, ["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_iterate_over_all(self): data = iter( test.ConcurrentPickledDicomObjectTaskSplitter(dicom_directory, ["CT"], constraints={})) with self.assertRaises(StopIteration): while True: next(data) self.assertNotEqual(len(data), 0)
def test_len(self): dataset = iter( test.ConcurrentPickledDicomObjectTaskSplitter(dicom_directory, ["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_summarize_wrong_summary_type(self): data = test.ConcurrentPickledDicomObjectTaskSplitter(dicom_directory, ["CT"], constraints={}) with self.assertRaises(TypeError): data.summarize("Modality", print_summary=None)
def test_summarize_correct_usage(self): data = test.ConcurrentPickledDicomObjectTaskSplitter(dicom_directory, ["CT"], constraints={}) self.assertIsInstance(data.summarize("Modality", print_summary=False), test.gem.LabelCounter)
def test_classes_wrong_label_type(self): data = test.ConcurrentPickledDicomObjectTaskSplitter(dicom_directory, ["CT"], constraints={}) with self.assertRaises(TypeError): data.classes(["Modality"])
def test_classes_correct_usage(self): data = test.ConcurrentPickledDicomObjectTaskSplitter(dicom_directory, ["CT"], constraints={}) self.assertIsInstance(data.classes("Modality"), list)
def test_can_be_parallelized(self): data = test.ConcurrentPickledDicomObjectTaskSplitter(dicom_directory, ["CT"], constraints={}) self.assertEqual(data.can_be_parallelized(), True)
def test_subset_wrong_constraint_type(self): data = test.ConcurrentPickledDicomObjectTaskSplitter(dicom_directory, ["CT"], constraints={}) with self.assertRaises(TypeError): subset = data.subset(("Modality", 1))
def test_next(self): dataset = test.ConcurrentPickledDicomObjectTaskSplitter( dicom_directory, ["CT"], constraints={}) data = next(iter(dataset)) self.assertIsInstance(data, list)
def test_iter(self): dataset = test.ConcurrentPickledDicomObjectTaskSplitter( dicom_directory, ["CT"], constraints={}) dataset = iter(dataset) self.assertIsInstance(dataset, test.PickledDicomoFilePool)
def test_init_wrong_constraints_type(self): with self.assertRaises(TypeError): dataset = test.ConcurrentPickledDicomObjectTaskSplitter( dicom_directory, ["CT"], constraints=[])
def test_init_invalid_directory_path(self): test.ConcurrentPickledDicomObjectTaskSplitter(os.path.join( dicom_directory, "asd"), ["CT"], constraints={})
def test_init_wrong_label_counter_type(self): with self.assertRaises(TypeError): test.ConcurrentPickledDicomObjectTaskSplitter( dicom_directory, ["CT"], constraints={}, label_counter_type=TestPickledDicomoDataSet)
def test_init_correct_usage(self): data = test.ConcurrentPickledDicomObjectTaskSplitter(dicom_directory, ["CT"], constraints={}) self.assertIsInstance(data, test.ConcurrentPickledDicomObjectTaskSplitter)