Copy DICOM header and use it to different DICOM images

조회 수: 5 (최근 30일)
Mar
Mar 2018년 11월 13일
댓글: Mar 2018년 11월 14일
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
Rik
Rik 2018년 11월 13일
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 2018년 11월 14일
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?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 DICOM Format에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by