How to convert tif stack to dcm series?

27 ビュー (過去 30 日間)
Alena Schwartz
Alena Schwartz 2020 年 8 月 9 日
コメント済み: Braian Adair 2024 年 2 月 20 日
I have a tif file that contains 1813 pages (images). I want to convert these to DICOM files within a single series. Currently, the code I am using writes over the .dcm file during each loop. How can I fix this?
fname = 'Sample19.tif';
info = imfinfo(fname);
imageStack = [];
numberOfImages = length(info);
for k = 1:numberOfImages
currentImage = imread(fname, k, 'Info', info);
dicomwrite(currentImage,'gear.dcm')
imageStack(:,:,k) = currentImage;
end
  1 件のコメント
Amine Adjoud
Amine Adjoud 2022 年 11 月 16 日
I encouter the same problem. Did you find a solution?

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 8 月 10 日
fname = 'Sample19.tif';
info = imfinfo(fname);
imageStack = [];
numberOfImages = length(info);
for k = 1:numberOfImages
currentImage = imread(fname, k, 'Info', info);
imageStack(:,:,k) = currentImage;
end
dicomwrite(imageStack,'gear.dcm')
However, in practice you almost always need a bunch of dicom metadata. The easiest way to get that is to use dicominfo() on a dcm file that has the same kind of attributes that you are going to need, and pass the resulting metadata to dicomwrite after the file name.
  8 件のコメント
Amine Adjoud
Amine Adjoud 2022 年 11 月 16 日
I encouter the same problem, did you get a solution?
Braian Adair
Braian Adair 2024 年 2 月 20 日
Thank you Julianna Mather you solved my four days problem!

サインインしてコメントする。

カテゴリ

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