Closed mkzia closed 5 months ago
Hi,
There is not easy way with just the CLI.
However, you can start with the anonymize_extra_rules.py
example and tweak the anonymizing function to get the desired result
import argparse
from dicomanonymizer.dicomfields import ALL_TAGS
from dicomanonymizer import anonymize
def main():
parser = argparse.ArgumentParser(add_help=True)
parser.add_argument(
"input",
help="Path to the input dicom file or input directory which contains dicom files",
)
parser.add_argument(
"output",
help="Path to the output dicom file or output directory which will contains dicom files",
)
args = parser.parse_args()
input_dicom_path = args.input
output_dicom_path = args.output
extra_anonymization_rules = {}
def anonymize_if_DT(dataset, tag):
element = dataset.get(tag)
if element is not None and element.VR == "DT":
# Change value to whatever you need
element.value = "00000000" # YYYYMMDD format
# ALL_TAGS variable is defined on file dicomfields.py
for i in ALL_TAGS:
extra_anonymization_rules[i] = anonymize_if_DT
# Launch the anonymization
anonymize(
input_dicom_path,
output_dicom_path,
extra_anonymization_rules,
delete_private_tags=False,
)
if __name__ == "__main__":
main()
Hello,
Is it possible to anonymize all DT tags without having to specify each tag?
Thanks