Assignment 4: Registration (Optional)
Methods In Medical Image Analysis (BioE 2630 : 18-791 : 42-735) - Spring 2016
20 points total
Due Date: Your final submission must be committed to svn by 10 AM EST on Thursday Morning, April 14. Big problems may not show up until the end, so finish early!
E-mail your TA or instructor with questions or problems.
This assignment is optional, but it is not a "bonus" assignment. If you choose to submit a registration hw solution to svn by the due date, then your homework score will be based on one more assignment. If you decide that this hurt your grade, then it's up to you to ask us to not count this homework in your final grade.
- 2D Registration using Mean-Squared Distance
- 2D Registration using Mutual Information
1 SVN setup for this assignment &
dataset acquisition (0 points, apx. 3 minutes)
Following our pattern from the segmentation homework, create a directorystructure in your SVN module to contain this assignment. You must first create the directories locally, then tell SVN to add them to your module, and then commit your changes to the SVN server:
cd c:\MIIA\{Your_SVN_User_Name}
mkdir hw-reg
mkdir hw-reg\Part1
mkdir hw-reg\Part2
svn add hw-reg
svn ci hw-reg -m "Setting up module for hw-reg"
Now, download the
image data set you will be using for this assignment, and unzip the archive
into your hw-reg folder.
For both Part1 and Part2, we will be using SimpleITK's 'ImageRegistrationMethod' function. We will be using two different metrics, to guide the registrations process. From the lectures, you'd remember that image registration involves moving one image with respect to a fixed image. To determine whether the movement of the image makes sense, whether it is indeed proceeding in the right direction and to quantify the performance of algorithm, we use metrics such as (i) Mean Squared distance - Part1 and (ii) Mutual Information - Part2.
- Download registration_MSQ.py into your Part1 folder
- Read the code and try to build an intuition of what's happening. If you're unclear, please refer to the image registration lecture slides.
- Similar to your segmentation assignment's code, change registration_MSQ.py such that you get input command-line arguments from the user for:
- Input fixed image
- Input moving image (the image we will register onto the fixed image)
- Path to save the registered image (relative paths will be based on the directory from which ipython was launched)
- Add some basic error handling, such that if the user enter less than 3 arguments, the program exits (again, take a look at hw3's python code if necessary)
- Add your modified code to your svn repository:
- svn add hw-reg\Part1\registraion_MSQ.py
- svn ci hw-reg\Part1 -m "MSQ: Added input arguments and error handling"
- Read the documentation for ImageRegistrationMethod and figure out the parameters for SetOptimizerAsRegularStepGradientDescent(). The given code has 3 internal parameters for gradient descent: (i) Max step, (ii) Min step, and (iii) Maximum number of iterations. Hint: SimpleITK's Doxygen has links to the underlying ITK classes. Since you need to learn more about this optimizer, pay attention to the underlying ITK optimizer, as well as the ITK optimizer's parent class. So, once you get to the ITK Doxygen for SetOptimizerAsGradientDescentLineSearch, then click on the SuperClass link to get to GradientDescentOptimizerv4Template, where you can read about the parameters.
- Try changing the following, and then summarize your observations in a comment at the top of your code:
- Max step between 0 to 10 (in steps of 0.5)
- Min step between 0.00001 to 0.5 (in whatever steps you prefer)
- Maximum number of iterations (10 to 200)
- What happens when min step is < 0.001 and max iterations is 10? Will it lead to an optimal solution? What are the tradeoffs when we set the max iteration count?
- Continue to experiment with parameters if you desire, and then save the best image you produced as registration_MSG.png. Include another comment at the top of your code to explain how you arrived at the parameters to obtain this result.
- Commit your result image and your modified code to your svn repository:
- svn add hw-reg\Part1\registration_MSG.png
- svn ci hw-reg\Part1 -m "MSQ: Final Parameters"
2. 2D Registration using Mutual Information (12 points)
- Download registration_MI.py into your Part2 folder
- Read the code and try to build an intuition of what's happening. If you're unclear, please refer to the image registration lecture slides.
- Similar to Part 1, change registration_MI.py such that you get input command-line arguments from the user for:
- Input fixed image
- Input moving image (the image we will register onto the fixed image)
- Path to save the registered image (relative paths will be based on the directory from which ipython was launched)
- Add some basic error handling, such that if the user enter less than 3 arguments, the program exits
- Add your modified code to your svn repository:
- svn add hw-reg\Part2\registration_MI.py
- svn ci hw-reg\Part2 -m "MI: Added input arguments and error handling"
- Read the documentation for ImageRegistrationMethod and figure out the parameters for SetOptimizerAsGradientDescentLineSearch(). The given code has 4 internal parameters for gradient-descent line search: (i) LearningRate, (ii) NumberOfIterations, (iii) ConvergenceMinimumValue, and (iv) ConvergenceWindowSize
- Try changing the following, and then summarize your observations in a comment at the top of your code:
- Learning rate - How does this parameter influence registration?
- ConvergenceMinimumValue between 1e-10 to 0.5
- ConvergenceWindowSize - How does this parameter influence registration?
- Continue to experiment with parameters if you desire, and then save the best image you produced as registration_MI.png. Include another comment at the top of your code to explain how you arrived at the parameters to obtain this result.
- Commit your result image and your modified code to your svn repository:
- svn add hw-reg\Part2\registration_MI.png
- svn ci hw-reg\Part2 -m "MI: Gradient-Descent Line-Search Parameters"
- Comment out (or remove) the normalization step of fixed and moving images (e.g: comment out fixed = sitk.Normalize(fixed)). How is the registration process affected? Do you think this step is necessary or not? Explain why. Include all your answers in another comment at the top of your MI code.
- Comment out (or remove) the Gaussian blurring step of fixed and moving images (e.g: comment out fixed = sitk.DiscreteGaussian(fixed, 2.0)). How is the registration process affected? Do you think this step is necessary or not? Explain why. Include all your answers in another comment at the top of your MI code.
- Try to intuitively describe why normalization and Gaussian blur come into picture when using Mutual information as a metric and not necessarily in Mean Squared Distance (Part1). Include your answer in another comment at the top of your MI code.
- Commit your final code to your svn repository:
- svn ci hw-reg\Part2 -m "MI: Final code, comments, and answers"
Finally, be sure all of your files are committed correctly, either by pointing your web browser to your svn URL and logging in with your svn name and password, or else by using the command "svn list -R --verbose --username {Your_SVN_User_Name} https://svn.vialab.org/svn/miia16/hw-reg/{Your_SVN_User_Name}". If these methods do not show all your submitted files present and with appropriate timestamps, then you have not properly committed them. In this case, the first thing to check is to make sure you've added the files to svn before comitting. Otherwise, email your TA and instructor for help.