如何用Matlab阅读很多DICOM文件? [英] How to read a lot of DICOM files with Matlab?

查看:1519
本文介绍了如何用Matlab阅读很多DICOM文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am using a script which generate a collection of strings in a loop:

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

我将字符串赋值给变量,当我尝试执行 img = dicomread(file); 函数时,我收到以下错误:

I assign the string to a variable, when I try to execute the img = dicomread(file); function I get the following error:

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')

However, using the command line I don't get errors: 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

可能是什么错误?

推荐答案

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

You've figured it out by now, haven't you.

根据你所做的事情写的,你测试

Based on what you've written, you test

img = dicomread('folder1/im1');

当您遇到问题时

img = dicomread(file);

您需要实际测试遇到问题的线路。我建议:

You need to actually test the line you are having trouble with. I would recommend:


在test.ma中设置一个断点 img = dicomread(file)。当你到达那一行时,你可以看到文件等于。另外做 whos文件以确保它是类 char 而不是单元格数组或随机的东西。

putting a break point in test.m a the line img = dicomread(file). When you get to that line you can see what file is equal to. Also do whos file to make sure it is of class char and not a cell array or something random.

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

If you still want help, edit your original post and show the code where you assign those strings to file and tell us what happens when you type img = dicomread(file) at the command prompt.

这篇关于如何用Matlab阅读很多DICOM文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆