This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.


Anonymize DICOM file


dicomanon(file_in, file_out)
dicomanon(..., 'keep', FIELDS)
dicomanon(..., 'update', ATTRS)


dicomanon(file_in, file_out) removes confidential medical information from the DICOM file file_in and creates a new file file_out with the modified values. Image data and other attributes are unmodified.

dicomanon(..., 'keep', FIELDS) modifies all of the confidential data except for those listed in FIELDS, which is a cell array of field names. This syntax is useful for keeping metadata that does not uniquely identify the patient but is useful for diagnostic purposes (e.g., PatientAge, PatientSex, etc.).

    Note   Keeping certain fields might compromise patient confidentiality.

dicomanon(..., 'update', ATTRS) modifies the confidential data and updates particular confidential data. ATTRS is a structure whose fields are the names of the attributes to preserve. The structure values are the attribute values. Use this syntax to preserve the Study/Series/Image hierarchy or to replace a specific value with a more generic property (e.g., remove PatientBirthDate but keep a computed PatientAge).

dicomanon(...,'WritePrivate',TF) specifies whether dicomanon should write nonstandard attributes to the anonymized file. If TF is true, dicomanon includes private extensions in the file, which could compromise patient confidentiality. The default value is false.

dicomanon(...,'UseVRHeuristic',TF) instructs the parser to use a heuristic to help read certain noncompliant files which switch value representation (VR) modes incorrectly. dicomanon displays a warning if the heuristic is employed. When TF is true (the default), a small number of compliant files will not be read correctly. Set TF to false to read these compliant files. Compliant files are always written.

For information about the fields that will be modified or removed, see DICOM Supplement 55 from


Remove all confidential metadata from a file.

dicomanon('patient.dcm', 'anonymized.dcm')

Create a training file.

dicomanon('tumor.dcm', 'tumor_anon.dcm', 'keep',...
         {'PatientAge', 'PatientSex', 'StudyDescription'})

Anonymize a series of images, keeping the hierarchy.

values.StudyInstanceUID = dicomuid;
values.SeriesInstanceUID = dicomuid;
d = dir('*.dcm');
for p = 1:numel(d)
	dicomanon(d(p).name, sprintf('anon%d.dcm', p), ...
		'update', values)

Introduced before R2006a

Was this topic helpful?