def _download_treatmentrecord_test_file(): data_paths = download.zip_data_paths("treatmentrecord-anonymisation.zip") return data_paths
def get_dataset_metadata(): release_url = "https://github.com/pymedphys/data/releases/download/structure-dicom" dicom_zip_url_pattern = f"{release_url}/" + "{dicom_type}.{uid}_Anonymised.zip" mappings_url = f"{release_url}/mappings.zip" data_download_root = pathlib.Path("auto-segmentation-dicom") save_filename = data_download_root.joinpath(get_filename_from_url(mappings_url)) mappings_paths = download.zip_data_paths( save_filename, check_hash=True, redownload_on_hash_mismatch=True, url=mappings_url, ) mapping_filenames = { "hashes": "hashes.json", "name_aliases": "name_mappings.json", "paths_and_uids": "uid-cache.json", "structure_names_by_uid": "structure-names-mapping-cache.json", } mapping_paths = {} for label, filename in mapping_filenames.items(): mapping_path = [path for path in mappings_paths if path.name == filename] if len(mapping_path) != 1: raise ValueError(f"Expected exactly one file named {filename}.") mapping_paths[label] = mapping_path[0] hash_path = mapping_paths["hashes"] data_path_root = hash_path.parent.parent with open(mapping_paths["paths_and_uids"]) as f: uid_cache = json.load(f) ( ct_image_paths, structure_set_paths, ct_uid_to_structure_uid, structure_uid_to_ct_uids, ) = indexing.read_uid_cache(data_path_root, uid_cache) with open(mapping_paths["structure_names_by_uid"]) as f: structure_names_cache = json.load(f) structure_names_by_ct_uid = structure_names_cache["structure_names_by_ct_uid"] structure_names_by_structure_set_uid = structure_names_cache[ "structure_names_by_structure_set_uid" ] uid_to_url = {} for structure_uid, ct_uids in structure_uid_to_ct_uids.items(): uid_to_url[structure_uid] = dicom_zip_url_pattern.format( dicom_type="RS", uid=structure_uid ) for ct_uid in ct_uids: uid_to_url[ct_uid] = dicom_zip_url_pattern.format( dicom_type="CT", uid=ct_uid ) names_map = filtering.load_names_mapping(mapping_paths["name_aliases"]) return ( data_path_root, structure_set_paths, ct_image_paths, ct_uid_to_structure_uid, structure_uid_to_ct_uids, names_map, structure_names_by_ct_uid, structure_names_by_structure_set_uid, uid_to_url, hash_path, )
def _download_rtplan_test_file(): data_paths = download.zip_data_paths("rtplan-anonymisation.zip") return data_paths