5

对于当前的项目,我必须使用矩阵中提供的信息并对其进行数学运算,并使用 ITK/VTK 函数来显示医疗信息/渲染。基本上我必须以(我猜)50/50 的方式同时使用 matlab 例程和 VTK/ITK。问题是,由于我必须同时使用这两种方法,我想提前决定使用哪种方法:

  1. 将 ITK 和 VTK 库导入 matlab: 为此,您必须首先构建自己的 VTK。然后,通过这个例子,整个想法是在 .mex 文件中编写您的 VTK 代码。这些是您可以在其中将 c 代码编程为 matlab 功能的文件。

  2. 在 ITK/VTK 环境中导入 matlab 函数:为此我会使用一种语言,可能是 python,来进行矩阵计算。我可以使用 Numpy。这是 Python 中的 matlab 类计算模块,将 vtk 数据转换为 numpy 数据,我可以使用 matplotlib 来制作绘图。

优点/缺点 ITK/VTK 在 matlab 中导入
+ 易于进行 matlab 计算和绘图
+ matlab 是处理矩阵的最强大工具之一
+ 以前使用过 matlab(主观)

- 必须安装 matlab
- 运行 matlab 会增加你的电脑的负担

在 ITK/VTK 环境中导入的优点 / 缺点 matlab
+ 无需安装 matlab
+ 对 PC 的压力较小,而且由于医疗数据集需要您的 PC 提供很多,这很好。
+ 在这种情况下已经设置了 ITK/VTK 环境(目前以这种方式使用,但从未使用 matlab/matrices .mat)

- 听说过很难以这种方式进行 matlab 计算的故事。有点乱。
- 较少的python经验(结合matlab 0)

所以...?结论
实际上,我正在寻找在这两种环境之一中工作的人,但由于我认为其中有这么几个人,所以我喜欢在做出最终选择之前听取建议。让它以我需要的方式工作将花费大量时间,因此尝试两者都是浪费时间(也有截止日期)。

额外说明
- 我已经尝试将 Simulink for matlab 与 VTK/ITK 库结合使用,但我不喜欢它。
- 虽然问题的解决方案当然是我能在这里得到的最好的解决方案,但我也很高兴人们在做出与这个基本相同的选择方面有经验。做出这样的选择时要寻找哪些关键点?我是否错过了我的利弊中的一个关键点?

4

5 回答 5

2

VTK comes with Python bindings (one description). I'm assuming ITK does too. If you don't already have a lot of code in Matlab, I'm guessing you'd have a much easier time seamlessly integrating VTK/ITK with python's numpy, matplotlib, etc.

EDIT:

In my opinion, non-trivial MEX functions are a pain to write. The tradeoff can often be writing new MEX functions for each task or taking extra time to write a lot of interfacing code.

Depending on what you're doing, scipy (a bundle of python packages including matplotlib, numpy, etc.) does a lot of what Matlab does. There are subtle differences and various tradeoffs. Automatic broadcasting is so incredibly useful, once you get the hang of it. MathWorks has recently added BSXFUN, but it's automatic with numpy. If you're doing a lot of work with sparse matrices or calling a lot of the more advanced linear algebra functions, check the numpy docs to see if what you need exists yet.

Depending on what you've done with your environment so far, I'd suggest trying out the Python approach for a few weeks. See if its plotting capabilities and math functions are sufficient for your needs. Expect to bang your head against the wall a little in the beginning because the documentation isn't as mature as Matlab's.

于 2009-05-28T01:40:18.773 回答
2

这可能会有所帮助:mlabwrap 是一种从 Python 调用 Matlab 的相当复杂的方法。http://mlabwrap.sourceforge.net/

于 2009-08-20T00:22:45.137 回答
1

我花了一些时间来测试两个版本,但在这个问题上得出结论:

我选择将 python 与 numpy/scipy 和 matplotlib 结合使用。我选择使用它的主要原因只有一个。当您在 Matlab 中导入 itk 和 vtk 时,您必须使用 Mex 函数来编写您的 C 代码。这些 mex 文件以下列方式在例程中:

替代文字 http://www.bastijn.nl/zooi/routine.png

现在,当例程到达 mex 文件所在的位置时,它会将控制权交给这个 mex 文件并像函数一样触发它,mex 文件就像一个黑盒子。在 Mex 文件完成它的工作后,它会将控制权交还给 matlab,然后程序继续。但是,在触发 Mex 文件或从 matlab 访问此 mexfile 中的变量时,您不能执行任何 matlab 操作。因此,不可能运行一些 itk/vtk 代码,请注意它不起作用并更改 mex 文件中使用的一些变量(在那里创建,但它们也会死在那里,因为黑盒只返回你的结果)速度测试什么是有效的。您必须再次触发整个 mex 功能。

这是一个主要缺点,因为您需要重新运行完整的 mex 文件(C 函数)以进行所有小改动。正在忙着修复这个主要的限制,但由于它们还没有准备好,我现在确实需要它,所以我选择了 python 之旅。

于 2009-06-10T07:45:15.873 回答
1

有点旧的帖子,但我只想提一下 matVTK(http://www.cir.meduniwien.ac.at/matvtk/)。这使您可以在 Matlab 中进行所有计算,然后使用 vtk 库绘制数据。

于 2011-02-27T11:24:10.980 回答
1

Bastjin,您做出了正确的选择:Python 规则!

更多信息:

对于选项 1,我写了这个:http: //github.com/thewtex/matlab-itk-import 但是,正如你提到的,它是次等的选项。

以下是选项 2 的一些链接: Mayavi2 的 mlab 具有很好的在 VTK 和 numpy 之间切换的能力。

WrapITK 允许您在 Python 中编写 ITK 管道,并且您可以使用 Numpy 与在那里找到的 PyBuffer 外部项目来回切换。

于 2010-03-10T15:36:27.723 回答