Error using fseek Invalid file identifier. Use fopen to generate a valid file identifier.
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Stelios Fanourakis
el 2 de Mayo de 2018
Respondida: Jan
el 2 de Mayo de 2018
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 comentarios
Respuesta aceptada
Jan
el 2 de Mayo de 2018
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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Convert Image Type en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!