[英]How to read a lot of DICOM files with Matlab?
我正在使用一個腳本,該腳本在循環中生成字符串集合:
'folder1/im1'
'folder1/im2'
...
'folder1/im3'
當我嘗試執行img = dicomread(file);
時,我將字符串分配給變量img = dicomread(file);
功能我得到以下錯誤:
Error using dicomread>newDicomread (line 164)
The first input argument must be a filename or DICOM info struct.
Error in dicomread (line 80)
[X, map, alpha, overlays] = newDicomread(msgname, frames);
Error in time (line 14)
img = dicomread(file);
但是,使用命令行我不會出錯: img = dicomread('folder1/im1')
。
代碼如下:
for i=1:6 %six cases
nameDir = strcat('folder', int2str(i));
dirData = dir(nameDir);
dirIndex = [dirData.isdir];
fileList = {dirData(~dirIndex).name}; % list of files for each directory
n = size(fileList);
cd(nameDir);
for x = 1:n(2)
img = dicomread(strcat(pwd(), '/', fileList(x)));
end
cd('..');
end
可能是什么錯誤?
您現在已經知道了,不是嗎。
根據您編寫的內容進行測試
img = dicomread('folder1/im1');
當你遇到麻煩的時候
img = dicomread(file);
您需要實際測試遇到問題的線路。 我建議:
在
img = dicomread(file)
行中在test.ma中放置一個斷點。 當您到達那一行時,您可以看到什么file
等於。 還要執行whos file
,以確保它屬於char
類,而不是單元格數組或隨機類。
如果仍然需要幫助,請編輯原始文章,並在代碼中顯示將這些字符串分配給file
並告訴我們在命令提示符下鍵入img = dicomread(file)
時會發生什么。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.