def test_load_trajectory_log_from_file_object(self): path = get_file_from_cloud_test_repo( ['mlc_logs', 'tlogs', 'dynamic_imrt.bin']) ref_log = TrajectoryLog(path) with open(path, 'rb') as f: t = TrajectoryLog(f) self.assertIsInstance(t, TrajectoryLog) self.assertEqual(t.num_beamholds, ref_log.num_beamholds)
def test_txt_file_also_loads_if_around(self): # has a .txt file log_with_txt = osp.join( TEST_DIR, 'mixed_types', "Anonymous_4DC Treatment_JST90_TX_20140712094246.bin") log = TrajectoryLog(log_with_txt) self.assertIsNotNone(log.txt) self.assertIsInstance(log.txt, dict) self.assertEqual(log.txt['Patient ID'], 'Anonymous') # DOESN'T have a txt file log_no_txt = osp.join( TEST_DIR, 'tlogs', "Anonymous_4DC Treatment_JS0_TX_20140712095629.bin") log = TrajectoryLog(log_no_txt) self.assertIsNone(log.txt)
def test_txt_file_also_loads_if_around(self): # has a .txt file _ = get_folder_from_cloud_test_repo(['mlc_logs', 'mixed_types']) log_with_txt = get_file_from_cloud_test_repo([ 'mlc_logs', 'mixed_types', "Anonymous_4DC Treatment_JST90_TX_20140712094246.bin" ]) log = TrajectoryLog(log_with_txt) self.assertIsNotNone(log.txt) self.assertIsInstance(log.txt, dict) self.assertEqual(log.txt['Patient ID'], 'Anonymous') # DOESN'T have a txt file _ = get_folder_from_cloud_test_repo(['mlc_logs', 'tlogs']) log_no_txt = get_file_from_cloud_test_repo([ 'mlc_logs', 'tlogs', "Anonymous_4DC_Treatment_JS0_TX_20140712095629.bin" ]) log = TrajectoryLog(log_no_txt) self.assertIsNone(log.txt)
def test_destination(self): tlog_file = osp.join( ANONYMOUS_DEST_FOLDER, 'PatientID_4DC Treatment_JST90_TX_20140712094246.bin') tlog = TrajectoryLog(tlog_file) tlog.anonymize(destination=ANONYMOUS_DEST_FOLDER) # shouldn't raise
def setUpClass(cls): cls.log = TrajectoryLog.from_demo() cls.log.fluence.gamma.calc_map()
def test_publish_pdf_w_imaging_log(self): imaging_tlog = TrajectoryLog( get_file_from_cloud_test_repo(['mlc_logs', 'tlogs', 'imaging.bin'])) with self.assertRaises(ValueError), tempfile.NamedTemporaryFile() as t: imaging_tlog.publish_pdf(t.name)
def setUpClass(cls): cls.tlog = TrajectoryLog.from_demo() cls.dlog = Dynalog.from_demo()
def test_calc_gamma_early_fails(self): log = TrajectoryLog.from_demo() with self.assertRaises(ValueError): log.fluence.gamma.plot_map()
def test_dynamic_imrt_log(self): tlog = TrajectoryLog( get_file_from_cloud_test_repo( ['mlc_logs', 'tlogs', 'dynamic_imrt.bin'])) self.assertTrue(tlog.treatment_type, TreatmentType.DYNAMIC_IMRT.value)
def test_imaging_log(self): tlog = TrajectoryLog( get_file_from_cloud_test_repo(['mlc_logs', 'tlogs', 'imaging.bin'])) self.assertTrue(tlog.treatment_type, TreatmentType.IMAGING.value)
def test_vmat_log(self): tlog = TrajectoryLog( get_file_from_cloud_test_repo(['mlc_logs', 'tlogs', 'vmat.bin'])) self.assertTrue(tlog.treatment_type, TreatmentType.VMAT.value)
def test_dynamic_imrt_log(self): tlog = TrajectoryLog(osp.join(TEST_DIR, 'tlogs', 'dynamic_imrt.bin')) self.assertTrue(tlog.treatment_type, DYNAMIC_IMRT)
def test_static_imrt_log(self): tlog = TrajectoryLog(osp.join(TEST_DIR, 'tlogs', 'static_imrt.bin')) self.assertTrue(tlog.treatment_type, STATIC_IMRT)
def test_vmat_log(self): tlog = TrajectoryLog(osp.join(TEST_DIR, 'tlogs', 'vmat.bin')) self.assertTrue(tlog.treatment_type, VMAT)
def test_imaging_log(self): tlog = TrajectoryLog(osp.join(TEST_DIR, 'tlogs', 'imaging.bin')) self.assertTrue(tlog.treatment_type, IMAGING)
def test_publish_pdf_w_imaging_log(self): imaging_tlog = TrajectoryLog(osp.join(TEST_DIR, 'tlogs', 'imaging.bin')) with self.assertRaises(ValueError), tempfile.TemporaryFile() as t: imaging_tlog.publish_pdf(t)