def test_dicom_dose_constancy(): wedge_basline_filename = "wedge_dose_baseline.json" baseline_dicom_dose_dict_zippath = download.get_file_within_data_zip( "dicom_dose_test_data.zip", "lfs-wedge_dose_baseline.zip") test_dicom_dose_filepath = download.get_file_within_data_zip( "dicom_dose_test_data.zip", "RD.wedge.dcm") test_dicom_dose = DicomDose.from_file(test_dicom_dose_filepath) with ZipFile(baseline_dicom_dose_dict_zippath, "r") as zip_ref: with zip_ref.open(wedge_basline_filename) as a_file: expected_dicom_dose_dict = json.load(a_file) assert np.allclose(test_dicom_dose.values, np.array(expected_dicom_dose_dict["values"])) assert test_dicom_dose.units == expected_dicom_dose_dict["units"] assert np.allclose(test_dicom_dose.x, np.array(expected_dicom_dose_dict["x"])) assert np.allclose(test_dicom_dose.y, np.array(expected_dicom_dose_dict["y"])) assert np.allclose(test_dicom_dose.z, np.array(expected_dicom_dose_dict["z"])) assert np.allclose(test_dicom_dose.coords, np.array(expected_dicom_dose_dict["coords"]))
def run_xyz_function_tests(coord_system): r"""Run the xyz extraction test sequence for a given xyz extraction function""" expected_xyz_path = download.get_file_within_data_zip( "dicom_dose_test_data.zip", "expected_{}_xyz.json".format(coord_system.lower())) with open(expected_xyz_path) as fp: expected_xyz = json.load(fp) assert set(expected_xyz.keys()) == set(ORIENTATIONS_SUPPORTED) test_ds_dict = { key: pydicom.dcmread(get_data_file(key)) for key in ORIENTATIONS_SUPPORTED } for orient, dicom in test_ds_dict.items(): test_xyz = coords.xyz_axes_from_dataset(dicom, coord_system) expected_xyz[orient] = np.array(expected_xyz[orient]) # These tests were being skipped in the previous code assert np.array_equal(test_xyz[0], expected_xyz[orient][0]) assert np.array_equal(test_xyz[1], expected_xyz[orient][1]) assert np.array_equal(test_xyz[2], expected_xyz[orient][2])
def loaded_plan(): plan = pydicom.read_file( str( download.get_file_within_data_zip("tps_compare_dicom_files.zip", DICOM_PLAN_FILEPATH)), force=True, ) return plan
def test_read_prs(): data_zip_name = "profiler_test_data.zip" file_name = download.get_file_within_data_zip(data_zip_name, "test_varian_open.prs") assert np.allclose(read_prs(file_name).cax, 45.50562901780488) assert np.allclose(read_prs(file_name).x[0][1], 0.579460838649598) assert np.allclose(read_prs(file_name).y[0][1], 0.2910764234184594) file_name = download.get_file_within_data_zip(data_zip_name, "test_varian_wedge.prs") assert np.allclose(read_prs(file_name).cax, 21.863167869662274) assert np.allclose(read_prs(file_name).x[0][1], 0.5626051581458927) assert np.allclose(read_prs(file_name).y[0][1], 0.260042064635505) file_name = download.get_file_within_data_zip(data_zip_name, "test_tomo_50mm.prs") assert np.allclose(read_prs(file_name).cax, 784.320114110518) assert np.allclose(read_prs(file_name).x[0][1], 563.4064789252321) assert np.allclose(read_prs(file_name).y[0][1], 1.8690221773721463)
def loaded_doses(): doses = {} for key, filepath in DICOM_DOSE_FILEPATHS.items(): resolved_filepath = str( download.get_file_within_data_zip("tps_compare_dicom_files.zip", filepath)) with lzma.open(resolved_filepath) as a_file: doses[key] = pydicom.dcmread(a_file, force=True) return doses
def get_data_file(filename): return download.get_file_within_data_zip("gamma_test_data.zip", filename)
def get_online_data(filename): return download.get_file_within_data_zip("pinnacle_test_data.zip", filename)
def get_data_file(filename): return download.get_file_within_data_zip("paulking_test_data.zip", filename)
def test_read_bin_file(): assert read_bin_file( download.get_file_within_data_zip( "paulking_test_data.zip", "MLC_all_test_old_800P.bin" ) ).shape == (400, 64)
def get_sinogram_csv_path(): return download.get_file_within_data_zip("paulking_test_data.zip", "sinogram.csv")
def get_data_file(orientation_key): return download.get_file_within_data_zip( "dicom_dose_test_data.zip", "RD.DICOMORIENT.Dose_{}_empty.dcm".format(orientation_key), )