MATLAB: Some DICOM info cannot be added to the Header

dicomMATLAB

Hello all,
I am creating a DICOM file using MatLab and adding data to the header. What I could not understand or figure out is when when I used for example the following code:
info.(dicomlookup('0010', '0010'))='name'
to enter the patient name it worked, as well as many other metadata. However, when I tried entering some other info, it did not give me an error at first, but after creating the dicom file then trying reading the specific data in the dicom info, it kept saying reference to non existed field.
For example, I tried entering clinic name using the following line: info.(dicomlookup('0008', '0080'))
It did not give me an error when creating the file, but after I tried to dicomread what has already been written, it said:
(Reference to non-existent field 'InstitutionName').
I used the same method for other data like patient name and it worked though. Can anyone please help me understand how to do this. I also used different versions at school hoping that it is just a bug but with no luck!
Thanks in advance!
Ali

Best Answer

Hello Mohammed,
This behavior seems to be related to the 'CreateMode' option of the dicomwrite function. It is set to 'Create' by default. If you set it to 'Copy' everything works fine. I have tested the following example with MATLAB R2014a and it seems to work fine:
>> X = dicomread('CT-MONO2-16-ankle.dcm');
>> info = dicominfo('CT-MONO2-16-ankle.dcm');
>> info.(dicomlookup('0010', '0010'))='name';
>> info.(dicomlookup('0008', '0080')) = 'Abc XyZ';
>> dicomwrite(X, 'ct_file.dcm', info,'CreateMode','Copy');
>> metadata = dicominfo('ct_file.dcm');
>> metadata.PatientName
>> metadata.InstitutionName
I hope this information and example helps.
Nalini
Related Question