Write images as DICOM files
dicomwrite(___,
specifies optional metadata or file options in structure
meta_struct
)meta_struct
. The names of fields in
meta_struct
must be the names of DICOM file attributes
or options. The value of a field is the value you want to assign to the
attribute or option.
dicomwrite(___,'ObjectType',
writes a file containing the necessary metadata for a particular type of DICOM
Information Object (IOD). For the supported IODs, IOD
)dicomwrite
verifies that all required metadata attributes are present, creates missing
attributes if necessary, and specifies default values where possible. Using
these supported IODs is the best way to ensure that the files you create conform
to the DICOM specification. For more information, see Tips.
dicomwrite(___,'SOPClassUID',
writes a file containing the necessary metadata for a particular type IOD,
specified using a DICOM Unique Identifier (UID).UID
)
dicomwrite(___,
writes to a DICOM file using Name,Value
)Name,Value
pairs to affect how
the file is written. You can specify multiple name-value pairs.
You can also use Name,Value
pairs to specify optional
metadata to write to the DICOM file. To find a list of the DICOM attributes that
you can specify, see the data dictionary file,
dicom-dict.txt
, included with the Image Processing Toolbox™ software. Enclose each attribute name in quotes.
The DICOM format specification lists several Information Object Definitions (IODs) that can be created. These IODs correspond to images and metadata produced by different real-world modalities (for example, MR, X-ray, Ultrasound, etc.). For each type of IOD, the DICOM specification defines the set of metadata that must be present and possible values for other metadata.
dicomwrite
fully implements a limited number of
IOD
s. For these IODs,
dicomwrite
verifies that all required metadata
attributes are present, creates missing attributes if necessary, and
specifies default values where possible. Using these supported IODs is
the best way to ensure that the files you create conform to the DICOM
specification. This is dicomwrite
default behavior
and corresponds to the CreateMode
option value of
'Create'
.
To write DICOM files for IODs that dicomwrite
doesn't implement, use the 'Copy'
value for the
CreateMode
option. In this mode,
dicomwrite
writes the image data to a file
including the metadata that you specify as a parameter, shown above in
the info
syntax. The purpose of this option is to
take metadata from an existing file of the same modality or IOD and use
it to create a new DICOM file with different image pixel data. If the
image data is empty, dicomwrite
does not write
image-related metadata attributes to the new DICOM file.
Note
Because dicomwrite
copies metadata to the file
without verification in 'Copy'
mode, it is
possible to create a DICOM file that does not conform to the DICOM
standard. For example, the file may be missing required metadata,
contain superfluous metadata, or the metadata may no longer
correspond to the modality settings used to generate the original
image. When using 'Copy'
mode, make sure that the
metadata you use is from the same modality and IOD. If the copy you
make is unrelated to the original image, use dicomuid
to create
new unique identifiers for series and study metadata. See the IOD
descriptions in Part 3 of the DICOM specification for more
information on appropriate IOD values.