Read a dicom file using the name from an Excel

Hello,
I have a folder with 900 images and an excel connected to it and I want to read the images based on the name in the excel. I tried with this code but it didn't worked.
folder=dir('C:\miniRSNA\*.dcm');
a=readtable('miniRSNA-labels.xlsx');
[name]=a(:,8);
for i=1: numel(name)
img(i)= name(i+1);
imag=strcat('C:\miniRSNA', img(i).name);
end
It gives me this error: Subscripting into a table using one subscript (as in t(i)) or three or more subscripts (as in t(i,j,k)) is not supported. Always specify a row subscript and a variable subscript, as in t(rows,vars).

 Accepted Answer

If anyone is interested, I managed to solve the problem
folder=dir('C:\miniRSNA\*.dcm');
[num,str]=xlsread('miniRSNA-labels.xlsx');
[name]=str(:,8);
for i=1: numel(name)
imgag(i)= name(i+1);
imag(i)=strcat('C:\miniRSNA\',imgag(i));
img=dicomread(char(imag(i)));
end

1 Comment

projectdir = 'C:\miniRSNA';
folder = dir( fullfile(projectdir, '*.dcm'));
[num, str] = xlsread('miniRSNA-labels.xlsx'); %umm, which directory is this in?
imagefilenames = fullfile(projectdir, str(2:end,8));
for i = 1 : numel(imagefilename)
img{i} = dicomread( imagefilenames{i} );
end

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!