Copy DICOM header and use it to different DICOM images

2 Ansichten (letzte 30 Tage)
Mar
Mar am 13 Nov. 2018
Kommentiert: Mar am 14 Nov. 2018
Hi,
I have a stack of 2D DICOM images. I want to replace the DICOM header of these DICOM images (without affecting pixel intensities) with another DICOM header (DICOM header from another dataset) that has all the info I need. Can I do this in Matlab?
Thanks.
  4 Kommentare
Rik
Rik am 13 Nov. 2018
That should work. You can easily test it by re-loading and comparing:
info = dicominfo('DICOM_1');
data = dicomread('DICOM_2');
dicomwrite(data,'NEW_FILE',info);
info_new=dicominfo('NEW_FILE');
data_new=dicomread('NEW_FILE');
isequal(data_new,data)
isequal(info_new,info)
Note that the info sometimes contains the filename as well, so the last test might return false for a succesfull operation.
With doing it in binary I meant reading the binary stream that contains the metadata, and writing that together with the binary stream containing the pixel data. That is much harder to work with, and you need to do more yourself, but at least you can be sure that result is bit-perfect.
Mar
Mar am 14 Nov. 2018
I wanted to make a loop to do this procedure to the 300 images that I have but for some reason it doesn't read the data in the right order. I want to take the DICOM header from IM1 from the one folder and the data from IM1 from the other folder. The two folders have the same size of images. Below is the code I used:
pwd1 = ‘path to folder with DICOM images’;
pwd2 = ‘path to folder with the DICOM headers I want to use’;
dicomlist = dir(fullfile(pwd1,’IM*'));
headerlist = dir(fullfile(pwd2,'IM*'));
for cnt = 1 : numel(dicomlist)
info{cnt} = dicominfo(fullfile(pwd2,headerlist(cnt).name));
I{cnt} = dicomread(fullfile(pwd1,dicomlist(cnt).name));
status{cnt} = dicomwrite(I{cnt},num2str(cnt),info{cnt});
end
Can anyone help with that?

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu DICOM Format finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by