views:

1487

answers:

4

For a current project I have to use and do mathemetics on information provided in matrices as well as use ITK/VTK functions for displaying medical information / renders. Basically I have to use both matlab routines and VTK/ITK in a (I guess) 50/50 way. The problem is that, since I have to use both, I want to decide in advance which method to use:

  1. Import ITK and VTK libs into matlab: for this you have to build your own VTK as a start. Then, by this example the whole idea is to write your VTK-code in .mex files. These are files in which you can program c-code as a function of matlab.

  2. Import matlab functions in ITK/VTK environment: for this I would use a language, probably python, to do matrix calculations. I could make use of Numpy. This is a matlab-kind-of calculation module in Python and convert vtk data to numpy data and I can make use of matplotlib to make plots.

Pros / cons ITK/VTK imported in matlab
+ easy to do matlab calculations and plotting
+ matlab is one of most powerfull tools for working with matrices
+ have used matlab before (subjective)

- Have to have matlab installed
- running matlab burdens your pc

Pros / cons matlab imported in ITK/VTK environment
+ no need to have matlab installed
+ less of a strain for PC, and since medical datasets require alot from your pc this is nice.
+ ITK/VTK environment already set up in this case (currently using it this way, but never with matlab/matrices .mat)

- have heard stories it is hard to do matlab calculations in this way. Bit messy.
- less experience in python (in combination with matlab 0)

So...? concluding
Actually I am looking for people who have been working in one of the two environments but since I think there are such a few of them I love to hear suggestions what to look for before making the final choice. It will cost a lot of time to get it working in a way I need it so it would be a waste of time to try both (also have a deadline).

extra notes
- I have tried Simulink for matlab in combination with VTK/ITK libs but I do not like it.
- Although a solution to the problem is ofcourse the best I can get here I am also happy with people having experience in making choices which are in base the same as this one. What are keypoints to look for when making such a choice? Am I missing a keypoint in my pros and cons?

+2  A: 

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.

Mr Fooz
I already have a working environment where I have python program modules as well as ITK/VTK imported. The problem for me was in the last guess you make, is it really easier and why.
bastijn
A: 
bastijn
+2  A: 

This might help: mlabwrap is a fairly sophisticated way to call Matlab form Python. http://mlabwrap.sourceforge.net/

Wow, thanks for the late reply :). This looks promising.
bastijn
A: 

Bastjin, you made the right choice: Python rules!

Some more information:

For option number 1, I wrote this: http://github.com/thewtex/matlab-itk-import But, As you mention, it is the inferior option.

Here are some links for option number 2: Mayavi2's mlab's has a nice ability to switch between VTK and numpy.

WrapITK allows you to write ITK pipelines in Python, and you can go back and forth with Numpy with the PyBuffer external project found there.

thewtex