File Exchange

image thumbnail

3D Free Form Image Registration Toolbox (GUI)

version (272 KB) by Daniel Markel
A toolbox for performing image registrations on 4D RTOG files or any other volumetric image.


Updated 10 Feb 2012

View Version History

View License

This toolbox contains all the functions necessary for extraction and registration of medical RTOG images using a cubic-B-spline free form deformation technique. The optimization routine uses a difference of squares along with smoothness and feature point designations as error criteria to minimize. Some code has been taken from CERR.

A GUI (FFD4D) is included for handling all the steps from extraction of data and contours to registration and deformation of the image.

The GUI requires contours be loaded of the organs being deformed in order to register them. If contours are not available a very rough automated segmentation routine is provided to outline skin and bone structures. These contours are what is used by the registration routine and are necessary, the original images are not, but can be deformed using the registration parameters after.

It is recommended that images be cropped identically (no larger than [400x400x100 pixels] and are globally registered before hand. A typical registration takes approx. 160 minutes to perform.

DICOM images can also be used, however there may still be many bugs associated with using DICOM.

I will add proper documentation soon. I apologize for now.

Please ensure the folder hierarchy is preserved when extracting these files.

Please let me know if you experience any problems. Don't forget to extract the zip file with the folder hierarchy intact or the gui will not function correctly.

This software should not be used clinically or commercially and is for research purposes only. Use at your own risk.


Cite As

Daniel Markel (2021). 3D Free Form Image Registration Toolbox (GUI) (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (22)

Shrimanti Ghosh

And where can I get the dataset?

Shrimanti Ghosh

Hi Daniel,
I wanted to know how can I run the program? I couldn't find the readme document. I saw the example2.m
Is this the file that I should run to see the result?

Jason Lee

Really nice code !!!
But I really want to know why 3D image data should be no larger than 400x400x100? For efficiency or accuracy or both? Or the procedure may go wrong if large than that ?
Sorry to waste your time. I'm still learning the code to fully understand this toolbox. Looking forward to replies. Thanks !

Daniel Markel

Hi Justin,

This program only handles non-rigid registration unfortunately. However it's very easy to get the transformation you need. Matlab now has a number of options for rigid (and even non-rigid) registration that make it very simple. You might be better served to try those.


Great software!

I was wondering if there is any way to get the transformation matrix?

I want to register treatment CT to the simulation CT and use this registration to apply couch shifts to a phantom.

It will be a rigid registration so I really just need the rotational and translational components.

Any ideas?



PS: particularly if I use feature points for the registration

keen chan

Nicolas Yu

No mannual. And the directories are better to be relative directories.


Thanks for the code,
How is it possible to test the software for 3D Mesh model?

Thanks again


amin moham

thanks for toolbox
can i use your functions for 2d image registration(motion maping in video)?

Eman Alsayyad

can i use this free form deformation code to deform a human body template model to an individual human by having 2 contour images one for the template and the other for the target if yes ,which files or functions can i use if no ,have you any background about how i can do that?
please reply as soon as possible it is an important issue thank you

yang ping

Can you offer more informations about CERR?
Thank you very much.

Daniel Markel

Sorry the first part of the comment was cut off.

The label can be anything you want, it's just what the program will call the data set after you load it in. All I recommend is not using the words 'temp' or 'deform' in the title.

Put the data files into any folder on your computer, you'll be able asked to select it once you're adding an image dataset. I wouldn't mess around with the 'patient files' folder. the program will manage it on it's own.

I should add, there's a bit of an order to using the GUI, I apologize there's no manual yet.

1. 'create new patient' or load an exisiting one first.
2. Now you can add images to you're patients file it's expected that they are 3D volumes and all images pertaining to it are in the same folder.
3. Once the data is in the program you can select it in the list and click 'View data' to see it or you can select 'load contours' to load in any ROI's that accompanied the data set, they should also be in the dicom or RTOG files (this is optional).
4. Click 'Feature points' to mark any fudicials between data sets. The points are colour coded on the screen to correspond to the first or second image. The fade slider goes from 'image1 ---> image2'. (This is also optional)
5. In the pull down menu in the main program you can select 'Registration Parameters' to change the optimization parameters to get a better or faster registration.
5. Click register points to set up a single or series or registrations. If there are no contours you can select 'auto segment' in the registration menu to have the program use thresholding to segment the images. Once you're ready hit 'Register' and leave the program until it's finished, this may take a while.
6. Once done, the registration parameters will appear in the 'Deform' menu (purple button). You select the data set you're applying the transformation to on the left and the transformation on the right. Hit 'Apply deformation' to produce a data set of the deformed volume (remember you can only output in dicom for now). 'Load dose' to load a dose volume to accompany the data set. Or 'Calculate DVH' to apply the transformation to a dose set and produce an excel file with the DVH data.

Daniel Markel

P.S. or if you're loading an RTOG you would select the header file within that folder.



Xi Liang

I cannot download database from the address, and they are just 14K and unable to unzip. Instead, I downloaded a dataset from

I put the files under the directory /patient files, but the this doesnt work. Should I rename the files?

Vahid T.

Thanks for uploading the database.
One more problem:
After loading the header file ( 0%0000 ), the software asks for a lable.
What should we insert as 'lable'?

Daniel Markel

Sorry for the delay, that's not a bad idea. Here's an RTOG of a phantom, you have to unzip it first, first file 0%0000 is the header. I have gotten rid of almost all the bugs now, I'll try to upload the fixed version tommorrow.

Vahid T.

Can you please upload the input images in rapidshare or mega-upload or....
It is really useful.

vijay kumar

Is 'uint6' used in loadDICOM2.m on line 42 a valid data type? There are several other bugs.

Daniel Markel

I do, but RTOG image sets are fairly large about 80 megabytes each which is why I did not include them here. You'd need atleast two sets, to test the software.

Greg Thom

Do you have test data for this software ?

MATLAB Release Compatibility
Created with R14SP3
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!