Dicominfo and Dicomread for multiple images

4 ビュー (過去 30 日間)
Reda Ghafeer
Reda Ghafeer 2020 年 11 月 16 日
コメント済み: Reda Ghafeer 2020 年 11 月 26 日
I have a total of 3281 .dcm images in a folder, they are each named differently. I am trying to extract certain fields from the headers of the DICOM images and create an array of each field that includes said field for all images to try to extract them to excel.
%Specify the folder where the files live.
myFolder = 'D:\AUS\Masters\Mammography_Images';
% Get a list of all files in the folder with the desired file name pattern.
filePattern = fullfile(myFolder, '*.dcm'); % Change to whatever pattern you need.
theFiles = dir(filePattern);
for k = 1 : 2
baseFileName = theFiles(k).name;
fullFileName = fullfile(theFiles(k).folder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
if dicominfo(fullFileName).KVP~=0;
KVP=dicominfo(fullFileName).KVP;
else KVP=0;
end
end
I am gettin the following error:
Reference to non-existent field 'KVP'.

採用された回答

Madhav Thakker
Madhav Thakker 2020 年 11 月 24 日
編集済み: Madhav Thakker 2020 年 11 月 24 日
Hi Reda,
You can use isfield to check whether a field exists in a structure.
Here is a similar question which has several different implementations for the same.
Hope this helps.
  1 件のコメント
Reda Ghafeer
Reda Ghafeer 2020 年 11 月 26 日
Hello Madhav,
Apologies for not replying sooner. I figured out how to only apply my code to actual images that include my parameters. Thank you very much for your help anyways.

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

その他の回答 (0 件)

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by