Anonymize and keep PatientsAge etc.

I tried to anonymize all the patients in my storage using the sample python script. It works like expected as is, but when I modify it to also keep eg. "PatientsAge" or "PatientsSex", the script aborts with the following error:

Traceback (most recent call last):
  File "", line 45, in <module>
    { 'Keep' : [ 'SeriesDescription', 'StudyDescription', 'StudyDate', 'StudyComments', 'PatientsAge' ] })
  File "/Users/media/Orthanc/Resources/Samples/Python/", line 108, in DoPost
    return _DoPutOrPost(uri, 'POST', data, contentType)
  File "/Users/media/Orthanc/Resources/Samples/Python/", line 87, in _DoPutOrPost
    raise Exception(resp.status)
Exception: 500

Thanks for any help!


Please post a standalone Python script so that we can help you: The error message is insufficient to get an insight of what went wrong.


Here is my script... (1.61 KB)

The same happens when using your continuous anonymization script... (3.19 KB)


These tags are known to Orthanc as “PatientAge” and “PatientSex” (i.e. there is no “s” at the end of “Patient”).

Remove the “s” and it should work fine.


Thanks so much! Osirix DICOM metadata showed the tags wrong.
I now solved nearly all my problems with your help!