DICOM画像からdicominfoにてヘッダー情報を構造体配列として抽出できたのですが、これをxlsxファイルとして出力する方法をご享受ください。

 採用された回答

Kojiro Saito
Kojiro Saito 2022 年 9 月 8 日

1 投票

構造体配列はwritestructでXML形式に出力できますが、そのままではExcel形式にならないので、struct2tableを使って構造体をテーブルに変換してからwritetableでファイル出力します。
サンプルコードです。
dataInfo = dicominfo('CT-MONO2-16-ankle.dcm');
dataInfoTbl = struct2table(dataInfo, 'AsArray', true);
writetable(dataInfoTbl, 'out.xlsx')
このDICOMデータではNameOfPhysiciansReadingStudyやOperatorsNameが構造体の入れ子になっているので、それもファイルに出力するには以下のように入れ子の構造体を配列に変換しておきます。
dataInfo = dicominfo('CT-MONO2-16-ankle.dcm');
fieldsNames = fieldnames(dataInfo);
for n=1:length(fieldsNames)
if isstruct(dataInfo.(fieldsNames{n}))
dataInfo.(fieldsNames{n}) = struct2array(dataInfo.(fieldsNames{n}));
end
end
dataInfoTbl = struct2table(dataInfo, 'AsArray', true);
writetable(dataInfoTbl, 'out.xlsx')

1 件のコメント

RYO ARATA
RYO ARATA 2022 年 9 月 10 日
変換できました!ありがとうございます。

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeDICOM Format についてさらに検索

製品

リリース

R2022a

タグ

質問済み:

2022 年 9 月 8 日

コメント済み:

2022 年 9 月 10 日

Community Treasure Hunt

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

Start Hunting!