Assignment 3: SimpleITK Registration - Notebooks
Methods In Medical Image Analysis (BioE 2630 : 16-725) - Spring 2020

Creative Commons License SimpleITK Notebooks 1 assignment by John Galeotti, © 2020 Carnegie Mellon University, is licensed under a Creative Commons Attribution 3.0 Unported License. Permissions beyond the scope of this license may be available by sending email to itk (The SimpleITK Notebooks referenced are separately © by their own authors, etc..)

John Galeotti
Usually meets with students after class


16 points total

Due Date:  Finish adding and commiting your submission to svn by 5pm on Tuesday night, February 25th.

Create a submission directory inside your svn repository, to hold everything you submit for this homework:

cd c:\MIMIA\{Your_SVN_User_Name}
mkdir hw_Reg_nb
svn add hw_Reg_nb
svn ci hw_Reg_nb -m "Setting up module for hw_Reg_nb"

(Windows users can install the free and open source PDFCreator to print to pdf. Macs can natively print to pdf files. Linux can natively print to either ps or pdf, and ps can easily be converted to pdf using ps2pdf or pstopdf from the command line.)

Prep (0 points)

You should have previously downloaded a set of SimpleITK notebooks by using git as instructed in assignment 2.4. In this assignment, we will copy some of these notebooks (the "6" series for registration) to a new directory so we can modify them. We will also copy some images and helper functions. You should now open a command prompt, and begin as follows (adjust directory names and forward/backward slashes as necessary for your computer):

cd \mimia\
mkdir Data
mkdir hw_Reg_nb
mkdir hw_Reg_nb\Output
cp SimpleITK-Notebooks\Data\* .\Data
cp SimpleITK-Notebooks\SharedImages\* .\hw_Reg_nb
cp SimpleITK-Notebooks\Python\*.jpg .\hw_Reg_nb
cp SimpleITK-Notebooks\Python\*.svg .\hw_Reg_nb
cp SimpleITK-Notebooks\Python\*.py .\hw_Reg_nb
cp SimpleITK-Notebooks\Utilities\*.py .\hw_Reg_nb
cp SimpleITK-Notebooks\Python\6*.ipynb .\hw_Reg_nb
cd hw_Reg_nb

Finally you can launch a web-based python interface called Jupyter. You should do so from the command line, making sure you are already in the hw_Reg_nb directory (like we just did above):


Problem 1  (8 points)

After you launch the Jupyter notebook's web interface, in the Jupyter web page find and click on the notebook named 60_Registration_Introduction.ipynb.

If you are not familiar with Jupyter notebook, it is an interactive Python environment. It divides your Python code into different cells and runs each cell separately. Such structure offers great flexibility for editing code. For example, when you want to add a cell, you can first click Insert at top and choose to add above or below a selected cell. If you prefer keyboard shortcut, try press a or b and see what happens.

Execute the code blocks one at a time, making sure there aren't any errors. As you proceed, follow the instructions below for certain blocks of code. WARNING: When a code block changes from showing a number to showing an asterisk, such as "In [*]," it means the block is still executing, and you should wait before going on to the next block. When a block is finished, it will change to show the order in which the block was executed, e.g. "In [7]."

Block [3] Read Images: After running this block, the two images should be visible. Adjust the slize from the fixed image (CT) to see the optic nerve and eyeballs. Likewise, also asjust the slice from the moving image (T1 MRI) to also see the optic nerve and eyeballs. (These slice selections are purly for visualization, and do not affect the following code.)

Block [4] Initial Alighment: After running this block, observe the initial mismatch. Try setting image_z to slice 7. adjust the alpha (transparency) back and forth, then choose a value between 0.3-0.7.

Block [5] Registration: After running this block, observe how much the error increases each time a new layer of the pyramid begins. Now try inserting a new cell in the notebook after the registration error-metric graph (use the "Insert" menu), and change the cell time to "Markdown" using the toolbar (look for the drop-down box to the right of the run and stop buttons, which probably currently says "Code"). Inside the new cell, write your own explanation of (1 or more reasons) why you think the error metric increases when the registration pyramid changes to lower scale. Remember, at large scale only large objects are visible, so lower scale is higher resolution located closer to the "bottom" of the image pyramid.

Block [6 & 7] Post Registration Analysis: After running this block, observe the alignment (in contrast to block 5, above). Try setting image_z to slice 7 again, and then adjust the alpha (transparency) back and forth. Set alpha to 0.8 when done (so we see the image we want to grade).

When finished, "print"/save the entire completed notebook as a pdf file named part1.pdf. Please make sure that the entire notebook, including all code, is visible in the pdf (long warning messages don't matter). You may need to tell your webbrowser to print the notebook at a reduced scale, e.g. 70%, to fit everything. Add and commit to svn.

Problem 2  (8 points)

Go back to the "Home Page" tab of your webbrowser to choose a new notebook. Open and work through all of 61_Registration_Introduction_Continued.ipynb. After running block[3], be sure to change the moving image to be diffrent than the fixed image; I suggest the 3rd choice for the moving image.

After finishing the ITKv4-style multi-transform registration, insert a "Markdown" box after the code block "print(final_transform_v11)" (e.g., after block[12]) but before "Version 2" in which you type your answers to the notebooks's questions (what type of transform and why different?).

After completing this notebook, "print"/save the entire notebook as a pdf file named part2.pdf. Add and commit to svn.