When writing a modified image to a DICOM file, you might want to make the modified image
the start of a new series. In the DICOM standard, images can be organized into series. When
you write an image with metadata to a DICOM file,
dicomwrite puts the image in the same series by default. To create a new series,
you must assign a new DICOM unique identifier to the
metadata field. The following example illustrates this process.
Read an image from a DICOM file into the MATLAB® workspace.
I = dicomread('CT-MONO2-16-ankle.dcm');
Read the metadata from the same DICOM file.
info = dicominfo('CT-MONO2-16-ankle.dcm');
To identify the series an image belongs to, view the value of the
ans = 1.2.840.1136188.8.131.521.1031152382.365.736169244
You typically only start a new DICOM series when you modify the image in some way. This example removes all the text from the image.
The example finds the maximum and minimum values of all pixels in the image. The pixels that form the white text characters are set to the maximum pixel value.
ans = 4080
ans = 32
To remove these text characters, the example sets all pixels with the maximum value to the minimum value.
Imodified = I; Imodified(Imodified == 4080) = 32;
View the processed image.
Generate a new DICOM unique identifier (UID) using the
dicomuid function. You need a new UID to write the modified image as
a new series.
uid = dicomuid
uid = 184.108.40.206.4.1.95220.127.116.11.56461980611264497732341403390561061497
dicomuid is guaranteed to generate a unique UID.
Set the value of the
SeriesInstanceUID field in
the metadata associated with the original DICOM file to the generated value.
info.SeriesInstanceUID = uid;
Write the modified image to a new DICOM file, specifying the
modified metadata structure,
info, as an argument. Because you set the
SeriesInstanceUID value, the image you write is part of a new
To verify this operation, view the image and the
metadata field in the new file.
For information about the syntax variations that specify nondefault spatial coordinates,
see the reference page for