Why does DICOMINFO read metadata from my DICOM file as UINT8 when I expect SINGLE?

4 views (last 30 days)
I have DICOM data that I am trying to read using "dicominfo". When I call "dicominfo" in Matlab (64-bit), the value of the Private tag (0019, 100E) with value representation "FD" is read as an UINT8 array (length 24), instead of a SINGLE precision float array (length 3) that I expect. Note that the tag value is decoded correctly by GDCM-toolkit that uses Win32.dll library. See below for an example: 
 
>> inf2 = dicominfo('002'); 
>> inf2.Private_0019_100e' %% correct answer [0 1 0.00066667] 
ans = 
Columns 1 through 16 
0 0 0 0 0 0 0 0 179 166 38 127 255 255 239 191 
Columns 17 through 24 
181 216 113 236 110 216 69 63 
Why does "dicominfo" read the data from my DICOM file incorrectly?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 24 Feb 2021
Edited: MathWorks Support Team on 24 Feb 2021
This is expected behavior that is the result of using a DICOM Dictionary that does not have the specific group element tag mentioned. MATLAB ships with a dictionary of thousands of standard DICOM metadata fields. When it encounters metadata fields that are not in the standard dictionary, MATLAB does not know how to interpret the data correctly and reads it as a sequence of bytes, which you see as the UINT8 array. 
To solve this issue, you will need to create a copy of the DICOM Dictionary and edit it to add all of the private fields that are not defined in the data dictionary, and then set MATLAB to use your copy using "dicomdict". I will explain this in further detail below. 
The following documentation details how to read DICOM metadata not part of the standard, and how to create your own copy of the DICOM Dictionary to include these: 
Particularly relevant from the documentation is the following section: 
"When dicominfo encounters a private metadata field in a DICOM file, it returns the metadata creating a generic name for the field based on the group and element tags of the metadata. For example, if the file contained private metadata at group 0009 and element 0006, dicominfo creates the name:Private_0009_0006. dicominfo attempts to interpret the private metadata, if it can. For example, if the metadata is a text string, dicominfo processes the data. If it can't interpret the data, dicominfo returns a sequence of bytes."
According to the documentation, the following are the steps that you will need to take to fix this issue.
1) Create a copy of the "dicom-dict.txt" file that defines the DICOM data dictionary. You can access this file by typing the following at the MATLAB command prompt:
edit(dicomdict('get'))
Then, save a copy of this file, for instance as "dicom_dict_copy.txt".
 
2) Add entries for all of the private fields that are not defined in the data dictionary. You can find those fields by running the following code:
fn = cell(1,4);
[fn{:}] = textread(dicomdict('get'),repmat('%s',1,4),'delimiter','\t','commentstyle','shell');
info = dicominfo('<your_dicom_file_here>''); % that is one of your output files
not_defined = setdiff(lower(fieldnames(info)),lower(fn{3}));
not_defined(cellfun(@(c) isempty(strfind(c,'private_')),not_defined)) = [];
3) According to the DICOM spec, you will need to modify the copy of the "dicom-dict.txt" file for all the fields defined in the "not_defined" variable above. Note that you will need the following four pieces of information to do this: 
 
(a) Group and element identifiers: E.g., (0019,100E)
(b) Value representation: Two character code, e.g. "FD"
(c) Attribute name
(d) Multiplicity
You can read the DICOM spec at the following websites:
ftp://medical.nema.org/medical/dicom/2008/
ftp://medical.nema.org/medical/dicom/2008/08_06pu.pdf
4) Once you have done this you can set the modified dictionary to be used for future decoding using the following syntax:
dicomdict('set', 'dicom_dict_copy.txt');

More Answers (0)

Products


Release

R2014a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!