Registration and Segmentation GUI and Code Guide Ahmad Humayun Nasir Rajpoot

advertisement
Registration and Segmentation
Molecular Pattern Analysis of Colon Cells
GUI and Code Guide
Ahmad Humayun
ahmad.humyn@gmail.com
Advisor:
Nasir Rajpoot
nasir@dcs.warwick.ac.uk
March 11, 2011
Warwick University
Molecular Pattern Analysis of Colon Cells
If you are copying code from this document, make sure you replace any missing under-scores and
remove any errant spaces.
All the scripts (including the GUI) were tested extensively on a Microsoft Windowsr 7 using Mathworks
MATLABr R2009b (ver: 7.9.0.529). Testing was done on both 32bit and 64bit flavors of Windowsr and
MATLABr .
1
System Requirements
There are no particular hardware requirements to run the Registration and Segmentation GUIs, except those posed by
the required programs below.
All the scripts and GUIs run on MATLABr . There are some toolboxes you would specifically need for running the given
programs:
1. Image Processing Toolbox is the basic toolbox requirement for running the system. It is extensively used
throughout the scripts and GUI.
2. Genetic Algorithm and Direct Search Toolbox is required for some registration techniques during optimization
(e.g. RegistrationMI). If you are using MATLABr R2010a (onwards) you would need Global Optimization
Toolbox in place of this toolbox.
2
Registration GUI
The main purpose of the registration GUI is to take a directory of images as input, and perform registration in a way
that makes it possible to transform any image in this directory to any other image’s frame of reference. The basic
layout and functionality of the Registration GUI is given in Figure 1. The GUI is easily extendable to new registration
methods.
9
(1) Specify the directory containing the
images you want to register.
(2) Analyze the directory for any errors.
(3) Specify the registration algorithm to
use. Also give the anti-body whose IP
image will be used as the reference image.
(4) Set the options for the registration technique selected. This space will
have different options with different algorithms.
(5) REGISTER all the images in the
directory with the set options.
(6) Log messages displayed during the
operation of the GUI.
(7) For writing registered images to disk.
(8) Used for fixing registrations (previously performed).
HH
Y
(9) Used for viewing/analyzing registration results.
H
Y
H
H
Figure 1: Registration GUI explained
2
Molecular Pattern Analysis of Colon Cells
Warwick University
The following steps need to be followed to perform registration with the GUI:
1. Start MATLABr and browse into a directory from where the registration GUI is easily accessible. For instance we
can cd into the root directory of the code provided. This is certainly not a requirement as long as you can add
the Registration/registration gui directory to the MATLAB path:
Listing 1: Starting Registration GUI
1
2
3
4
5
6
% change t o a c o n v e n i e n t path
cd [CODE ROOT DIR ] ;
% add GUI code t o t h e MATLAB path
addpath R e g i s t r a t i o n / r e g i s t r a t i o n g u i ;
% s t a r t r e g i s t r a t i o n GUI
registration gui ;
2. Once the GUI starts up you can specify the directory containing the images you want to register. This is done
through the ‘Select Directory’ button (as given in Figure 1 (1)), and then browsing to the needed folder as shown
in Figure 2a:
(a) Select directory to register
(b) Directory ready to be analyzed
Figure 2: Select the directory for registration
Once the folder has been selected, the folder name will be displayed as shown in Figure 2b.
3. Once the directory has been selected, it is time to analyze if the directory is valid for registration. This is done
by simply clicking ‘Analyze Directory’ button as shown in Figure 1 (2). The success or failure will be given as
a log message in the window pointed out in Figure 1 (6). Upon success the options and buttons to perform
registration will get be enabled and the GUI will be in a state similar to Figure 1. The requirements for a valid
directory are as follows:
(a) All the images in the directory should match the following regular expression. If they do not, they will not
be recognized as valid images for registration:
((.+?)[\\/])∗ ([IO] [PF]) VF(\d+) (? : \d+)? (.+?) \.(? : (png)|(jpg)|(tif)|(gif)|(bmp)|(ppm)|(pbm)) $
{z
} | {z } | {z } | {z } | {z } |
{z
}
|
dir. path
valid
Visual
anti-body’s
optional
prefixes:
Field’s #
name
postfix
File (image) extension
IP,OP,IF,OF
The following are some examples of filenames that will match this regular expression: IF VF1 Bax.png,
OF VF3 NCAM.png, IP VF2 Cyclin D1 01.png.
3
Warwick University
Molecular Pattern Analysis of Colon Cells
(b) There should be images from one or more visual fields in the directory. The presence of a visual field is
inferred from the filenames as given above.
(c) If there are multiple visual fields, all visual fields should have exactly the same anti-bodies. For instance, if
VF1 has 3 anti-bodies Bax, CD36, and DAPI, VF2 and VF3 present in the same directory should have only
3 anti-bodies with the exact same names.
4. Once the directory has been validated, you are free to select the options for registration as given in Figure 1 (3)
and (4). As pointed in Figure 1 (3) you can select the registration method to use. The current code comes with
two registration methods:
(a) Mutual Info. (MATLAB class: RegistrationMI) register by trying to maximize mutual information [2] using
pattern search [1].
(b) Mutual Info. (Blocks) (MATLAB class: RegistrationMIBlocks) breaks the two images into smaller blocks
and tries to register each corresponding block using RegistrationMI.
5. Apart from registering each anti-body’s OP to IP image (intra anti-body registration), the IP images of all antibodies are also registered to a particular anti-body’s IP image (inter anti-body registration). This is done so that
every image in the directory can be transformed to any other image’s frame of reference. Figure 1 (3) points to
a popup menu which can be used to select this reference anti-body whose IP image is used for inter anti-body
registration.
6. The space pointed by Figure 1 (4) gives the options for the registration method chosen in 4. This panel would
change on selecting a new registration method. Options set here will be used when you finally register the images
in the selected directory. The explanations for the options for the two registration methods provided can be read
in Appendix A.
7. Once the directory has been selected and the registration options are set, you can push the ‘Register’ button to
start the registration process (as indicated by 1 (5)). The progress of the process is displayed in a progress bar
as given in Figure 3. Apart from the percentage progress, it displays any progress messages, the time elapsed,
and the time remaining:
Figure 3: The progress bar shown as the images in the directory are registered.
If you want to stop the process in between, press the ‘Cancel’ button on the progress bar. Unfortunately, usually
you will have to wait for the cancel confirmation dialog box to pop up. This is a limitation of MATLAB as the
registration and the GUI itself run on the same thread. All cancel/abort decisions can only take in between
individual registrations.
Once the registration finishes, the progress bar would close. Any error or success messages will be displayed in
the log message window.
8. The product of the registration process are .mat files which contain the translations resulting from the registrations. The registration process will generate the same number of registration files as the number of visual fields
in the directory. The filename format for these files is as follows:
results cancer5
| {z } VF01
| {z }
Images
root
dir. name
025
| {z }
Visual
#
Field ID
bodies
anti-
processed
4
20110309
|
{z
} 181854
| {z } .mat
modified date:
modified time:
YYYYMMDD
HHMMSS
Molecular Pattern Analysis of Colon Cells
Warwick University
The contents of this file is explained in Section 2.1
2.1
Registration File Structure
The registration file has the following variables:
1. im dir: This character array variable holds the full path of the image directory which was registered. Note that
when the registration file is passed onto a colleague, he might have the dataset at a different location. To cater
for this, whenever the registration file is loaded through the GUI, im dir is automatically checked and adjusted
with the help of the user if need be.
2. vf id: Gives the Visual Field ID whose registration information is contained in this file.
3. reg ver: This gives the modification number for this registration information. It is possible that the files are not
correctly registered automatically and might need fixes (see Section 2.2) - on each fix this modification number
is incremented. As explained in Section 3.1, this is useful for noting that the segmentation was done using the
latest registration results/parameters.
4. reg obj: This variable holds the registration method’s MATLAB object which was used for registering the specified
images.
5. reg ref ab: This character array holds the anti-body’s name that was specified for inter anti-body registration
(see Section 2 Point 5).
6. im structs: This main variable holds all the registration information. It is an N × 8 cell array, where N is the
number of anti-bodies. Each row in the cell array gives the intra and inter anti-body registration information
for a particular anti-body. Explanation for each column in a row follows:
(a) Column 1: Is a character array giving the anti-body’s name for which the current row holds information.
(b) Column 2-5: Are all character arrays giving filenames for the IF, OF, IP, OP images respectively. If some
image is not present, that particular character array is empty.
(c) Column 6: Is a 4 length vector giving the translations. The first two values gives translations for the intra
anti-body registration (OP to IP), and the last two gives translation for the inter anti-body registration
(IP to reference anti-body IP - reference anti-body is given in reg ref ab). The first value in each tuple is
x-axis translation (positive is translation toward right), the second value is y-axis translation (positive is
translation downward).
(d) Column 7: Is a structure array giving additional information returned by the registration method for the
intra anti-body registration.
(e) Column 8: Same as Column 8 for inter anti-body registration.
2.2
Fixing Registrations
Once the registration finishes, the GUI will ask if you want to fix any mis-registrations (see Figure 4a). If you say ‘no’
at this moment, you can later load this registration file and try to fix it through the button pointed by Figure 1 (8).
The following are the steps in fixing a registration file:
1. If the system detects that there are any errors in intra anti-body registration, it gives the user the opportunity
to change the reference anti-body (see Figure 4b). If user decides to change it, the user is displayed a list of
all available anti-bodies to select a new reference anti-body. Once selected all inter anti-body registrations are
performed again against the new reference anti-body’s IP, and a progress bar similar to Figure 3 is displayed.
Note changing the reference anti-body doesn’t ensure that all inter anti-body registrations will be fixed. In fact,
it is possible that the errors in inter anti-body registration would increase.
2. The system next tries to fix all remaining registrations with the help of the user. The aim of the system is to
take help from the user in finding a better initial translation to provide to the registration method. The user is
shown a dialog box similar to Figure 4c telling what is the registration that the user will next help fix.
5
Warwick University
Molecular Pattern Analysis of Colon Cells
3. On pressing ‘Ok’, the user is shown the reference image and asked to mark a feature point (like in Figure 4d).
The mark can be adjusted and is displayed as a red crosshair. Once the user is satisfied, they can press Enter
* and move onto the floating image. Here the user has to mark the corresponding (matching) position for the
mark they made in the reference image (Figure 4e). The user has to press Enter * again once satisfied.
4. The user will be asked to mark a different point on the same two images (repeat Steps 2 and 3). This is done to
get a mean (better) initial translation. Changing the number of repetitions in these two steps is easily possible
through code.
5. Once the user has provided an initial estimate for translation, the registration method uses it to perform the
registration. During it a wait message similar to Figure 4f is displayed.
6. On completion of registration, the user is reported about its success (like in Figure 4h) or its failure (like in
Figure 4g). Upon failure the user is prompted if they want to try marking corresponding points (possibly new
points) again.
7. The system tries to fix all mis-registrations by going through steps 2 to 6.
8. After attempting to fix all registrations, the system tries to store this information in a registration file. The user
is asked if he wants to ‘Replace’ the old registration file or make a ‘New File’. In either case the time stamp is
adjusted on this new file (see Section 2 Point 8).
(a) Do you want to fix registration?
(b) Do you want to specify an alternate reference
anti-body?
(d) Mark feature point in Reference image
(f) Wait message while attempting fix
registration
(c) Tells which registration we will attempt
to fix
(e) Mark feature point in Floating image
(g) Registration failed. Want to try again?
Figure 4: Fixing Registrations steps
6
(h) Registration success
Molecular Pattern Analysis of Colon Cells
2.3
Warwick University
Analyzing Registrations
It is possible to see how the registration results turned out through the GUI. Using the ‘Analyze Registrations’ button
pointed by Figure 1 (7), you can load a registration file for analysis. Once the file is selected, first all images are
translated according to the registration results: all images are translated to the IP of the reference anti-body. During
this process a progress bar similar to Figure 5a is displayed. Once all the translated images are cached in memory,
the GUI given 5b is displayed. The four quadrants display the IP, OP, IF, and OF images for one particular anti-body
whose name is given at the bottom of the figure. By using the slider right above the anti-body name, you can view
different registered anti-bodies. You can also put markers over the images - marking one image will place a marker at
the same location on the 3 other images. Since all images are translated to one particular image’s frame of reference,
a marker’s position over an image should correspond to the same physical location on all other images. The markers
remain even if you move the slider - to clear are markers use the ‘Clear markers’ button on the bottom left corner of
the figure.
Any registration errors are indicated in text over the images.
(a) Caching registered images before displaying the analysis GUI
(b) Registration analysis GUI. Notice the red markers you can place on the images for
analysis.
Figure 5: Analyzing Registered images
2.4
Output Registrations to Files
It is possible to write the translated images to disk using the ‘Output Registrations’ button pointed out in Figure 1
(9). After selecting the registration file, the user will be requested for a directory to write the the registered translated
images to. Before the images are written, all images are cached and translated to the IP of the reference anti-body.
A progress bar similar to 5a is displayed during this process. This is followed by another progress bar which tracks
the progress of writing registered images to the specified directory. All images are written as .png files. Finally, if
7
Download