What values can I add to my DICOM file with DICOMWRITE?
3 views (last 30 days)
Show older comments
MathWorks Support Team
on 27 Jun 2009
Commented: Walter Roberson
on 21 Jul 2020
I would like to know what values I can add to my DICOM file with DICOMWRITE.
Accepted Answer
MathWorks Support Team
on 27 Jun 2009
DICOM files are collections of DICOM information objects, called IODs. Different IODs correspond to different types of real world medical images. For example, single-frame MR images have their own IOD, as do CT, nuclear medicine, and ultrasound images. Each IOD has a specific set of DICOM attributes that it can contain. The DICOM spec defines the set of attributes for each IOD, and only those attributes can be written to a DICOM file containing the IOD.
The DICOMWRITE function included as of version 3.2 (R13) of the Image Processing Toolbox stores "Secondary Capture" (SC) objects. Only attributes associated with the SC IOD can be used by DICOMWRITE.
Nevertheless, it is possible to pass attributes to DICOMWRITE that do not belong with the SC IOD. However, these values are ignored. For example:
status = dicomwrite(X, filename, 'SliceThickness', 16)
attempts to place the 'SliceThickness' attribute in the output file. This attribute cannot be stored in a SC DICOM image, so it is ignored.
The optional output value of DICOMWRITE gives information about parameters passed to DICOMWRITE that were ignored. The value returned is a structure with three fields corresponding to the three categories of parameters that are ignored.
(1) Some parameters don't belong with the SC IOD, 'SliceThickness' for example. This field is called 'wrong_iod'.
(2) The 'not_modifiable' field lists parameters that apply to the SC IOD but can't be modified by the users. These parameters (such as 'Columns' and 'BitsAllocated') are usually values inferred from the image.
(3) If you pass a structure of attributes from DICOMINFO to DICOMWRITE, you are also passing several special values added by DICOMINFO. These parameters are contained in 'dicominfo_fields'.
1 Comment
More Answers (1)
Julianna Mather
on 11 Mar 2019
The answer from 2009 is no longer accurate. (It might not have been accurate at the time it was posted.)
In short: DICOMWRITE supports any arbitrary DICOM file that contains images. This includes much, much more than SC. Use the "CreateMode" parameter instead of the "IOD" parameter to get access to all of these information objects.
Longer answer: DICOMWRITE has two modes: Create and Copy. These are specified with the "CreateMode" name-value pair. In "Create" mode, you have to give all of the relevant metadata beyond what we can infer from the image pixels. For Secondary Capture images, there isn't anything extra that has to be given. CreateMode == Create was the way that DICOMWRITE originally worked, which is why the default result from DICOMWRITE is a Secondary Capture image. Other DICOM information objects that we can create with full validation are CT and MR.
It quickly became apparent that people wanted to write DICOM files containing many more kinds of information objects than CT, MR, and SC. For us (at MathWorks) to create that metadata from scratch--or more accurately, for us to list all of the metadata that needs to be specified and to validate it all--became prohibitively difficult and we recognized that customers wanted to make new DICOM files based on existing metadata from other files, modifying only a couple of values and the pixel data. This is when we added CreateMode == copy. This was a *really* long time ago (around 2005... maybe earlier... the years blend together). Using this parameter, every conceivable DICOM information object that stores pixel data is supported by DICOMWRITE, assuming the customer has a similar DICOM file with accurate metadata that they can use. It's worth noting that we only do minimal validation of this metadata.
Notable exceptions to "every conceivable DICOM information object that stores pixel data" are DICOM IODs that don't store pixels: radiotherapy, DICOMDIR, and structured reports. This could conceivably change in the near future.
1 Comment
Walter Roberson
on 21 Jul 2020
dicom files are binary files. you do not edit them.
can you post a link to the file? I understand that dicom files often contain private information, so it is understandable if you cannot do that, but it would make it easier for us
See Also
Categories
Find more on DICOM Format in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!