Create New DICOM Series

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 SeriesInstanceUID metadata field. The following example illustrates this process.

  1. Read an image from a DICOM file into the MATLAB® workspace.

    I = dicomread('CT-MONO2-16-ankle.dcm');

    To view the image, use either of the toolbox display functions imshow or imtool. Because the DICOM image data is signed 16-bit data, you must use the autoscaling syntax.

    imtool(I,'DisplayRange',[])

  2. 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 SeriesInstanceUID field.

    info.SeriesInstanceUID
    ans =
    
    1.2.840.113619.2.1.2411.1031152382.365.736169244
  3. 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.

    max(I(:))
    ans =
    
        4080
    min(I(:))
    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.

    imshow(Imodified,[])

  4. 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 =
    
    1.3.6.1.4.1.9590.100.1.1.56461980611264497732341403390561061497

    dicomuid is guaranteed to generate a unique UID.

  5. Set the value of the SeriesInstanceUID field in the metadata associated with the original DICOM file to the generated value.

    info.SeriesInstanceUID = uid;
  6. 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 series.

    dicomwrite(Imodified,'ankle_newseries.dcm',info);

    To verify this operation, view the image and the SeriesInstanceUID metadata field in the new file.

For information about the syntax variations that specify nondefault spatial coordinates, see the reference page for imshow.