Image Processing Toolbox User's Guide Previous page   Next Page

Writing Image Data or Metadata to a DICOM File

To write image data or metadata to a file in DICOM format, use the dicomwrite function. This example writes the image I to the DICOM file ankle.dcm.

When you write image data to a DICOM file, dicomwrite includes the minimum set of metadata fields required by the type of DICOM information object (IOD) you are creating. dicomwrite supports three types of DICOM IODs with full validation and supports many other types (e.g. X-ray, radiotherapy, nuclear medicine) without validation.

You can also specify the metadata you want to write to the file by passing to dicomwrite an existing DICOM metadata structure that you retrieved using dicominfo.

In this case, the dicomwrite function writes the relevant information in the metadata structure info to the new DICOM file.

Note that the metadata written to the file is not identical to the metadata in the info structure. When writing metadata to a file, there are certain fields that dicomwrite must update. For example, dicomwrite must update the file modification date in the new file. To illustrate, compare the instance ID in the original metadata with the ID in the new file.

Using dicominfo, read the metadata from the newly written file and check the file modification date.

Anonymizing a DICOM File

When using a DICOM file as part of a training set, blinded study, or a presentation, you might want to remove confidential patient information. To do this, use the dicomanon function.

The dicomanon function creates a new series and study values, changes some of the metadata, and then writes the file. For example, you could replace steps 4, 5, and 6 in the example in Example: Creating a New Series with a call to the dicomanon function.


Previous page  Reading Metadata from a DICOM File Example: Creating a New Series Next page

© 1994-2005 The MathWorks, Inc.