【问题标题】:How to read a lot of DICOM files with Matlab?如何用 Matlab 读取大量的 DICOM 文件?
【发布时间】:2012-06-14 14:59:29
【问题描述】:

我正在使用一个在循环中生成字符串集合的脚本:

'folder1/im1' 
'folder1/im2'
... 
'folder1/im3'

我将字符串分配给一个变量,当我尝试执行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

可能是什么错误?

【问题讨论】:

  • 路径是绝对的吗?如果不是,请检查相对于脚本位置的路径?
  • @Ansari 我测试过:绝对路径和相对路径...

标签: matlab image-processing dicom


【解决方案1】:

你现在已经明白了,不是吗。

根据你写的,你测试

img = dicomread('folder1/im1');

当你遇到问题时

img = dicomread(file);

您需要实际测试您遇到问题的线路。我会推荐:

在 test.m 的 img = dicomread(file) 行中设置一个断点。当你到达那条线时,你可以看到file 等于什么。还要执行whos file 以确保它属于char 类,而不是单元格数组或随机的东西。

如果您仍然需要帮助,请编辑您的原始帖子并显示您将这些字符串分配给 file 的代码,并告诉我们在命令提示符下键入 img = dicomread(file) 时会发生什么。

【讨论】:

  • img = dicomread(char(strcat(pwd(), '/', fileList(x)))); 你太棒了,我用char() 函数将class cell 转换为class char
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-04
  • 1970-01-01
  • 2015-09-02
  • 1970-01-01
  • 2013-10-19
相关资源
最近更新 更多