Simple Installation of Simple ITK

Do you know what it feels after 4 years of vacuum in academic research and you have to catch up quickly with your research? It seems like.. OMG, my brain has frozen… I am too old, last 5 years I did not use Ubuntu, I didn’t use Python, I even forget what are those ‘magical scientific words’ they talking about? O__O . I almost lost my grip and surrender… But, no, life must go on. So I just follow the instructions from my supervisors, saying I must do this, do that, learn this, read that, etc. Let’s begin!

First of all, at the moment I am just an empty sheet. I am not exposed to any programming language or framework. Then, for a quick start I prefer to user Python and Simple ITK for medical image analysis purpose. Follow me Step-by-step tutorial to set up environment and install tools you might need in medical imaging.

VM Ware

If you use Windows (like me) you better get a new VM Ware workstation to run a new virtual machine on Ubuntu (version 12 above should be fine). Ubuntu already comes with Python in it, so you just open the terminal and type “python”.

However, it is not so intuitive if you type and compile like that. I think using IDLE (the default Python IDE) is still too hard for me, then I chose a more handy IDE for Python, which is Spyder – a MATLAB-like Python IDE. Before installing Spyder and Simple ITK, it is advised to install ImageJ first since Simple ITK will use it for invoking the ‘sitk.Show’ comman. I was one installed Simple ITK first followed by ImageJ without having all of the complete plugin but I found trouble!

ImageJ

Simply run this line on your terminal

sudo apt – get install imagej

However, this version does not come with Nifti plugin which make me failed to load any image. Therefore, you must download Nifti plugin from here (http://rsb.info.nih.gov/ij/plugins/nifti.html) and don’t forget the handling for extra file type (http://rsb.info.nih.gov/ij/plugins/file-handler.html).

If you download those items in Download folder then you have to move them inside the Plugins folder of ImageJ.

sudo mv nifti_io.jar  [your path for ImageJ plugins folder]

You should re-open imagej and you also should now see five new commands in imagej/fiji:

  • File/Import/NIfTI-Analyze,
  • File/Save As/Analyze (NIfTI-1),
  • File/Save As/NIfTI-1

If you’re done with ImageJ then you can proceed to the next step.

Spyder

My choice of IDE simply because it looks like MATLAB and more intuitive. Well, if you install it you mostly get what you needed. Just run the following command line:

sudo apt – get install spyder

Useful packages

Some packages that can be useful for computer vision and medical imaging can be installed as well:

sudo apt – get install ipython – notebook ipython – qtconsole python – opencv

As we know, it is better to have ipython (interactive python) for Simple ITK because it is just safer then just using Python alone.

Simple ITK

Simple ITK is the new simplified/abstraction for ITK. Instead of writing more lines in ITK, you could have a nice and simple command in Simple ITK. Check out their tutorial here (https://github.com/dblezek/SimpleITK-MICCAI-2011-Tutorial).

Install it using this command:

sudo easy_install SimpleItk

By then, you can check in your Spyder whether your Simple ITK is working or not? Type in your Spyder editor:

import SimpleITK as sitk
image = sitk.ReadImage(“filename”)
sitk.Show(image)

Your image should appear in ImageJ. Make sure you install nifti first in ImageJ plugins, if not then it says cannot open Tmp/.nii something.

 

Scikit-learn

If you user machine learning then it is good to get nice toolbox, examples, and tutorial (in Python) from here (http://scikit-learn.org/).

Requirements:

sudo apt-get install build-essential python-dev python-setuptools python-numpy python-scipy libatlas-dev libatlas3gf-base

Installing scikit in Ubuntu (you must first have the easy install first).

sudo easy_install scikit-learn

ensure the Python path.

export PYTHONPATH=$PYTHONPATH:${HOME}/lib/python2.7/site-package

You may see the term ‘UMD has deleted’ in you Spyder console. Then, you have to add the path in “Python Path Manager” inside Spyder. Add /usr/local/lib/python2.7/site-packages , where the modules of scikit-learn installed.

Voila!🙂

I hope now I can continue proceed to the next stage, which is a small-baby-step tutorial on how to use Simple ITK and Scikit :p