예제 #1
0
def write_metadata(image_path: Path, image: sitk.Image):
    """Write down the metadata keys to a txt file"""
    metadata = {}
    for key in image.GetMetaDataKeys():
        metadata[key] = image.GetMetaData(key)

    metadata_path = Path(image_path.parent, image_path.stem + '_metadata.txt')
    util.write_json(metadata, metadata_path)
예제 #2
0
def get_metadata_dictionary(image: SimpleITK.Image) -> dict:
    dictionary = dict()
    for key in image.GetMetaDataKeys():
        value = image.GetMetaData(key)
        dictionary[key] = np.array(value)
    return dictionary