Error using fseek Invalid file identifier. Use fopen to generate a valid file identifier.
조회 수: 2 (최근 30일)
이전 댓글 표시
Anybody knows why it comes up with this error at I = dicomread(fullFileName); line?
Here is my code:
filePatternu = fullfile(myFolder, 'test*.dcm*'); allFilesi = dir(filePatternu);
for k= 1: length(allFilesi) baseFileName = allFilesi(k).name; % e.g. "1.png" fullFileName = fullfile(myFolder, baseFileName); I = dicomread(fullFileName); end
댓글 수: 0
채택된 답변
Jan
2018년 5월 2일
After formatting (using the "{} Code" button...), your code looks fine:
filePatternu = fullfile(myFolder, 'test*.dcm*');
allFilesi = dir(filePatternu);
for k = 1:length(allFilesi)
baseFileName = allFilesi(k).name; % e.g. "1.png"
fullFileName = fullfile(myFolder, baseFileName);
I = dicomread(fullFileName);
end
The only problem I can see is that this catches folders also, when their name match the ".dcm*" pattern. Try this:
allFilesi = dir(filePatternu);
allFilesi([allFilesi.isdir]) = [];
Catching the problem is a good idea also:
for k = 1:length(allFilesi)
baseFileName = allFilesi(k).name; % e.g. "1.png"
fullFileName = fullfile(myFolder, baseFileName);
try
I = dicomread(fullFileName);
catch ME
error('Forum:My:Function', 'Failed to import file [%s]: %s', ...
fullFileName, ME.message);
end
end
Now you can see for which file the import is failing.
Another idea is that the file is used or removed by another application between the dir and the dicomread. Displaying the failing file will help you to identify the problem.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Convert Image Type에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!