Cellstr error in my program: Where is my mistake?

Hi, My program is the following:
s = dir('./sub*/*.*');
for kk = 1:numel(s);
if ~s(kk).isdir
dicomfiles = 1:numel('./sub*/*.*');
fd=spm_file(dicomfiles(1,:), 'fpath');
cd(fd);
hdr=spm_dicom_headers(dicomfiles);
spm_dicom_convert(hdr, 'all', 'series', 'nii')
else
end
msgbox ('done' , 'OK')
end
I am trying to get the program to read all folders containing the word sub and then in each folder convert the files and then loop to go through each folder, then the files, etc.
I am currently getting the errors:
Error using cellstr (line 49)
Conversion to cellstr from double is not possible.
Error in spm_file (line 63)
str = cellstr(str);
Error in LoopDcmConv (line 5)
fd=spm_file(dicomfiles(1,:), 'fpath');
Would someone be able to tell me where to change the program to make it run properly?

댓글 수: 2

This is strange as it will always return the array [1 2 ... 10]
1:numel('./sub*/*.*')
so, the next line will return a strange character array
I can change that command to 1:160, since I know how many files I want to read per folder, when I change that it gets rid of the line 5 error

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Variables에 대해 자세히 알아보기

질문:

2018년 10월 4일

댓글:

2018년 10월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by