필터 지우기
필터 지우기

Error using dicomread, file not found

조회 수: 6 (최근 30일)
Olukayode Sonaike
Olukayode Sonaike 2017년 10월 31일
댓글: Olukayode Sonaike 2017년 11월 1일
Am using dicom images in my project.
Currently trying to read in a series of dicom images into an array using dicomread but I keep getting these error.
Error using dicom_getFileDetails (line 14)
File "00100002.dcm" not found.
Error in dicomread>newDicomread (line 188)
fileDetails = dicom_getFileDetails(filename);
Error in dicomread (line 86)
[X, map, alpha, overlays] = newDicomread(msgname, frames, useVRHeuristic);
Error in Brain_Scannerv1 (line 20)
X(:,:,1,y) = uint16(dicomread(fileNames{y}));
side notes
the files don't have the .dcm extension so I have to add the extension to the filenames.
code below works for a folder containing dicom images but not all of them.
%%create filepath and find list of Dicom
folder_path = uigetdir;
addpath(folder_path)
dirOutput = dir(fullfile(folder_path));
fileNames = {dirOutput.name};
file_num = length(fileNames); %get the number of dicom files.
ext = '.dcm';
for p = 1:file_num
fileNames(p) = strcat(fileNames(p),ext);
end
fileNames(:,[1, 2]) = []; % first 2 filenames don't have have an actual file so i clear the first 2 columns
file_num = length(fileNames);
%%read DICOM files
X = repmat(int16(0), [256 256 1 file_num]); %preallocate array to store files
for y=1:file_num
X(:,:,1,y) = uint16(dicomread(fileNames{y}));
end
Any help is appreciated

채택된 답변

Walter Roberson
Walter Roberson 2017년 10월 31일
folder_path = uigetdir;
dirOutput = dir(folder_path);
dirOutput([dirOutput.isdir]) = [];
fileNames = fullfile(folder_path, {dirOutput.name});
If a file does not have a .dcm extension, then dicomread() will not be able to read the file if you add the .dcm extension. You should leave out the code
ext = '.dcm';
for p = 1:file_num
fileNames(p) = strcat(fileNames(p),ext);
end
Note: you have
fileNames(:,[1, 2]) = []; % first 2 filenames don't have have an actual file so i clear the first 2 columns
which is not correct code because some files can sort before '.' and '..' . In the code above, the equivalent but more robust code is the one involving isdir
  댓글 수: 1
Olukayode Sonaike
Olukayode Sonaike 2017년 11월 1일
Thanks for responding. leaving out the code
if true
ext = '.dcm';
for p = 1:file_num
fileNames(p) = strcat(fileNames(p),ext);
end
end
gets rid of the errors.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 DICOM Format에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by