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 Center および File ExchangeDICOM Format についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by