First CT Meeting 2010

Conferences No Comments »

In the field of image reconstruction there are numerous conferences dealing with CT and nuclear medicine. However, yet there is no true conference solely for CT reconstruction.

Thus I am glad to hear that a new conference is going to take place this year for the first time in Utah, June 6-9, 2010:  The First International Meeting on Image Formationin X-Ray Computed Tomography.

Discrete random element selection based on a user-specified probability

Matlab, Programming, Statistics No Comments »

Yesterday, an algorithmic idea came into my mind which required a specific component:

  • Given: Set of discrete delements E(i). Likelihood P(i) for the occurence of an element E(i).
  • Goal: A function which returns a random element from E based on the distribution described by P.

What is this useful for? Well, I wanted to implement some kind of stochastic gradient descent algorithm for image registration without gradients but given a certain likelihood for a point to increase the cost function value. However, I think this kind of function comes in handy for many situations.

Matlab Code & Example

I wrote a Matlab function randelement() which solves exactly the problem. It is based on the theory of inverse transform sampling. The link to the download is given below. It is well-documented, that’s why I will only provide a little usage example:

  1. %  select some arbitrary discrete points
  2. E = [-2 0 2 4 6];
  3.  
  4. % select likelihoods for each point
  5. P = [1 0.5 2 0.1 0.5];
  6.  
  7. % get a long vector with elements from P
  8. % distributed according to P
  9. R=randelement(E, [100000 1], P);
  10.  
  11. % verify by looking at the histogram

The histogram will then look somehow similar to this:

histogram

So … this function seems to do what we wanted - I like it!
The latest version of randelement.m can be downloaded here.

Matlab / C++ Communication

C++, Libraries, Matlab No Comments »

Often one is required to write medical image processing code in C++ for reasons of speed and programming libraries. However, what is missing during the development are nice and interactive calculation, plotting and visualization tools. However, on the contrary these are provided by Matlab. So all we need is an easy link for communicating between Matlab and your C++ program.

An overview of the available methods is provided in the Matlab external interfaces guide. Today I want to provide you with a link to my favorite method for windows C++ programs. It is called MatlabEngine and can be downloaded at CodeProject.

Storing 3-D data in a portable single file DICOM volume format

DICOM, Matlab, Programming No Comments »

Handling of DICOM data is a mandataory but  tricky task in medical image processing. This is especially true when it comes to volumetric 3-D data. The most common and supported format for storing 3-D data using DICOM is to partition the volume into slices and to save each slice as a simple DICOM image. The slices can be distinguished either by a number coding (e.g. slice.001, slice.002,…) in the file name or by specific DICOM tags.

However, this format easily becomes a pain as it requires to store hundreds of single files. The goal of this article is to provide a solution for that problem but still to remain a large compatibility with existing software. The solution: just zip it up! I agree, this sounds simple but provides all the required functionality. It is a single file, zip-files are highly portable and are available on almost all platforms, plus we get a nice compression for free.

Of course we won’t zip our data by hand! In this article I will provide a Matlab routine which allows to store and read volume data using the above technique.  In an upcoming article I will provide C/C++ code, too.  Here we go: The two functions are called dicomreadvolume() and dicomwritevolume(). They require you to have the Matlab image processing toolbox installed. An example session for storing and reading the 3-D Shepp-Logan phantom with an anisotropic voxel size of [0.25mm 0.25mm 0.5mm] could look like this:

  1. % create phantom data
  2. V = phantom3d(128);
  3. V = uint8(255.*V); % convert to uint8
  4.  
  5. % save the dicom volume
  6. dicomwritevolume(shepplogan.zip‘, V, [0.25 0.25 0.5]);
  7.  
  8. % read in the dicom volume again
  9. [V2 VS] = dicomreadvolume(shepplogan.zip);
  10.  
  11. % V2 contains the volume
  12. % VS contains the voxel size

 
I hope this code helps some of you out. It comes in handy for me in an every day usage :-). In an upcoming article I will provide you with some equivalent C++ code. So look out for more!

An up-to-date download is available at MATLAB Central.

Helper functions for reading/writing binary data in Matlab

Matlab, Programming No Comments »

A common task in image processing is reading and writing binary data to files. On the Matlab command line it comes in handy to have a set of helper functions that save one from typing duplicate code over and over again, i.e. the fopen(), fwrite()/fread() and fclose() stuff.

I have created two functions writebinary() and readbinary() for that purpose. A primitive session where we save and load the 2-D Shepp-Logan phantom could look like this:

  1. I = phantom(200) .* 256; % create the phantom
  2. writebinary(img.raw‘, I, ‘uint8); % save it as char
  3. J = readbinary(img.raw‘, [200 200], ‘uint8=>double); % read it in again and cast to double

Its not a big deal - but useful!

The latest version can be downloaded at MATLAB Central.

Matlab 3-D Shepp-Logan Phantom

Matlab, Programming 2 Comments »

The Shepp-Logan phantom is often used in 2-D and 3-D reconstruction literature to present the quality of reconstruction algorithms. In Matlab the 2-D version of the phantom can be used as follows for creating a 200 x 200 image:

  1. I = phantom(200);
  2. figure, imshow(I,[]);

results into the following image:

Matlab 2-D Shepp-Logan Phantom

Matlab 2-D Shepp-Logan Phantom

Read the rest of this entry »

Design by j david macor.com.Original WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in