まず、DICOMヘッダを取得するには、各フィールドを含むstruct
を返しますdicominfo
を使用する必要があります。 InstanceNumber
フィールドを並べ替えに使用する場合は、このようにすることができます。言われて、あなたはInstanceNumberを使用して慎重に並べ替えDICOMsする必要があることを
%// Get all of the files
directory = uigetdir();
files = dir(fullfile(directory, '*.dcm'));
filenames = cellfun(@(x)fullfile(directory, x), {files.name}, 'uni', 0);
%// Ensure that they are actually DICOM files and remove the ones that aren't
notdicom = ~cellfun(@isdicom, filenames);
files(notdicom) = [];
%// Now load all the DICOM headers into an array of structs
infos = cellfun(@dicominfo, filenames);
%// Now sort these by the instance number
[~, inds] = sort([infos.InstanceNumber]);
infos = infos(inds);
%// Now you can loop through and display them
dcm = dicomread(infos(1));
him = imshow(dcm, []);
for k = 1:numel(infos)
set(him, 'CData', dicomread(infos(k)));
pause(0.1)
end
。 「InstanceNumber」は、時間の経過とともに取得された同じ画像、または3Dボリューム全体で異なるスライスを参照できるため、これを実行する堅牢な方法ではありません。あなたがどちらか一方を望むなら、私はもっと具体的なものを選ぶでしょう。
物理スライスを並べ替える場合は、SliceLocation
フィールド(使用可能な場合)でソートすることをお勧めします。時間でソートする場合は、TriggerTime
(利用可能な場合)を使用できます。
また、あなたはまた、潜在的ので、多分これらを区別するためにSeriesNumber
を使用することを検討してフォルダ内の複数のシリーズがあるかもしれないことを考慮する必要があります。
本当にありがとうございました,,,しかし、あなたのコードを試したところ、次のエラーで戻ってきました。 非構造体配列オブジェクトからの構造体の参照です。 プロジェクト3のエラー> Load_Image_Callback(行190) [〜、inds] = sort([infos.InstanceNumber]); –
@AhmedHassaan申し訳ありません!私は 'cellfun'呼び出しを' dicominfo'に変更して、セルではなく構造体を返さなければなりませんでした。今すぐテストしてください。 – Suever