Difference between revisions of "B-Spline Automatic Registration"

From MIPAV
Jump to: navigation, search
(Output files)
m (Normalized mutual information measure)
 
(44 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{| width="100%"
+
This chapter describes the B-spline based registration of images in three dimensions (3D). The description specializes to two dimensions (2D) is in the obvious manner.
|
+
Chapter is continued on the following pages:
[[Image:mipavfinallogo.gif]]
+
| align="right" valign="top" |
+
|}
+
== B-Spline Automatic Registration ==
+
  
This section describes the B-spline based registration of images in three dimensions (3D). The description specializes to two dimensions (2D) is in the obvious manner.
+
*[[B-Spline Automatic Registration | B-Spline Automatic Registration - you are here]]
  
=== Background ===
+
*[[BSpline registration: Detecting folding]]
  
Let the target image have dimensions [[Image:BSplineRegistrationOV_withMath11.jpg]] with image indices satisfying [[Image:BSplineRegistrationOV_withMath12.jpg]], [[Image:BSplineRegistrationOV_withMath13.jpg]], and [[Image:BSplineRegistrationOV_withMath14.jpg]]. Let the source image have dimensions [[Image:BSplineRegistrationOV_withMath15.jpg]] with image indices satisfying [[Image:BSplineRegistrationOV_withMath16.jpg]], [[Image:BSplineRegistrationOV_withMath17.jpg]], and [[Image:BSplineRegistrationOV_withMath18.jpg]]. The B-spline volume function maps indices [[Image:BSplineRegistrationOV_withMath19.jpg]] via [[BSplineRegistrationOV_withMath.html#wp1012563|equation 1]].
+
*[[Examples of BSpline registration]]
  
Equation 1 <div align="left">[[Image:BSplineRegistrationOV_withMath20.jpg]]</div><br />
+
*[[User Dialogs in MIPAV | B-Spline Automatic Registration Dialog]]
  
where the [[Image:BSplineRegistrationOV_withMath21.jpg]] functions are the B-spline basis functions, and the ''B'' values are the control points. The numbers [[Image:BSplineRegistrationOV_withMath22.jpg]],[[Image:BSplineRegistrationOV_withMath23.jpg]], and [[Image:BSplineRegistrationOV_withMath24.jpg]] are user selectable, the degrees [[Image:BSplineRegistrationOV_withMath25.jpg]], [[Image:BSplineRegistrationOV_withMath26.jpg]], and [[Image:BSplineRegistrationOV_withMath27.jpg]] for the basis functions are user selectable, and the B-spline basis functions are open and uniform.
+
== Class implementation for MIPAV ==
 +
 
 +
The following classes are part of the <span style="font-family:courier">mipav/model/structures</span> package:
 +
 
 +
* B-splineBasis
 +
* B-splineBasisDiscretef
 +
* BSplineLattice2Df
 +
* BSplineLattice3Df
 +
* BSplineRegistrationBasef
 +
* fBSplineRegistration2Df
 +
 
 +
The following classes are also part of the <span style="font-family:courier">mipav/model/algorithms</span>/registration package:
 +
 
 +
* AlgorithmRegBSpline
 +
* AlgorithmRegBSpline2D
 +
* AlgorithmRegBSpline3D
 +
* AlgorithmRegBSpline25D
 +
 
 +
== Background ==
 +
 
 +
<div id="Equation1"></div>
 +
Let the target image have dimensions
 +
<math>
 +
(p_o)\,(p_o)\,(p_o)
 +
</math> with image indices satisfying
 +
<math>
 +
0\le j_0<p_0
 +
</math>,
 +
<math>
 +
0\le j_1<p_1
 +
</math>, and
 +
<math>
 +
0\le j_2<p_2
 +
</math>. Let the source image have dimensions <math>
 +
(q_o)\,(q_o)\,(q_o)
 +
</math> with image indices satisfying <math>
 +
0\le k_0<q_0
 +
</math>, <math>
 +
0\le k_1<q_1
 +
</math>, and <math>
 +
0\le k_2<q_2
 +
</math>. The B-spline volume function maps indices <math>
 +
j_0,j_1,j_2
 +
</math> via equation 1.
 +
 
 +
Equation 1 <div align="left"><math>
 +
M_{j_0, j_1, j_2} = \sum_{i_0=0}^{n_o} \left( N_{i_0},d_0,\frac{j_0}{p_0-1} \sum_{i_1=0}^{n_1} \left( N_{i_1}, \frac{j_1}{p_1-1} \sum_{i_2=0}^{n_2}  N_{i_2}, d_2, \frac{j_2}{p_2-1}, B_{i_0, i_1, i_2} \right) \right)
 +
 
 +
 
 +
</math></div><br />
 +
 
 +
where the <math>
 +
N_{i_e, d_e}(u)
 +
</math> functions are the B-spline basis functions, and the ''B'' values are the control points. The numbers <math>
 +
n_0,n_1,</math> and <math> n_2 </math>, are user selectable, the degrees  
 +
<math>
 +
d_0,d_1,</math> and <math> d_2
 +
</math> for the basis functions are user selectable, and the B-spline basis functions are open and uniform.
  
 
The control points have the following characteristics:
 
The control points have the following characteristics:
  
 
* Each control point has coordinates from the unit cube. In two dimensions, each control point has coordinates from the unit square.
 
* Each control point has coordinates from the unit cube. In two dimensions, each control point has coordinates from the unit square.
* The initial placement of the control points depends on the B-spline basis and must yield the identity function; that is, [[Image:BSplineRegistrationOV_withMath28.jpg]]. The initial placement of the control points is described in Section [BSplineRegistrationOV_withMath.html#wp1000933 "Improving performance" ].
+
* The initial placement of the control points depends on the B-spline basis and must yield the identity function; that is,  
 +
<math>
 +
M_{j_0j_1j_2} = (\frac {j_0} {p_0-1}), (\frac{j_1} {p_1-1}), (\frac {J_2)} {P_2+1})
 +
</math>. The initial placement of the control points is described in Section "Improving performance".
 
* A control point is said to be in the outer layer if one of its indexes is either the minimum index (zero) or the maximum index (one less than the number of control points in a given dimension). The position of the control points in the outer layer are fixed as follows:
 
* A control point is said to be in the outer layer if one of its indexes is either the minimum index (zero) or the maximum index (one less than the number of control points in a given dimension). The position of the control points in the outer layer are fixed as follows:
  
  Equation 2 <div align="left">[[Image:BSplineRegistrationOV_withMath29.jpg]]</div><br />  
+
  Equation 2 <div align="left"><math>
 +
B_0,i_1,i_2 =(0,y_{i_1},z_{i_2})
 +
</math>
  
; ''This constraint implies that the [[Image:BSplineRegistrationOV_withMath30.jpg]]'''' ''''for all [[Image:BSplineRegistrationOV_withMath31.jpg]].''
+
<math>
 +
B_{i_0}, 0, i_2 = (\chi_{i_0}, 0, z_{i_2})
 +
</math>
  
* A control point not in the outer layer is said to be an interior control point. The position of the interior control points is constrained such that its movement must not cause any folding in the B-spline transformation. ''Folding'' is defined to occur when there is a negative value anywhere in the computed deformation for the current B-spline transformation. The computation of the deformation is described in Section [BSplineRegistrationOV_withMath.html#wp1001643 "Deformation" ]. The method by which folding is detected is described in Section [BSplineRegistrationOV_withMath.html#wp1001731 "Detect folding" ].
+
<math>
 +
B_{i_0}, i_0, 0 = (\chi_{i_0}, y_{i_1}, 0)
 +
</math>
  
Each [[Image:BSplineRegistrationOV_withMath32.jpg]] contains normalized 3D coordinates (i.e., in the unit cube) that identify a location in the source image corresponding to the sample at ([[Image:BSplineRegistrationOV_withMath33.jpg]]) in the target image. The [[Image:BSplineRegistrationOV_withMath34.jpg]] coordinates are ''related to sample ''coordinates in the source image by [[Image:BSplineRegistrationOV_withMath35.jpg]] where the output indices ([[Image:BSplineRegistrationOV_withMath36.jpg]]) are considered to be continuous values; that is, they are not necessarily integer valued. If the source image's samples are [[Image:BSplineRegistrationOV_withMath37.jpg]], where [[Image:BSplineRegistrationOV_withMath38.jpg]] for all [[Image:BSplineRegistrationOV_withMath39.jpg]], we need to evaluate the image at the nonintegral values ([[Image:BSplineRegistrationOV_withMath40.jpg]]). We can use trilinear interpolation to do this (use bilinear interpolation in the case of two-dimensional (2D) registration). Let [[Image:BSplineRegistrationOV_withMath41.jpg]], the largest integer smaller than [[Image:BSplineRegistrationOV_withMath42.jpg]]. Define [[Image:BSplineRegistrationOV_withMath43.jpg]]. The interpolated image value is:
+
<math>
 +
B_{n_0-1}, i_1, i_2 = (1, y_{i_1}, z_{i_2})
 +
</math>
  
Equation 3 <br /> <div style="font-style: normal; margin-bottom: 2pt; margin-left: 0pt; margin-right: 0pt; margin-top: 0pt; text-align: left; text-decoration: none; text-indent: 0pt; text-transform: none; vertical-align: baseline">'''<font size="8pt"><font color="#000000"><div align="left">[[Image:BSplineRegistrationOV_withMath44.jpg]]</div><br /> </font></font>'''</div><div><br /> </div><div><br /> </div><div><div align="left">[[Image:BSplineRegistrationOV_withMath45.jpg]]</div> </div><div><div align="left">[[Image:BSplineRegistrationOV_withMath46.jpg]]</div> </div><div><div align="left">[[Image:BSplineRegistrationOV_withMath47.jpg]]</div> </div><div><div align="left">[[Image:BSplineRegistrationOV_withMath48.jpg]]</div> </div><div><div align="left">[[Image:BSplineRegistrationOV_withMath49.jpg]]</div> </div><div><div align="left">[[Image:BSplineRegistrationOV_withMath50.jpg]]</div> </div>
+
<math>
 +
B_{i_0},n_1-1, i_2 = (\chi_{i_0}, 1, z_{i_2})
 +
</math>
  
If the target image samples are [[Image:BSplineRegistrationOV_withMath51.jpg]], where [[Image:BSplineRegistrationOV_withMath52.jpg]] for all [[Image:BSplineRegistrationOV_withMath53.jpg]], then the source image [[Image:BSplineRegistrationOV_withMath54.jpg]] is trilinearly interpolated at ([[Image:BSplineRegistrationOV_withMath55.jpg]]), which are the coordinates of [[Image:BSplineRegistrationOV_withMath56.jpg]]. This means that the currently registered source image, denoted [[Image:BSplineRegistrationOV_withMath57.jpg]], has the same dimensions as the target image and can be defined in terms of the target image samples as [[Image:BSplineRegistrationOV_withMath58.jpg]]. A measure of error between the two images S''j0,j1,j2'' and T''j0,j1 ,j2 ''can be computed. A number of possible error measure functions are defined in Section 1.2. The goal is to select the control point positions to make the error measure as small as possible. This is done by moving a single control point at a time using gradient descent.
+
<math>
 +
B_{i_0},i_1, n_2-1 = (\chi_{i_0}, y_{i_1}, 1)
 +
</math>
 +
 
 +
</div><br />
 +
 
 +
; ''This constraint implies that the <math>
 +
0\le k^\prime_w<q_w
 +
</math>'''' ''''for all w.''
 +
 
 +
* A control point not in the outer layer is said to be an interior control point. The position of the interior control points is constrained such that its movement must not cause any folding in the B-spline transformation. ''Folding'' is defined to occur when there is a negative value anywhere in the computed deformation for the current B-spline transformation. The computation of the deformation is described in Section "Deformation". The method by which folding is detected is described in Section "Detect folding".
 +
 
 +
Each <math>
 +
M_(j_0)(j_1)(j_2)
 +
</math> contains normalized 3D coordinates (i.e., in the unit cube) that identify a location in the source image corresponding to the sample at <math>
 +
(j_0,j_1,j_2)
 +
</math> in the target image. The <math>
 +
M_(j_0)(j_1)(j_2)
 +
</math> coordinates are ''related to sample ''coordinates in the source image by <math>
 +
M_{j_{0}, j_{1}, j_{2}} =\left( \frac {k^\prime_0}{q_0-1}, \frac{k^\prime_1}{q_1-1}, \frac{k^\prime_2}{q_2-1}\right)
 +
</math> where the output indices <math>
 +
k^\prime_0, k^\prime_1, k^\prime_2
 +
</math> are considered to be continuous values; that is, they are not necessarily integer valued. If the source image's samples are <math>
 +
s_k\_0,k_1,k_2
 +
</math>, where <math>
 +
0\le k^\prime_w < q_w
 +
</math> for all ''w'' , we need to evaluate the image at the nonintegral values <math>
 +
k^\prime_0, k^\prime_1, k^\prime_2
 +
</math>. We can use trilinear interpolation to do this (use bilinear interpolation in the case of two-dimensional (2D) registration). Let <math>
 +
k_w= |k^\prime_w|
 +
</math>, the largest integer smaller than <math> k^\prime_w </math>. Define <math>
 +
\Delta w = k^\prime_w - k_w
 +
</math>. The interpolated image value is:
 +
 
 +
Equation 3 <br />
 +
<math>
 +
U_0 = (1-\Delta_0)(S_{k_0,k_1,k_2}) + (\Delta_0)(S_{k_0 + 1,k_1,k_2})
 +
</math>
 +
 
 +
<math>
 +
U_1 = (1-\Delta_0)(S_{k_0,k_1+1,k_2} + (\Delta_0)(S_{k_0,k_1 + 1,k_2})
 +
</math>
 +
 
 +
<math>
 +
U_2 = (1-\Delta_0)(S_{k_0,k_1,k_2+1} + (\Delta_0)(S_{k_0+1,k_1,k_2+1})
 +
</math>
 +
 
 +
<math>
 +
U_3 = (1-\Delta_0)(S_{k_0,k_1+1,k_2+1} + (\Delta_0)(S_{k_0+1,k_1+1,k_2+1})
 +
</math>
 +
 
 +
<math>
 +
\nu_0 = (1 - \Delta_1)U_0 + (\Delta_1)(U_1)
 +
</math>
 +
 
 +
<math>
 +
\nu_1 = (1 - \Delta_1)U_2 + (\Delta_1)(U_3)
 +
</math>
 +
 
 +
<math>
 +
S(\kappa_0, \kappa_1, \kappa_2) = (1- \Delta_2)\nu_0 + (\Delta_2)(\nu_1)
 +
</math>
 +
 
 +
If the target image samples are <math>
 +
T_{j_0, j_1, j_2}
 +
</math>, where <math>
 +
0 \le j_w < p_w
 +
</math> for all ''w'', then the source image S is trilinearly interpolated at <math>
 +
(k^\prime_0,k^\prime_1, k^\prime_2)
 +
</math>, which are the coordinates of <math>
 +
M_(j_0)(j_1)(j_2)
 +
</math>. This means that the currently registered source image, denoted [[Image:BSplineRegistrationOV_withMath57.jpg]], has the same dimensions as the target image and can be defined in terms of the target image samples as <math>
 +
S^\prime(j_0,j_1,j_2) = S(k^\prime_0,k^\prime_1, k^\prime_2)
 +
</math>. A measure of error between the two images S''j0,j1,j2'' and T''j0,j1 ,j2 ''can be computed. A number of possible error measure functions are defined in Section 1.2. The goal is to select the control point positions to make the error measure as small as possible. This is done by moving a single control point at a time using gradient descent.
  
 
The gradient of the error function is estimated for the control point Bi''0'',i''1'',i''2 ''by means of finite differences, where changes in the error function are measured for small steps of the control point from its current position in each of the coordinate axis directions. Let [[Image:BSplineRegistrationOV_withMath59.jpg]], [[Image:BSplineRegistrationOV_withMath60.jpg]]and [[Image:BSplineRegistrationOV_withMath61.jpg]] be small step sizes equivalent to one sample increment in the target image,
 
The gradient of the error function is estimated for the control point Bi''0'',i''1'',i''2 ''by means of finite differences, where changes in the error function are measured for small steps of the control point from its current position in each of the coordinate axis directions. Let [[Image:BSplineRegistrationOV_withMath59.jpg]], [[Image:BSplineRegistrationOV_withMath60.jpg]]and [[Image:BSplineRegistrationOV_withMath61.jpg]] be small step sizes equivalent to one sample increment in the target image,
  
  Equation 4 <div align="left">[[Image:BSplineRegistrationOV_withMath62.jpg]]</div><br />  
+
  Equation 4 <div align="left"><math>
 +
\left( \Delta x = \frac{1} {p_0} \right),\left( \Delta y = \frac{1} {p_1} \right),\left( \Delta z = \frac{1} {p_2} \right)
 +
</math></div><br />  
  
 
The gradient of the error function is estimated at each control point B''i0,i1,i2''. The gradient at each control point is denoted by
 
The gradient of the error function is estimated at each control point B''i0,i1,i2''. The gradient at each control point is denoted by
  
  Equation 5 <br /> <div><br /> </div><div><br /> </div><div><br /> </div><div><br /> </div><div><div align="left">[[Image:BSplineRegistrationOV_withMath63.jpg]]</div> </div>
+
  Equation 5 <br /> <div><br /> </div><div><br /> </div><div><br /> </div><div><br /> </div><div><div align="left"><math>
 +
\triangledown E(i_0,i_1,i_2) =  \left ( \frac {E \left ( i_0+ \Delta x, i_1,i_2 \right ) - E \left (i_0 - \Delta x,i_1,i_2 \right )} {2\Delta x} \right ) , \left ( \frac {E \left ( i_0i_1 + \Delta y, i_2 \right ) - E \left (i_0i_1 - \Delta y,i_2 \right )} {2\Delta y} \right ),
 +
\left ( \frac {E \left ( i_0i_1i_2 + \Delta z \right ) - E \left (i_0i_1i_2 - \Delta z \right )} {2\Delta z} \right )
 +
</math></div> </div>
  
 
The gradient descent step is as follows. The current control point under consideration is B''i0,i1,i2''. The ray originating at this point and having direction of greatest decrease in E is
 
The gradient descent step is as follows. The current control point under consideration is B''i0,i1,i2''. The ray originating at this point and having direction of greatest decrease in E is
  
  Equation 6 <div align="left">[[Image:BSplineRegistrationOV_withMath64.jpg]]</div><br />  
+
  Equation 6 <div align="left"><math>
 +
B ^\backprime {i_0,i_1,i_2} (t) = B^\backprime {i_0,i_1,i_2} +tD
 +
</math></div><br />  
  
 
where the direction is the unit length vector
 
where the direction is the unit length vector
  
<div><div align="left">[[Image:BSplineRegistrationOV_withMath65.jpg]]</div> </div>
+
<div><div align="left"><math>
 +
D = \frac {\triangledown E(i_0,i_1,i_2)} {|\triangledown E(i_0,i_1,i_2)|}
 +
</math></div> </div>
  
and where [[Image:BSplineRegistrationOV_withMath66.jpg]] is computed using [[BSplineRegistrationOV_withMath.html#wp1014786|equation 5]]. The idea is to choose t &gt; 0 to minimize
+
and where [[Image:BSplineRegistrationOV_withMath66.jpg]] is computed using equation 5. The idea is to choose t &gt; 0 to minimize
  
<div><div align="left">[[Image:BSplineRegistrationOV_withMath67.jpg]]</div> </div>
+
<div><div align="left"><math>
 +
e(t) = E (B^\backprime i_0i_1i_2 (t))
 +
</math></div> </div>
  
A calculus approach which sets the first derivative to zero and solves for ''t'' yields an expression for ''e(t)'' that is really complicated. Instead, you should choose a set of ''t''-values, ''t''''1'' through ''t''''m'', evaluate ''e(t''''i'''')'' and find the minimum value. Suppose this occurs at ''t''''k''. Replace this in [[BSplineRegistrationOV_withMath.html#wp999901|equation 6]] to obtain the new location for the control point.
+
A calculus approach which sets the first derivative to zero and solves for ''t'' yields an expression for ''e(t)'' that is really complicated. Instead, you should choose a set of ''t''-values, ''t''''1'' through ''t''''m'', evaluate ''e(t''''i'''')'' and find the minimum value. Suppose this occurs at ''t''''k''. Replace this in equation 6 to obtain the new location for the control point.
  
Only those ''t''-values which do not result in the occurrence of folding in the B-spline transformation are considered. The method described in Section [BSplineRegistrationOV_withMath.html#wp1001731 "Detect folding" ] is used to determine if folding occurs for a given set of control point positions. Note that sample ''t0 '' (i.e., ''t=0'') is equivalent to the location of the control point before any movement attempt, and by definition, sample ''t0'' does not cause folding. A test is made to determine whether folding occurs for ''tm'', the extreme sample in the set of chosen ''t-''values. If folding does not occur at ''tm'', then folding does not occur at any of the other ''t-''values between ''t0'' and ''tm''. If folding does occur at ''tm'', then a bisection method is employed to find the ''tf old'' value between ''t0'' and ''tm'' where folding begins to occur. The search for a minimum value of ''e(t)'' by sampling must be limited to the ''t'' &lt; ''t''''f old''.
+
Only those ''t''-values which do not result in the occurrence of folding in the B-spline transformation are considered. The method described in Section "Detect folding" is used to determine if folding occurs for a given set of control point positions. Note that sample ''t0 '' (i.e., ''t=0'') is equivalent to the location of the control point before any movement attempt, and by definition, sample ''t0'' does not cause folding. A test is made to determine whether folding occurs for ''tm'', the extreme sample in the set of chosen ''t-''values. If folding does not occur at ''tm'', then folding does not occur at any of the other ''t-''values between ''t0'' and ''tm''. If folding does occur at ''tm'', then a bisection method is employed to find the ''tf old'' value between ''t0'' and ''tm'' where folding begins to occur. The search for a minimum value of ''e(t)'' by sampling must be limited to the ''t'' &lt; ''t''''f old''.
  
 
=== Error measures ===
 
=== Error measures ===
All of the error measures between two images defined in this section assume that the two images have the same dimensions. This is the case for the target image ''Tj''''0 '''',j''''1'''',j''''2'''' '' and registered source image ''S''''`''(''j0,j1,j2'') = ''S''(''k''''`''''0'''',k''''`''''1'''',k''''`''''2''). The particular error measures defined here are only concerned with corresponding samples from the two images or histograms of the values of the samples from the two images, and are not concerned with whether the images have two or three dimensions. For simplicity, each image measure will be defined with a single index to access its samples.
+
All of the error measures between two images defined in this section assume that the two images have the same dimensions. This is the case for the target image T (j0,j1,j2) and registered source image S (j0,j1,j2) = S(k0,k1,k2).  
  
==== Least squares measure ====
+
The particular error measures defined here are only concerned with corresponding samples from the two images or histograms of the values of the samples from the two images, and are not concerned with whether the images have two or three dimensions. For simplicity, each image measure will be defined with a single index to access its samples.
 +
 
 +
For more information, refer to [[Cost functions used in MIPAV algorithms]].
 +
 
 +
=== Least squares measure ===
  
 
The least squares measure is defined by
 
The least squares measure is defined by
  Equation 7 <br /> <div><div align="left">[[Image:BSplineRegistrationOV_withMath68.jpg]]</div> </div>
+
  Equation 7 <br /> <div><div align="left"><math>
 +
E_{LS} = \sum_{j}{|S^\prime(j) - T(j)|}^2
 +
</math></div> </div>
  
 
where the summation is over all the indices for the target image voxels.
 
where the summation is over all the indices for the target image voxels.
Line 70: Line 226:
 
Here, ''S''''`''(''j'') is a registered source image and ''T''(''j'') is a target image. The minimum value of this measure is zero; the maximum value depends on the range of values in the target and registered source images.
 
Here, ''S''''`''(''j'') is a registered source image and ''T''(''j'') is a target image. The minimum value of this measure is zero; the maximum value depends on the range of values in the target and registered source images.
  
==== Correlation ratio measure ====
+
For more information, refer to [[Cost functions used in MIPAV algorithms]].
  
 +
=== Correlation ratio measure ===
 +
 +
See also: [[Cost functions used in MIPAV algorithms]].
 
The correlation ratio measure is defined by
 
The correlation ratio measure is defined by
  
Equation 8 <br /> <div><div align="left">[[Image:BSplineRegistrationOV_withMath69.jpg]]</div> </div>
+
Equation 8 <br /> <div><div align="left"><math>
 +
E_{CR}= \frac {\sum_{k} \frac {n_k} {N} Var (S^\prime _k)} {Var (S)}
 +
</math></div> </div>
  
 
where
 
where
Line 87: Line 248:
 
The range of values for this measure is [''0,1''].
 
The range of values for this measure is [''0,1''].
  
==== Normalized mutual information measure ====
+
=== Normalized mutual information measure ===
  
 
The normalized mutual information measure is defined by
 
The normalized mutual information measure is defined by
  Equation 9 <br /> <div><div align="left">[[Image:BSplineRegistrationOV_withMath70.jpg]]</div> </div>
+
  Equation 9 <br /> <div><div align="left"><math>
 +
E_{NMI} = \frac {H(S^\prime, T)} {H(S^\prime) + H(T)}
 +
</math></div> </div>
  
 
where
 
where
  
<div><div align="left">[[Image:BSplineRegistrationOV_withMath71.jpg]]</div> </div>
+
<div><div align="left"><math>
 +
H(S^\prime, T)= -\sum_{i,j}p_{i,j}log p_{i,j}
 +
</math></div> </div>
  
 
is the standard entropy definition for probability pij estimated using the ''(i,j)'' joint histogram bins, and similarly for the marginals ''H(S')'' and ''H(T)''.
 
is the standard entropy definition for probability pij estimated using the ''(i,j)'' joint histogram bins, and similarly for the marginals ''H(S')'' and ''H(T)''.
Line 100: Line 265:
 
The standard entropy calculation
 
The standard entropy calculation
  
<div><div align="left">[[Image:BSplineRegistrationOV_withMath72.jpg]]</div> </div>
+
<div><div align="left"><math>
 +
H(S^\prime, T)= -\sum_{k}p_{k}log p_{k}
 +
</math></div> </div>
  
 
for an image ''X'' of ''N ''samples and user-selectable ''k'' histogram intensity bins equally distributed over the range of samples in image ''X'' can be rewritten as
 
for an image ''X'' of ''N ''samples and user-selectable ''k'' histogram intensity bins equally distributed over the range of samples in image ''X'' can be rewritten as
  
<div><div align="left">[[Image:BSplineRegistrationOV_withMath73.jpg]]</div> </div>
+
<div><div align="left">
 +
<math>
 +
H(X) = -\sum_{k} \frac {n_k} {N} log \left ( \frac {n_k} {N} \right )
 +
</math></div> </div>
  
 
where n''k'' is the histogram value for the k-th intensity bin and ''N'' =<font face="Symbol">S</font> ''k ''n''k''. The computational effort can be reduced by factoring to get
 
where n''k'' is the histogram value for the k-th intensity bin and ''N'' =<font face="Symbol">S</font> ''k ''n''k''. The computational effort can be reduced by factoring to get
  
<div><div align="left">[[Image:BSplineRegistrationOV_withMath74.jpg]]</div> </div>
+
<div><div align="left"><math>
 +
H(X) = \left ( \frac{-1}{N} \right ) \sum_{k} n_K (logn_k -log N)
 +
</math></div> </div>
  
 
where ''log n''''k'' can be a precomputed lookup table of logarithms of integer values.
 
where ''log n''''k'' can be a precomputed lookup table of logarithms of integer values.
  
The range of values for this measure is [''0,1''].
+
The range of values for this measure is [0,1].
 +
 
 +
For more information, refer to [[Cost functions used in MIPAV algorithms]].
  
 
=== Improving performance ===
 
=== Improving performance ===
Line 124: Line 298:
 
=== Initial placement of control points for identity map ===
 
=== Initial placement of control points for identity map ===
  
Referring to [[BSplineRegistrationOV_withMath.html#wp1012563|equation 1]] for the definition of the B-spline mapping function, the identity map is the one which yields
+
Referring to equation 1 for the definition of the B-spline mapping function, the identity map is the one which yields
  
<div><br >[[Image:BSplineRegistrationOV_withMath75.jpg|center]].</div><br /><div align="left">
+
<div><br ><math>
 +
M_{j_0j_1j_2} = (\frac {j_0} {p_0-1}), (\frac{j_1} {p_1-1}), (\frac {J_2)} {P_2+1})
 +
</math>.</div><br /><div align="left">
  
 
This section describes how to initially place the control points to yield this identity map. Since a separate set of B-spline basis functions is defined for each dimension, it happens that the placement of the control points to provide this identity map is computed independently for each dimension. This means that the ''x''-coordinate for each control point initially is determined by the B-spline basis defined for the ''X''-axis, and similarly for other dimensions.
 
This section describes how to initially place the control points to yield this identity map. Since a separate set of B-spline basis functions is defined for each dimension, it happens that the placement of the control points to provide this identity map is computed independently for each dimension. This means that the ''x''-coordinate for each control point initially is determined by the B-spline basis defined for the ''X''-axis, and similarly for other dimensions.
Line 134: Line 310:
 
For a B-spline basis of degree 1, the initial placement of the control points for the identity map is such that the control point coordinates are uniformly spaced as follows:
 
For a B-spline basis of degree 1, the initial placement of the control points for the identity map is such that the control point coordinates are uniformly spaced as follows:
  
  Equation 10 <div align="left">[[Image:BSplineRegistrationOV_withMath76.jpg]]</div><br />  
+
  Equation 10 <div align="left"><math>
 +
B_{i_k} = \frac {i_k} {n_k}
 +
</math></div><br />  
  
 
for coordinate ''k''. If the problem is to register images of three dimensions, and the B-spline bases for all three dimensions are selected to have degree 1, then
 
for coordinate ''k''. If the problem is to register images of three dimensions, and the B-spline bases for all three dimensions are selected to have degree 1, then
  
Equation 11 <br /> <div><div align="left">[[Image:BSplineRegistrationOV_withMath77.jpg]]</div> </div>
+
Equation 11 <br /> <div><div align="left"><math>
 +
B_{i_0, i_1, i_2} = \left ( \frac {i_0}{n_0}, \frac {i_1} {n_1}, \frac {i_2} {n_2} \right )
 +
</math></div> </div>
  
For a B-spline basis of degree 2 or larger, the initial placement of the control point coordinates is computed by the method of least squares. Again referring to [BSplineRegistrationOV_withMath.html#wp1012563 equation 2] for the definition of the B-spline mapping function, the identity map for coordinate ''k'' is
+
For a B-spline basis of degree 2 or larger, the initial placement of the control point coordinates is computed by the method of least squares. Again referring to equation 2 for the definition of the B-spline mapping function, the identity map for coordinate ''k'' is
  
<div><div align="left">[[Image:BSplineRegistrationOV_withMath78.jpg]]</div> </div>
+
<div><div align="left"><math>
 +
\frac {j_k}{p_k-1} = \sum_{i_k=0} ^{n_k}N_{i_k,d_k} \left ( \frac {j_k}{p_k-1} \right ) B_{i_k}
 +
</math></div> </div>
  
 
for any target image coordinate j''k'' satisfying 0&lt;= j''k'' &lt;p''k''.
 
for any target image coordinate j''k'' satisfying 0&lt;= j''k'' &lt;p''k''.
Line 148: Line 330:
 
A system of p''k'' equations above for n''k'' 1 unknowns (i.e., the Bi''k ''coordinate values) is set up in a matrix form A''X'' = ''C'', where
 
A system of p''k'' equations above for n''k'' 1 unknowns (i.e., the Bi''k ''coordinate values) is set up in a matrix form A''X'' = ''C'', where
  
<div><div align="left">[[Image:BSplineRegistrationOV_withMath79.jpg]]</div> </div>
+
<div><div align="left"><math>
 +
\left ( X_i = B_{i_k} \right ), \left (A_{ji}=N_{i_k,d_k} \left ( \frac {j_k} {p_k-1} \right) \right ),\left (C_j = \frac {j_k} {p_k-1} \right )
 +
</math></div> </div>
  
 
The solution is computed as
 
The solution is computed as
  
<div><div align="left">[[Image:BSplineRegistrationOV_withMath80.jpg]]</div> </div>
+
<div><div align="left">
 +
<math>
 +
X = (A^TA)^{-1}A^TC
 +
</math></div> </div>
  
 
The repositioning of the control points to yield this identity map is guaranteed not have create folding in the resulting transformation.
 
The repositioning of the control points to yield this identity map is guaranteed not have create folding in the resulting transformation.
  
==== Composition for two-pass registration ====
+
=== Composition for two-pass registration ===
  
 
Let ''S'' be a source image and ''T'' be the target image. If the image ''S'' is registered to image ''T'', then image ''S'' becomes the registered source image where ''R(T)'' is the registration mapping. This is graphically shown as:
 
Let ''S'' be a source image and ''T'' be the target image. If the image ''S'' is registered to image ''T'', then image ''S'' becomes the registered source image where ''R(T)'' is the registration mapping. This is graphically shown as:
  
[[Image:Composition1.png]]
+
[[Image:BSplineComposition1.png]]
  
 
For B-spline registration, the ''R(T)'' mapping is based on the selected B-spline basis and control points for each axis.
 
For B-spline registration, the ''R(T)'' mapping is based on the selected B-spline basis and control points for each axis.
Line 166: Line 353:
 
In the case of two-pass registration, the registered source image ''S''' is then registered to the same target image ''T'', but this time using different mapping parameters, i.e., a different set of B-spline basis and control points for the axes. The output of this second registration is a new registered source image ''S"''. Let ''R''''1''''(T)'' be the mapping for the first pass registration and ''R''''2''''(T)'' be the mapping for the second pass registration. This is graphically shown as:
 
In the case of two-pass registration, the registered source image ''S''' is then registered to the same target image ''T'', but this time using different mapping parameters, i.e., a different set of B-spline basis and control points for the axes. The output of this second registration is a new registered source image ''S"''. Let ''R''''1''''(T)'' be the mapping for the first pass registration and ''R''''2''''(T)'' be the mapping for the second pass registration. This is graphically shown as:
  
[[Image:Composition2.png]]
+
[[Image:BSplineComposition2.png]]
  
 
The usefulness of a two-pass registration is that the first pass would apply a coarse-level computation to quickly arrive at an approximate registration, and then the second pass would apply a finer-level computation to continue from the point where the first pass registration finished. The first pass registration may use B-spline bases with fewer control points and a smaller degree.
 
The usefulness of a two-pass registration is that the first pass would apply a coarse-level computation to quickly arrive at an approximate registration, and then the second pass would apply a finer-level computation to continue from the point where the first pass registration finished. The first pass registration may use B-spline bases with fewer control points and a smaller degree.
Line 174: Line 361:
 
This means defining a mapping ''R(T)'' having the same B-spline bases as the second pass registration mapping ''R''''2''''(T),'' but which maps the original source image ''S'' into the final registered source image ''S''. This is graphically shown as:
 
This means defining a mapping ''R(T)'' having the same B-spline bases as the second pass registration mapping ''R''''2''''(T),'' but which maps the original source image ''S'' into the final registered source image ''S''. This is graphically shown as:
  
[[Image:Composition3.png]]
+
[[Image:BSplineComposition3.png]]
  
 
The ''R(T)'' mapping for the second pass in a two-pass registration is different in that the initial placement of the control points does not yield the identity map to the original source image ''S''.
 
The ''R(T)'' mapping for the second pass in a two-pass registration is different in that the initial placement of the control points does not yield the identity map to the original source image ''S''.
Line 182: Line 369:
 
=== Deformation ===
 
=== Deformation ===
  
The deformation from the nonlinearly registered source image ''S'' to the target image ''T'' can be measured at each sample in the target image by computing the determinant of the Jacobian matrix for the nonlinear transformation. For three dimensions, the nonlinear registration transformation is defined by [[BSplineRegistrationOV_withMath.html#wp1012563| equation 1]]. Since each M''j0j1j2 ''contains normalized 3D coordinates of the position in the source image mapped for each (j0, j1, j2) in the target image, a map image of 3D coordinates can be created that contains these M''j0j1j2 ''source images coordinates (this map image has the same dimensions as the target image). An estimate of the gradient at each sample in this map image is computed using central finite differences at interior samples and forward/backward finite differences at "outer layer" samples. Since each sample in the map image contains 3D coordinates, the estimated gradient at each sample then is a 3x3 matrix of values representing the Jacobian matrix. A single-valued deformation image with the same dimensions as the target image is created which contains the computed determinants of the Jacobian matrices for each sample.
+
The deformation from the nonlinearly registered source image ''S'' to the target image ''T'' can be measured at each sample in the target image by computing the determinant of the Jacobian matrix for the nonlinear transformation. For three dimensions, the nonlinear registration transformation is defined by [[#Equation1| Equation 1]]. Since each M''j0j1j2 ''contains normalized 3D coordinates of the position in the source image mapped for each (j0, j1, j2) in the target image, a map image of 3D coordinates can be created that contains these M''j0j1j2 ''source images coordinates (this map image has the same dimensions as the target image). An estimate of the gradient at each sample in this map image is computed using central finite differences at interior samples and forward/backward finite differences at "outer layer" samples. Since each sample in the map image contains 3D coordinates, the estimated gradient at each sample then is a 3x3 matrix of values representing the Jacobian matrix. A single-valued deformation image with the same dimensions as the target image is created which contains the computed determinants of the Jacobian matrices for each sample.
  
 
If no deformation has occurred at a sample, the Jacobian matrix is the identity and its determinant is 1. If the source image is compressed near a sample, the determinant will be less than one. If the source image is expanded near a sample, the determinant will be greater than one. The computation of deformation is unaffected by differences in the dimensions for the source and target images. Because of the constraints on the placement of the control points, a negative determinant should not be possible, which would indicate some type of folding in the mapping.
 
If no deformation has occurred at a sample, the Jacobian matrix is the identity and its determinant is 1. If the source image is compressed near a sample, the determinant will be less than one. If the source image is expanded near a sample, the determinant will be greater than one. The computation of deformation is unaffected by differences in the dimensions for the source and target images. Because of the constraints on the placement of the control points, a negative determinant should not be possible, which would indicate some type of folding in the mapping.
  
=== Detect folding ===
+
== Next ==
  
The situation of folding in a 2D or 3D B-spline transformation occurs when there is a negative value in the computed deformation. The computation of the deformation is described in Section [BSplineRegistrationOV_withMath.html#wp1001643 "Deformation" ]. This section describes a method for detecting if such folding occurs given the current positions for the lattice of the B-spline control points. Given the lattice structure of the B-spline control points, folding can be detected by geometric means. In two dimensions, consider any interior control point and its 8 neighboring control points forming a polygon. Construct 8 triangles involving the chosen interior control point each time with the 8 pairings of adjacent control points on the polygon perimeter. The intersection of any one triangle with the other 7 triangles should each be empty in order for there to be no folding. Alternatively, the area of the polygon should be identical to the union of the areas of the 8 triangles.
+
*[[B-Spline Automatic Registration | B-Spline Automatic Registration - you are here]]
  
The issues are similar in three dimensions by considering the 26 neighboring control points forming a polyhedron. In this case, 48 tetrahedrons are constructed involving the chosen interior control point each time along with the triples of control points from the 48 triangles forming the polyhedron mesh. The intersection of any one tetrahedron with the other 47 tetrahedrons should each be empty in order for there to be no folding. Alternatively, the volume of the polyhedron should be identical to the union of the volumes of the 48 tetrahedrons.
+
*[[BSpline registration: Detecting folding]]
  
A sufficient but not necessary condition to conclude that folding occurs in the case of two dimensions is the premise that any interior control point is outside the polygon formed by its 8 neighboring control points. In the case of three dimensions, the premise is that any interior control point is outside the polyhedron formed by its 26 neighboring control points.
+
*[[Examples of BSpline registration]]
 
+
A condition that is both necessary and sufficient to conclude that folding occurs does exist for both 2D and 3D. In the case of two dimensions, again consider the 8 triangles formed by the chosen interior control point each time with the 8 pairings of adjacent control points on the polygon perimeter. It is important that these triangles formed by control points from the lattice be consistently counterclockwise ordered. For each triangle, let ''A =(a0,a1) ''be the 2D coordinates of the chosen interior control point, and let ''B =(b0,b1)'' and ''C =(c0,c1)'' be the 2D coordinates of the other two triangle control points taken in counterclockwise order. The normal to the plane which contains this triangle can be computed from the (right handed) cross product of the two vectors AB and AC. One way to express the calculation of the cross product involves the construction of the following matrix which contains the three triangle point coordinates:
+
 
+
Equation 12 <br /> <div><div align="left">[[Image:BSplineRegistrationOV_withMath84.jpg]]</div> </div>
+
 
+
The determinant of this matrix is twice the signed area of the triangle. Starting with consistently counter clockwise ordered triangles from the initially placed lattice of control points, the determinant of this matrix should remain positive as control point positions are moved. The determinant will become negative when the triangle ''folds''.
+
 
+
The premise for the necessary and sufficient condition to detect when folding occurs extends to three dimensions. Consider the 48 tetrahedrons formed by the chosen interior control point each time with the triples of adjacent control points from the 48 triangles forming the polyhedron mesh. It is important that the tetrahedrons formed by the control points from the lattice be consistently counterclockwise ordered, in the 3D sense. For each tetrahedron, let ''A = (a0,a1,a2)'' be the 3D coordinates of the chosen interior control point, and let ''B = (b0,b1,b2)'', ''C = (c0,c1,c2)'', and ''D = (d0,d1,d2)'' be the 3D coordinates of the other three tetrahedron control points taken in counterclockwise order. Extending the matrix determinant formulation used for two dimensions to three dimensions, the following matrix is constructed which contains the four tetrahedron point coordinates:
+
 
+
<div><div align="left">[[Image:BSplineRegistrationOV_withMath85.jpg]]</div> </div>
+
 
+
The determinant of this matrix is 6 times the signed volume of the tetrahedron. Starting with consistently counterclockwise ordered tetrahedrons from the initially placed lattice of control points, the determinant of this matrix should remain positive as control point positions are moved. The determinant will become negative when the tetrahedron ''folds''.
+
 
+
===== Support for color images =====
+
 
+
The registration of 2D and 3D color images involves first converting the three color channels of values at each sample in the source and target color images to create single channel source and target intensity images. Once the conversion has been done, the single channel intensity source and target images are registered as described in [[BSplineRegistrationOV_withMath.html#wp1011586|Background]]. The resulting transformation map is extracted from the registration which is then used to interpolate the original source color image in order to generate the output registered source color image.
+
 
+
Normally, the three color channels represent red, green, and blue intensities, and so the conversion to a single channel value usually represents overall intensity. In this manner, the conversion is simply a weighted average of the three color channels where separate weights can be provided for each channel. The current implementation uses equal weights for each channel.
+
 
+
===== Support for 2.5D images =====
+
 
+
A 2.5D image is actually a 3D image containing a series 2D slice images. The registration of a 2.5D intensity or color image involves a 2D registration of each slice in the 2.5D image to a reference slice also in the same 2.5D image. The reference slice can either be a xed slice or the previous slice. The resulting output registered 2.5D image contains the same number of slices as the original 2.5D image where the sample values in a slice of the registered output are from the same slice of the original only "warped" by the B-spline registration transformation.
+
 
+
If the reference slice is fixed, then the reference slice will appear in the registered output as being unchanged. If the reference slice is the previous slice, then the first slice will be registered to the last slice.
+
 
+
==== Examples of B-spline registration ====
+
 
+
[[BSplineRegistrationOV_withMath.html#wp1018548| Figure 1]] below shows an example of B-spline 3D image registration. [[BSplineRegistrationOV_withMath.html#wp1018286 |Figure 2] shows the registration deformation image and its lookup table. The registration was done using the default parameter values, which are explained in Section [[BSplineRegistrationOV_withMath.html#wp1003232|Image types]].
+
 
+
{| width="90%" border="1" frame="hsides" frame="hsides"
+
|-
+
| width="9%" valign="top" |
+
[[Image:noteicon.gif|center]]
+
| width="81%" bgcolor="#B0E0E6" | '''Note:''' that the input and the target image are both images of the same brain, that's why the registration demonstrates a very good overall fitting.
+
|}
+
 
+
<br />
+
 
+
<div>
+
<div style="color: #000000;  font-size: 10pt; font-style: normal; font-weight: normal; margin-bottom: 5pt; margin-left: 0pt; margin-right: 0pt; margin-top: 9pt; text-align: left; text-decoration: none; text-indent: 0pt; text-transform: none; vertical-align: baseline">
+
{| border="1" cellpadding="5"
+
|+ <div> ''' Figure 1. The input source image (A), the input target image (B) and the output registered image (C). Note that images (A) and (B) are both the images of the same brain. That's why it shows a very good overall fitting. Results may vary, if you take different brain images. ''' </div>
+
|-
+
|
+
<div style="font-style: normal; font-weight: normal; margin-bottom: 0pt; margin-left: 0pt; margin-right: 0pt; margin-top: 1pt; text-align: left; text-decoration: none; text-indent: 0pt; text-transform: none; vertical-align: baseline"><font size="2pt"><font color="#000000"><div><center>[[Image:2D_RegistrationOriginalImage.png]]</center></div><br /> </font></font></div>
+
|
+
<div style="font-style: normal; font-weight: normal; margin-bottom: 0pt; margin-left: 0pt; margin-right: 0pt; margin-top: 1pt; text-align: left; text-decoration: none; text-indent: 0pt; text-transform: none; vertical-align: baseline"><font size="2pt"><font color="#000000"><div><center>[[Image:2D_RegistrationTargetImage.png]]</center></div><br /> </font></font></div>
+
|
+
<div style="font-style: normal; font-weight: normal; margin-bottom: 0pt; margin-left: 0pt; margin-right: 0pt; margin-top: 1pt; text-align: left; text-decoration: none; text-indent: 0pt; text-transform: none; vertical-align: baseline"><font size="2pt"><font color="#000000"><div><center>[[Image:2D_RegistrationRegisteredImage.png]]</center></div><br /> </font></font></div>
+
|}
+
 
+
</div><div>
+
<div style="color: #000000;  font-size: 10pt; font-style: normal; font-weight: normal; margin-bottom: 5pt; margin-left: 0pt; margin-right: 0pt; margin-top: 9pt; text-align: left; text-decoration: none; text-indent: 0pt; text-transform: none; vertical-align: baseline">
+
{| border="1" cellpadding="5"
+
|+ <div>'''Figure 2. The deformation image and its lookup table. The dark areas on the deformation image are related to the areas on images (A) and (B) which did not perform a deformation during the registration or the deformation was relatively small. The light areas are related to the areas on images (A) and (B) which perform a bigger deformation.''' </div>
+
|-
+
|
+
<div style="font-style: normal; font-weight: normal; margin-bottom: 0pt; margin-left: 0pt; margin-right: 0pt; margin-top: 1pt; text-align: left; text-decoration: none; text-indent: 0pt; text-transform: none; vertical-align: baseline"><font size="2pt"><font color="#000000"><div><center>[[Image:FunctionLUT.png]]</center></div><br /> </font></font></div>
+
|
+
<div style="font-style: normal; font-weight: normal; margin-bottom: 0pt; margin-left: 0pt; margin-right: 0pt; margin-top: 1pt; text-align: left; text-decoration: none; text-indent: 0pt; text-transform: none; vertical-align: baseline"><font size="2pt"><font color="#000000"><div><center>[[Image:Function.png]]</center></div><br /> </font></font></div>
+
|}
+
 
+
</div>
+
 
+
==== Image types ====
+
 
+
The algorithm can be applied to 2D and 3D color (RGB) and grayscale images.
+
 
+
=== User Dialogs in MIPAV ===
+
 
+
Whenever B-spline registration is selected by the user, a dialog is displayed for the user to select the registration reference and the options related to how the registration is to be performed. A different dialog is displayed depending on whether the user selects 2D/3D registration between two images, or 2.5D registration of slices within a single image. The displayed dialogs differ only in how the registration reference is specified which depends on whether 2D/3D registration or 2.5D registration was selected; otherwise, options related to how the registration is to be performed are the same.
+
 
+
The choice of 2D/3D or 2.5D B-spline registration is made by selecting the appropriate menu item from the Algorithms: Registration submenu of MIPAV. Refer to [[BSplineRegistrationOV_withMath.html#wp1017164|Figure 3]] for details.
+
 
+
<div>
+
{| border="1" cellpadding="10"
+
|+ <div>'''Figure 3. The choice of 2D/3D or 2.5D B-spline registration is made by selecting the appropriate menu item from the Algorithms: Registration submenu ''' </div>
+
[[File:RegistrationAlgorithmsMenu.png]]
+
 
+
<div style="color: #000000;  font-size: 9pt; font-style: normal; font-weight: normal; margin-bottom: 5pt; margin-left: 0pt; margin-right: 0pt; margin-top: 9pt; text-align: left; text-decoration: none; text-indent: 0pt; text-transform: none; vertical-align: baseline">
+
 
+
 
+
 
+
The 2D/3D B-spline registration is available through the ''B-spline automatic registration 2D/3D'' menu item. This menu item is enabled when a 2D or 3D image (intensity or color) is the currently active image. The dialog is displayed only if there is at least one other loaded image in MIPAV which is compatible for registering to the currently active image. A compatible image is one that has the same number of channels of data and the same number of dimensions, but not necessarily the same sizes for each dimension. Refer to Figures [[BSplineRegistrationOV_withMath.html#wp1022791  |4]] and [[BSplineRegistrationOV_withMath.html#wp1020307  |5]]. The 2.5D B-spline registration is available through the ''B-spline automatic registration 2.5D menu'' item. This menu item is enabled only when a 3D image (intensity or color) is the currently active image. Refer to [[BSplineRegistrationOV_withMath.html#wp1020706 |Figure 6]]. Since the options related to how the registration is to be performed are identical for 2D/2.5D/3D and intensity/color images, and the only difference is how the registration reference is selected for 2D/3D vs. 2.5D, the dialog for presenting these options to the user is implemented in the same class. This class is <font>JDialogRegistrationBSpline</font> and is in the <font>mipav/model/view/dialogs</font> package. The class dynamically creates a dialog to present to the user with options that are appropriate for the type of registration.
+
 
+
{| border="1"
+
==== <div>'''Figure 4.  B-Spline Single - Pass Automatic Registration 2D/3D dialog box'''</div>====
+
+
 
+
{|  border="1" cellpadding="5" cellspacing="0"
+
|+
+
|-
+
|  colspan="3" rowspan="1" | <div ><b>General
+
|-
+
| <div >Register</div>
+
| <div >Displays a list of currently active 2D/3D images to registration. The drop down list of options show the names of available images currently loaded to which this image can be registered. This list will only contain the names of images currently loaded in MIPAV which are compatible. </div>
+
|  colspan="1" rowspan="2" | <div ><div align="center">[[File:B-splineAutomRegistration3DIntensity.png]] </div><</div><div ><br></div>
+
|-
+
| <div >Cost function</div>
+
| <div >This drop down list contains the following choices for cost measure to use during registration: Least Squares, Correlation Ratio, and Normalized Mutual Information.</div>
+
|-
+
| <div >Perform two-pass registra-tion</div>
+
|  colspan="2" rowspan="1" | <div >This dialog is shown with the default options for single-pass registration. If the <em>Perform two-pass registration</em> option is enabled, then the dialog will change to make options for <em>two-pass registration</em> available.</div>
+
|-
+
|  colspan="3" rowspan="1" | <div >Transformation Options</div><div >The following is a discussion of the dialog options which control each registration pass, one set of options per pass. For more information refer to [[BSplineRegistrationOV_withMath.html#wp1021773|Transformation options]]</div>
+
|-
+
| <div >Sub-sample image for speed</div>
+
|  colspan="2" rowspan="1" | <div >If this option is enabled, the image will be subsample in power of 2 for each dimension. Subsampling increases performance of the algorithm, but it exhibits lower accuracy of registration.</div>
+
|-
+
| <div >B-Spline Degree (same for all axes)</div>
+
|  colspan="2" rowspan="1" | <div >This is the degree of the B-Spline to use for all axes of the image. The drop list of options show the values of 1 (linear), 2 (quadratic), 3 (cubic), and 4 which are available. Although, the underlying BSpineBasisf class supports any degree, this dialog restricts the degrees to these values. Choosing a smaller degree executes faster than a larger degree, but a higher degree offers a higher order of continuity.<em></em></div>
+
|-
+
| <div >B-Spline Control Points(same for all axes)</div>
+
|  colspan="2" rowspan="1" | <div >This is the number of B-spline control points to use for all axes of the image.The minimum number of control points is the larger of the number 2 and the degree of the B-Spline. This dialog limits the maximum number of control points to one-half of the number of samples in the smallest dimension. </div>
+
|-
+
| <div >Gradient Descent Minimize Step Size (sample units)<a name="wp1022724"></a></div>
+
|  colspan="2" rowspan="1" | <div >This is the size of steps each control point is moved along the gradient-based direction when searching for a minimum of the error. The registration does not take into account the size of an image sample in each dimension, so <em>this step size is specified in units of a sample</em>. E.g., a value of 0.5 will move the control point in increments of <em>half of a sample</em> while searching for the minimum error. The minimum step size is 0.1 sample and the maximum is 5 samples. </div>
+
|-
+
| <div >Gradient Descent Minimize Max Search Steps</div>
+
|  colspan="2" rowspan="1" | <div >This is the maximum number of steps the control point is moved along the gradient-based direction when searching for a minimum of the error. If the distance from the control point current position to the bounding polygon/polyhedron of its neighboring control points along the gradient-based direction is less than this specified value, then the computed distance value will be used for this control point instead. The minimum number of steps is 1 and the maximum is 100.<</div>
+
|-
+
|  colspan="3" rowspan="1" | <div >Iteration options (one iteration=move each control point once)</div>
+
|-
+
|  colspan="2" rowspan="1" | <div >Convergence limit (min change rate for one iteration)</div>
+
| <div >This is a rate of change threshold such that if the rate the error changes between starting and ending of each iteration is smaller than this value, then the registration terminates.</div>
+
|-
+
|  colspan="2" rowspan="1" | <div >Maximum Number of Iterations</div>
+
| <div >If the convergence limit is not satisfied after this many iterations have been executed, then the registration terminates. The range of possible values is 1 to 100. </div>
+
|-
+
|  colspan="3" rowspan="1" | <div >Results</div>
+
|-
+
| <div >Create deforma-tion field image</div>
+
|  colspan="2" rowspan="1" | <div >If this checkbox is enabled, then the deformation image is computed after the last pass of registration is performed. The image that is created has the same dimensions as the target and the registered source images, and has the name of the source image appended with <em>deformation</em> suffix. The deformation image will be automatically displayed along with the registered source image upon completion of registration. Refer to [[BSplineRegistrationOV_withMath.html#wp1018286|Figure5]] for details.</div>
+
|-
+
| <div ><b>OK</b></div>
+
|  colspan="2" rowspan="1" | <div >Applies the algorithm to the input image that you chose in this dialog box.</div>
+
|-
+
| <div ><b>Cancel</b></div>
+
|  colspan="2" rowspan="1" | <div >Disregards any changes that you made in this dialog box and closes the dialog box.</div>
+
|-
+
| <div ><b>Help</b><</div>
+
|  colspan="2" rowspan="1" | <div >Displays online help for this dialog box.</a></div>
+
|-
+
|}
+
 
+
==== <div>'''Figure 5.  B-Spline Two - Pass Automatic Registration 2D/3D dialog box'''</div>====
+
If the <em>Perform two-pass registration</em> check box is selected, then the dialog will change to the following:
+
<em>
+
{|  border="1" cellpadding="5" cellspacing="0"
+
|+
+
|-
+
|  colspan="3" rowspan="1" | <div >General</div>
+
|-
+
| <div >Register</div>
+
| <div >Displays a list of currently active 2D/3D images to registration. The drop down list of options show the names of available images currently loaded to which this image can be registered. This list will only contain the names of images currently loaded in MIPAV which are compatible. </div>
+
|  colspan="1" rowspan="2" | <div ><br></div><div ><div align="center">[[File:TwoPassRegistration.png]]</div></div>
+
|-
+
| <div >Cost function</div>
+
| <div >This drop down list contains the following choices for cost measure to use during registration: Least Squares, Correlation Ratio, and Normalized Mutual Information.</div>
+
|-
+
| <div >Perform two-pass registra-tion</div>
+
|  colspan="2" rowspan="1" | <div >This dialog is shown with the default options for <em>two-pass registration</em>. If the <em>Perform two-pass registration</em> option is disabled, then the dialog will change to make options for <em>single-pass registration</em> available as shown in [[BSplineRegistrationOV_withMath.html#wp1022791|Figure 4]]</div>
+
|-
+
|  colspan="3" rowspan="1" | <div >Transformation Options</div><div >The following is a discussion of the dialog options which control each registration pass, one set of options per pass. For more information refer to <a [[BSplineRegistrationOV_withMath.html#wp1021773|Transformation options]]</div>
+
|-
+
| <div >Sub-sample image for speed</div>
+
|  colspan="2" rowspan="1" | <div >If this option is enabled, the image will be subsample in power of 2 for each dimension. Subsampling increases performance of the algorithm, but it results lower accuracy of registration.</div>
+
|-
+
| <div >B-Spline Degree (same for all axes)</div>
+
|  colspan="2" rowspan="1" | <div >This is the degree of the B-Spline to use for all axes of the image. The drop list of options show the values of 1 (linear), 2 (quadratic), 3 (cubic), and 4 which are available. Although, the underlying BSpineBasisf class supports any degree, this dialog restricts the degrees to these values. Choosing a smaller degree executes faster than a larger degree, but a higher degree offers a higher order of continuity.<em></em></div>
+
|-
+
| <div >B-Spline Control Points(same for all axes)</div>
+
|  colspan="2" rowspan="1" | <div >This is the number of B-spline control points to use for all axes of the image.The minimum number of control points is the larger of the number 2 and the degree of the B-Spline. This dialog limits the maximum number of control points to one-half of the number of samples in the smallest dimension. </div>
+
|-
+
| <div >Gradient Descent Minimize Step Size (sample units)</div>
+
|  colspan="2" rowspan="1" | <div >This is the size of steps each control point is moved along the gradient-based direction when searching for a minimum of the error. The registration does not take into account the size of an image sample in each dimension, so <em>this step size is specified in units of a sample</em>. E.g., a value of 0.5 will move the control point in increments of <em>half of a sample</em> while searching for the minimum error. The minimum step size is 0.1 sample and the maximum is 5 samples. </div>
+
|-
+
| <div >Gradient Descent Minimize Max Search Steps</div>
+
|  colspan="2" rowspan="1" | <div >This is the maximum number of steps the control point is moved along the gradient-based direction when searching for a minimum of the error. If the distance from the control point current position to the bounding polygon/polyhedron of its neighboring control points along the gradient-based direction is less than this specified value, then the computed distance value will be used for this control point instead. The minimum number of steps is 1 and the maximum is 100.</div>
+
|-
+
|  colspan="3" rowspan="1" | <div >Iteration options (one iteration=move each control point once)</div>
+
|-
+
|  colspan="2" rowspan="1" | <div >Convergence limit (min change rate for one iteration)</div>
+
| <div >This is a rate of change threshold such that if the rate the error changes between starting and ending of each iteration is smaller than this value, then the registration terminates.</div>
+
|-
+
|  colspan="2" rowspan="1" | <div >Maximum Number of Iterations</div>
+
| <div >If the convergence limit is not satisfied after this many iterations have been executed, then the registration terminates. The range of possible values is 1 to 100. </div>
+
|-
+
|  colspan="3" rowspan="1" | <div >Results</div>
+
|-
+
| <div >Create deforma-tion field image</div>
+
|  colspan="2" rowspan="1" | <div >If this checkbox is enabled, then the deformation image is computed after the last pass of registration is performed. The image that is created has the same dimensions as the target and the registered source images, and has the name of the source image appended with <em>deformation</em> suffix. The deformation image will be automatically displayed along with the registered source image upon completion of registration. Refer to [[BSplineRegistrationOV_withMath.html#wp1018286|Figure 5]]for details.</div>
+
|-
+
| <div >OK</div>
+
|  colspan="2" rowspan="1" | <div >Applies the algorithm to the input image that you chose in this dialog box.</div>
+
|-
+
| <div >Cancel</div>
+
|  colspan="2" rowspan="1" | <div >Disregards any changes that you made in this dialog box and closes the dialog box.</div>
+
|-
+
| <div >Help</div>
+
|  colspan="2" rowspan="1" | <div >Displays online help for this dialog box.</div>
+
|-
+
|}
+
 
+
This dialog is shown with the default options for a two-pass registration. As previously mentioned and as indicated in the dialog, a single iteration involves the movement of each interior control point in a gradient descent minimization manner.
+
<a name="wp1003337"></a></p><p >
+
 
+
==== <div>'''B-Spline Single - Pass Automatic Registration 2.5D dialog box'''</div>====
+
 
+
The following is an example of the dialog which is displayed for 2.5D intensity/color image registration: This dialog is show with the default options for a single-pass registration. If the Perform two-pass registration check box is selected, then the dialog will change in a manner similar to that for the 2D/3D image registration shown in [[BSplineRegistrationOV_withMath.html#wp1020307|Figure 5]].
+
<div >
+
 
+
<div>'''Figure 6.  B-Spline Single - Pass Automatic Registration 2.5D dialog box'''</div>
+
{|  border="1" cellpadding="5" cellspacing="0"
+
|+
+
|-
+
|  colspan="3" rowspan="1" | <div >General</div>
+
|-
+
| <div >Register</div>
+
| <div >The Register source field is already filled with the name of the currently selected 2.5D image. The reference slice is selected from among the slices in the selected image. </div><div >Radio buttons are used to select whether the reference slice is the the adjacent (previous) slice or a particular slice number in the image. If the Reference Slice radio button is selected, then a drop down list of slices numbers is enabled where the middle slice is selected by default. </div>
+
 
+
|  colspan="1" rowspan="2" | <div ><br></div><div ><div align="center">[[File:25DRegistration.png]]</div></div>
+
|-
+
| <div >Cost function</div>
+
| <div >This drop down list contains the following choices for cost measure to use during registration: Least Squares, Correlation Ratio, and Normalized Mutual Information.</div>
+
|-
+
| <div >Perform two-pass registration</div>
+
|  colspan="2" rowspan="1" | <div >This dialog is shown with the default options for single-pass registration. If the Perform two-pass registration option is enabled, then the dialog will change to make options for two-pass registration</em> available. Refer to [[BSplineRegistrationOV_withMath.html#wp1021917|Figure 7]]</div>
+
|-
+
|  colspan="3" rowspan="1" | <div >Transformation Options</div><div >The following is a discussion of the dialog options which control each registration pass, one set of options per pass. For more information refer to [[BSplineRegistrationOV_withMath.html#wp1021773|Transformation options.]]</div>
+
|-
+
| <div >Sub-sample image for speed</div>
+
|  colspan="2" rowspan="1" | <div >If this option is enabled, the image will be subsample in power of 2 for each dimension. Subsampling increases performance of the algorithm, but it results lower accuracy of registration.</div>
+
|-
+
| <div >B-Spline Degree (same for all axes)</div>
+
|  colspan="2" rowspan="1" | <div >This is the degree of the B-Spline to use for all axes of the image. The drop list of options show the values of 1 (linear), 2 (quadratic), 3 (cubic), and 4 which are available. Although, the underlying BSpineBasisf class supports any degree, this dialog restricts the degrees to these values. Choosing a smaller degree executes faster than a larger degree, but a higher degree offers a higher order of continuity.</div>
+
|-
+
| <div >B-Spline Control Points(same for all axes)</div>
+
|  colspan="2" rowspan="1" | <div >This is the number of B-spline control points to use for all axes of the image.The minimum number of control points is the larger of the number 2 and the degree of the B-Spline. This dialog limits the maximum number of control points to one-half of the number of samples in the smallest dimension. </div>
+
|-
+
| <div >Gradient Descent Minimize Step Size (sample units)</div>
+
|  colspan="2" rowspan="1" | <div >This is the size of steps each control point is moved along the gradient-based direction when searching for a minimum of the error. The registration does not take into account the size of an image sample in each dimension, so this step size is specified in units of a sample. E.g., a value of 0.5 will move the control point in increments of <em>half of a sample</em> while searching for the minimum error. The minimum step size is 0.1 sample and the maximum is 5 samples. </div>
+
|-
+
| <div >Gradient Descent Minimize Max Search Steps</div>
+
|  colspan="2" rowspan="1" | <div >This is the maximum number of steps the control point is moved along the gradient-based direction when searching for a minimum of the error. If the distance from the control point current position to the bounding polygon/polyhedron of its neighboring control points along the gradient-based direction is less than this specified value, then the computed distance value will be used for this control point instead. The minimum number of steps is 1 and the maximum is 100.</div>
+
|-
+
|  colspan="3" rowspan="1" | <div >Iteration options (one iteration=move each control point once)</div>
+
|-
+
|  colspan="2" rowspan="1" | <div >Convergence limit (min change rate for one iteration)</div>
+
| <div >This is a rate of change threshold such that if the rate the error changes between starting and ending of each iteration is smaller than this value, then the registration terminates.</div>
+
|-
+
|  colspan="2" rowspan="1" | <div >Maximum Number of Iterations</div>
+
| <div >If the convergence limit is not satisfied after this many iterations have been executed, then the registration terminates. The range of possible values is 1 to 100. </div>
+
|-
+
|  colspan="3" rowspan="1" | <div >Results</div>
+
|-
+
| <div >Create deformation field image</div>
+
|  colspan="2" rowspan="1" | <div >If this checkbox is enabled, then the deformation image is computed after the last pass of registration is performed. The image that is created has the same dimensions as the target and the registered source images, and has the name of the source image appended with <em>deformation</em> suffix. The deformation image will be automatically displayed along with the registered source image upon completion of registration. Refer to [[BSplineRegistrationOV_withMath.html#wp1018286|Figure 2]] for details.</div>
+
|-
+
| <div >OK</div>
+
|  colspan="2" rowspan="1" | <div >Applies the algorithm to the input image that you chose in this dialog box.</div>
+
|-
+
| <div >Cancel</div>
+
|  colspan="2" rowspan="1" | <div >Disregards any changes that you made in this dialog box and closes the dialog box.</div>
+
|-
+
| <div >Help</div>
+
|  colspan="2" rowspan="1" | <div >Displays online help for this dialog box.</div>
+
|-
+
</div>
+
|}
+
 
+
==== <div>'''B-Spline Two - Pass Automatic Registration 2.5D dialog box'''</div>====
+
 
+
<div>'''Figure 7.  B-Spline Two - Pass Automatic Registration 2.5D dialog box'''</div>
+
 
+
 
+
{|  border="1" cellpadding="5" cellspacing="0"
+
|+
+
|-
+
|  colspan="3" rowspan="1" | <div >General</div>
+
|-
+
| <div >Register</div>
+
| <div >The Register source field is already filled with the name of the currently selected 2.5D image. The reference slice is selected from among the slices in the selected image. </div><div >Radio buttons are used to select whether the reference slice is the the adjacent  (previous) slice or a particular slice number in the image. If the Reference Slice radio button is selected, then a drop down list of slices numbers is enabled where the middle slice is selected by default. </div>
+
|  colspan="1" rowspan="2" | <div ><br></div><div ><div align="center">[[File:25DTwoPassRegistration.png]]</div></div>
+
|-
+
| <div >Cost function</div>
+
| <div >This drop down list contains the following choices for cost measure to use during registration: Least Squares, Correlation Ratio, and Normalized Mutual Information.</div>
+
|-
+
|  colspan="2" rowspan="1" | <div >Perform two-pass registration<</div>
+
| <div >This dialog is shown with the default options for two-pass registration.</div>
+
|-
+
|  colspan="3" rowspan="1" | <div >Transformation Options</div><div >The following is a discussion of the dialog options which control each registration pass, one set of options per pass. For more information refer to [[BSplineRegistrationOV_withMath.html#wp1021773|Transformation options]].</div>
+
|-
+
| <div >Sub-sample image for speed</div>
+
|  colspan="2" rowspan="1" | <div >If this option is enabled, the image will be subsample in power of 2 for each dimension. Subsampling increases performance of the algorithm, but it results lower accuracy of registration.</div>
+
|-
+
| <div >B-Spline Degree (same for all axes)</div>
+
|  colspan="2" rowspan="1" | <div >This is the degree of the B-Spline to use for all axes of the image. The drop list of options show the values of 1 (linear), 2 (quadratic), 3 (cubic), and 4 which are available. Although, the underlying BSpineBasisf class supports any degree, this dialog restricts the degrees to these values. Choosing a smaller degree executes faster than a larger degree, but a higher degree offers a higher order of continuity.</div>
+
|-
+
| <div >B-Spline Control Points(same for all axes)</div>
+
|  colspan="2" rowspan="1" | <div >This is the number of B-spline control points to use for all axes of the image.The minimum number of control points is the larger of the number 2 and the degree of the B-Spline. This dialog limits the maximum number of control points to one-half of the number of samples in the smallest dimension. </div>
+
|-
+
| <div >Gradient Descent Minimize Step Size (sample units)</div>
+
|  colspan="2" rowspan="1" | <div >This is the size of steps each control point is moved along the gradient-based direction when searching for a minimum of the error. The registration does not take into account the size of an image sample in each dimension, so this step size is specified in units of a sample. E.g., a value of 0.5 will move the control point in increments of half of a sample while searching for the minimum error. The minimum step size is 0.1 sample and the maximum is 5 samples. </div>
+
|-
+
| <div >Gradient Descent Minimize Max Search Steps</div>
+
|  colspan="2" rowspan="1" | <div >This is the maximum number of steps the control point is moved along the gradient-based direction when searching for a minimum of the error. If the distance from the control point current position to the bounding polygon/polyhedron of its neighboring control points along the gradient-based direction is less than this specified value, then the computed distance value will be used for this control point instead. The minimum number of steps is 1 and the maximum is 100.</div>
+
|-
+
|  colspan="3" rowspan="1" | <div >Iteration options (one iteration=move each control point once)</div>
+
|-
+
|  colspan="2" rowspan="1" | <div >Convergence limit (min change rate for one iteration)</div>
+
| <div >This is a rate of change threshold such that if the rate the error changes between starting and ending of each iteration is smaller than this value, then the registration terminates.</div>
+
|-
+
|  colspan="2" rowspan="1" | <div >Maximum Number of Iterations</div>
+
| <div >If the convergence limit is not satisfied after this many iterations have been executed, then the registration terminates. The range of possible values is 1 to 100. </div>
+
|-
+
|  colspan="3" rowspan="1" | <div >Results</div>
+
|-
+
| <div >Create deformation field image</div>
+
|  colspan="2" rowspan="1" | <div >If this checkbox is enabled, then the deformation image is computed after the last pass of registration is performed. The image that is created has the same dimensions as the target and the registered source images, and has the name of the source image appended with deformation suffix. The deformation image will be automatically displayed along with the registered source image upon completion of registration. Refer to [[BSplineRegistrationOV_withMath.html#wp1018286|Figure 2]] for details.</div>
+
|-
+
| <div >OK</div>
+
|  colspan="2" rowspan="1" | <div >Applies the algorithm to the input image that you chose in this dialog box.</div>
+
|-
+
| <div >Cancel</div>
+
|  colspan="2" rowspan="1" | <div >Disregards any changes that you made in this dialog box and closes the dialog box.</div>
+
|-
+
| <div >Help</div>
+
|  colspan="2" rowspan="1" | <div >Displays online help for this dialog box.</div>
+
|-
+
|}
+
 
+
<div style="color: #000000;  font-size: 9pt; font-style: normal; font-weight: normal; margin-bottom: 5pt; margin-left: 0pt; margin-right: 0pt; margin-top: 9pt; text-align: left; text-decoration: none; text-indent: 0pt; text-transform: none; vertical-align: baseline">
+
 
+
===== Transformation options =====
+
 
+
The following is a discussion of the dialog options which control each registration pass, one set of options per pass:
+
 
+
''B-spline Degree (same for all axes):'' This is the degree of the B-spline to use for all axes of the image. Even though the B<font>SplineRegistration2Df </font>and <font>BSplineRegistration3Df</font> classes allow for specification of separate degrees for each axis, this dialog restricts the degrees to be the same. The drop list of options show the values of 1 (linear), 2 (quadratic), 3 (cubic), and 4 which are available. Although, the underlying <font>BSpineBasisf</font> class supports any degree, this dialog restricts the degrees to these values.Choosing a smaller degree executes faster than a larger degree, but a higher degree offers a higher order of continuity.
+
 
+
''B-spline Control Points (same for all axes):'' This is the number of B-spline control points to use for all axes of the image. Even though the <font>BSplineRegistration2Df </font>and <font>BSplineRegistration3Df </font>classes allow for specification of separate number of control points for each axis, this dialog restricts the numbers of control points to be the same. Initially, the control points are evenly spaced in each dimension, and the registration algorithm moves the interior control points to minimize the error difference between the target image and the registered source image. The minimum number of control points is the larger of the number 2 and the degree of the B-spline. This dialog option limits the maximum number of control points to one-half of the number of samples in the smallest dimension. Choosing more control points generally results in better overall fitting, but a limitation may be that the control points will be closer to each other and that will limit how much a control point can move to minimize the error (in order to satisfy the constraint that an interior control point must be within the bounding polygon/polyhedron formed by its neighboring control points). Also, since choosing more control points means that control points will be closer to each other, it may be helpful to reduce the maximum number of steps for searching for the gradient descent minimum.
+
 
+
Choosing more control points rather than fewer should result in a longer execution time. Even though more control points means fewer samples (for the same size input image) are affected by a single control point, the fact that there are more control points to move and each one requires a gradient descent sample search for a minimum error most likely results in the longer execution time.
+
 
+
Choosing more control points may require a different convergence limit. Since the convergence limit is tested once per iteration and an iteration involves moving each interior control point once, it may be that more control points could result in more (or less) overall changes in the error between starting and ending one iteration.
+
 
+
''Gradient Descent Minimize Step Size (sample size units): ''This is the size of steps each control point is moved along the gradient-based direction when searching for a minimum of the error. The registration does not take into account the size of an image sample in each dimension, so this step size is specified in units of a sample. For instance, a value of 0.5 will move the control point in increments of half a sample while searching for the minimum error. The minimum step size is 0.1 sample and the maximum is 5 samples.
+
 
+
''Gradient Descent Minimize Max Search Steps:'' This is the maximum number of steps the control point is moved along the gradient-based direction when searching for a minimum of the error. If the distance from the control points current position to the bounding polygon/polyhedron of its neighboring control points along the gradient-based direction is less than this specified value, then the computed distance value will be used for this control point instead. The minimum number of steps is 1 and the maximum is 100.
+
 
+
''Convergence limit (min change rate for one iteration): ''This is a rate of change threshold such that if the rate the error changes between starting and ending of each iteration is smaller than this value, then the registration terminates. As mentioned previously, the rate of change is computed as
+
 
+
<font>'''(previousError-currentError) / previousError '''</font>
+
 
+
where <font>previousError</font> is the error measured before starting an iteration and currentError is the error measured after completing an iteration. The error being measured here depends on the particular cost function selected.
+
 
+
''Maximum Number of Iterations:'' If the convergence limit is not satisfied after this many iterations have been executed, then the registration terminates. The range of possible values is 1 to 100.
+
 
+
<div style="color: #000000;  font-size: 9pt; font-style: normal; font-weight: normal; margin-bottom: 5pt; margin-left: 0pt; margin-right: 0pt; margin-top: 9pt; text-align: left; text-decoration: none; text-indent: 0pt; text-transform: none; vertical-align: baseline">
+
 
+
==== Output files ====
+
 
+
After the B-spline registration algorithm finishes running, the following files can be found in the image directory:
+
 
+
* the source and target image,
+
* the *.xmp files with the recorded history for both source and target images,
+
* the NonLinear Transformation (*.nlt) file that contains the information about the performed B-spline transformation, such as the dimensionality of the transformed image, the degree of the B-spline, the number of control points, and the values of the control points. This file is used for the Transform Nonlinear algorithm, refer to [TransformNonlinear.html#wp999048 "Transform Nonlinear"],
+
* the result file.
+
 
+
=== Class implementation for MIPAV ===
+
 
+
The following classes are part of the <font>mipav/model/structures</font> package:
+
 
+
* B-splineBasis
+
* B-splineBasisDiscretef
+
* BSplineLattice2Df
+
* BSplineLattice3Df
+
* BSplineRegistrationBasef
+
* fBSplineRegistration2Df
+
 
+
The following classes are also part of the <font>mipav/model/algorithms</font>/registration package:
+
 
+
* AlgorithmRegBSpline
+
* AlgorithmRegBSpline2D
+
* AlgorithmRegBSpline3D
+
* AlgorithmRegBSpline25D
+
  
----
+
*[[User Dialogs in MIPAV | B-Spline Automatic Registration Dialog]]
  
{| width="100%"
+
== See also ==
| valign="top" |
+
**[[Optimized automatic registration 3D]]
 +
**[[Registration: Landmark-Least Squares]]
 +
**[[Registration: Landmark-TPSpline]]
 +
**[[Registration: Manual 2D Series]]
 +
**[[Registration: Time Series Optimized Automatic Registration]]
  
| align="right" | '''<font size="2" color="#800080" face="Verdana">Imaging Sciences Laboratory, CIT, NIH<br /> Matthew McAullife, Ph.D.<br /> mcmatt@exchange.nih.gov<br /> 301-594-2432<br /> Building 12A, Room 2041,<br /> 9000 Rockville Pike, Bethesda, MD 20892</font>'''<br />
+
[[Category:Help]]
|}
+
[[Category:Help:Algorithms]]

Latest revision as of 18:14, 9 May 2012

This chapter describes the B-spline based registration of images in three dimensions (3D). The description specializes to two dimensions (2D) is in the obvious manner. Chapter is continued on the following pages:

  • B-Spline Automatic Registration - you are here

Class implementation for MIPAV

The following classes are part of the mipav/model/structures package:

  • B-splineBasis
  • B-splineBasisDiscretef
  • BSplineLattice2Df
  • BSplineLattice3Df
  • BSplineRegistrationBasef
  • fBSplineRegistration2Df

The following classes are also part of the mipav/model/algorithms/registration package:

  • AlgorithmRegBSpline
  • AlgorithmRegBSpline2D
  • AlgorithmRegBSpline3D
  • AlgorithmRegBSpline25D

Background

Let the target image have dimensions <math> (p_o)\,(p_o)\,(p_o) </math> with image indices satisfying <math> 0\le j_0<p_0 </math>, <math> 0\le j_1<p_1 </math>, and <math> 0\le j_2<p_2 </math>. Let the source image have dimensions <math> (q_o)\,(q_o)\,(q_o) </math> with image indices satisfying <math> 0\le k_0<q_0 </math>, <math> 0\le k_1<q_1 </math>, and <math> 0\le k_2<q_2 </math>. The B-spline volume function maps indices <math> j_0,j_1,j_2 </math> via equation 1.

Equation 1
<math>

M_{j_0, j_1, j_2} = \sum_{i_0=0}^{n_o} \left( N_{i_0},d_0,\frac{j_0}{p_0-1} \sum_{i_1=0}^{n_1} \left( N_{i_1}, \frac{j_1}{p_1-1} \sum_{i_2=0}^{n_2} N_{i_2}, d_2, \frac{j_2}{p_2-1}, B_{i_0, i_1, i_2} \right) \right)


</math>

where the <math> N_{i_e, d_e}(u) </math> functions are the B-spline basis functions, and the B values are the control points. The numbers <math>

n_0,n_1,</math> and  <math> n_2 </math>, are user selectable, the degrees 

<math>

d_0,d_1,</math> and  <math> d_2

</math> for the basis functions are user selectable, and the B-spline basis functions are open and uniform.

The control points have the following characteristics:

  • Each control point has coordinates from the unit cube. In two dimensions, each control point has coordinates from the unit square.
  • The initial placement of the control points depends on the B-spline basis and must yield the identity function; that is,

<math>

M_{j_0j_1j_2} = (\frac {j_0} {p_0-1}), (\frac{j_1} {p_1-1}), (\frac {J_2)} {P_2+1})

</math>. The initial placement of the control points is described in Section "Improving performance".

  • A control point is said to be in the outer layer if one of its indexes is either the minimum index (zero) or the maximum index (one less than the number of control points in a given dimension). The position of the control points in the outer layer are fixed as follows:
Equation 2
<math>

B_0,i_1,i_2 =(0,y_{i_1},z_{i_2}) </math>

<math> B_{i_0}, 0, i_2 = (\chi_{i_0}, 0, z_{i_2}) </math>

<math> B_{i_0}, i_0, 0 = (\chi_{i_0}, y_{i_1}, 0) </math>

<math> B_{n_0-1}, i_1, i_2 = (1, y_{i_1}, z_{i_2}) </math>

<math> B_{i_0},n_1-1, i_2 = (\chi_{i_0}, 1, z_{i_2}) </math>

<math> B_{i_0},i_1, n_2-1 = (\chi_{i_0}, y_{i_1}, 1) </math>


This constraint implies that the <math>

0\le k^\prime_w<q_w </math>' 'for all w.

  • A control point not in the outer layer is said to be an interior control point. The position of the interior control points is constrained such that its movement must not cause any folding in the B-spline transformation. Folding is defined to occur when there is a negative value anywhere in the computed deformation for the current B-spline transformation. The computation of the deformation is described in Section "Deformation". The method by which folding is detected is described in Section "Detect folding".

Each <math>

M_(j_0)(j_1)(j_2)

</math> contains normalized 3D coordinates (i.e., in the unit cube) that identify a location in the source image corresponding to the sample at <math> (j_0,j_1,j_2) </math> in the target image. The <math>

M_(j_0)(j_1)(j_2)

</math> coordinates are related to sample coordinates in the source image by <math>

M_{j_{0}, j_{1}, j_{2}} =\left( \frac {k^\prime_0}{q_0-1}, \frac{k^\prime_1}{q_1-1}, \frac{k^\prime_2}{q_2-1}\right)

</math> where the output indices <math> k^\prime_0, k^\prime_1, k^\prime_2 </math> are considered to be continuous values; that is, they are not necessarily integer valued. If the source image's samples are <math> s_k\_0,k_1,k_2 </math>, where <math> 0\le k^\prime_w < q_w </math> for all w , we need to evaluate the image at the nonintegral values <math> k^\prime_0, k^\prime_1, k^\prime_2 </math>. We can use trilinear interpolation to do this (use bilinear interpolation in the case of two-dimensional (2D) registration). Let <math> k_w= |k^\prime_w| </math>, the largest integer smaller than <math> k^\prime_w </math>. Define <math> \Delta w = k^\prime_w - k_w </math>. The interpolated image value is:

Equation 3
<math> U_0 = (1-\Delta_0)(S_{k_0,k_1,k_2}) + (\Delta_0)(S_{k_0 + 1,k_1,k_2}) </math>

<math> U_1 = (1-\Delta_0)(S_{k_0,k_1+1,k_2} + (\Delta_0)(S_{k_0,k_1 + 1,k_2}) </math>

<math> U_2 = (1-\Delta_0)(S_{k_0,k_1,k_2+1} + (\Delta_0)(S_{k_0+1,k_1,k_2+1}) </math>

<math> U_3 = (1-\Delta_0)(S_{k_0,k_1+1,k_2+1} + (\Delta_0)(S_{k_0+1,k_1+1,k_2+1}) </math>

<math> \nu_0 = (1 - \Delta_1)U_0 + (\Delta_1)(U_1) </math>

<math> \nu_1 = (1 - \Delta_1)U_2 + (\Delta_1)(U_3) </math>

<math> S(\kappa_0, \kappa_1, \kappa_2) = (1- \Delta_2)\nu_0 + (\Delta_2)(\nu_1) </math>

If the target image samples are <math> T_{j_0, j_1, j_2} </math>, where <math> 0 \le j_w < p_w </math> for all w, then the source image S is trilinearly interpolated at <math> (k^\prime_0,k^\prime_1, k^\prime_2) </math>, which are the coordinates of <math>

M_(j_0)(j_1)(j_2)

</math>. This means that the currently registered source image, denoted BSplineRegistrationOV withMath57.jpg, has the same dimensions as the target image and can be defined in terms of the target image samples as <math> S^\prime(j_0,j_1,j_2) = S(k^\prime_0,k^\prime_1, k^\prime_2) </math>. A measure of error between the two images Sj0,j1,j2 and Tj0,j1 ,j2 can be computed. A number of possible error measure functions are defined in Section 1.2. The goal is to select the control point positions to make the error measure as small as possible. This is done by moving a single control point at a time using gradient descent.

The gradient of the error function is estimated for the control point Bi0,i1,i2 by means of finite differences, where changes in the error function are measured for small steps of the control point from its current position in each of the coordinate axis directions. Let BSplineRegistrationOV withMath59.jpg, BSplineRegistrationOV withMath60.jpgand BSplineRegistrationOV withMath61.jpg be small step sizes equivalent to one sample increment in the target image,

Equation 4
<math>

\left( \Delta x = \frac{1} {p_0} \right),\left( \Delta y = \frac{1} {p_1} \right),\left( \Delta z = \frac{1} {p_2} \right)

</math>

The gradient of the error function is estimated at each control point Bi0,i1,i2. The gradient at each control point is denoted by

Equation 5




<math>

\triangledown E(i_0,i_1,i_2) = \left ( \frac {E \left ( i_0+ \Delta x, i_1,i_2 \right ) - E \left (i_0 - \Delta x,i_1,i_2 \right )} {2\Delta x} \right ) , \left ( \frac {E \left ( i_0i_1 + \Delta y, i_2 \right ) - E \left (i_0i_1 - \Delta y,i_2 \right )} {2\Delta y} \right ), \left ( \frac {E \left ( i_0i_1i_2 + \Delta z \right ) - E \left (i_0i_1i_2 - \Delta z \right )} {2\Delta z} \right )

</math>

The gradient descent step is as follows. The current control point under consideration is Bi0,i1,i2. The ray originating at this point and having direction of greatest decrease in E is

Equation 6
<math>

B ^\backprime {i_0,i_1,i_2} (t) = B^\backprime {i_0,i_1,i_2} +tD

</math>

where the direction is the unit length vector

<math>

D = \frac {\triangledown E(i_0,i_1,i_2)} {|\triangledown E(i_0,i_1,i_2)|}

</math>

and where BSplineRegistrationOV withMath66.jpg is computed using equation 5. The idea is to choose t > 0 to minimize

<math>

e(t) = E (B^\backprime i_0i_1i_2 (t))

</math>

A calculus approach which sets the first derivative to zero and solves for t yields an expression for e(t) that is really complicated. Instead, you should choose a set of t-values, t'1 through t'm, evaluate e(t'i') and find the minimum value. Suppose this occurs at t'k. Replace this in equation 6 to obtain the new location for the control point.

Only those t-values which do not result in the occurrence of folding in the B-spline transformation are considered. The method described in Section "Detect folding" is used to determine if folding occurs for a given set of control point positions. Note that sample t0 (i.e., t=0) is equivalent to the location of the control point before any movement attempt, and by definition, sample t0 does not cause folding. A test is made to determine whether folding occurs for tm, the extreme sample in the set of chosen t-values. If folding does not occur at tm, then folding does not occur at any of the other t-values between t0 and tm. If folding does occur at tm, then a bisection method is employed to find the tf old value between t0 and tm where folding begins to occur. The search for a minimum value of e(t) by sampling must be limited to the t < t'f old.

Error measures

All of the error measures between two images defined in this section assume that the two images have the same dimensions. This is the case for the target image T (j0,j1,j2) and registered source image S (j0,j1,j2) = S(k0,k1,k2).

The particular error measures defined here are only concerned with corresponding samples from the two images or histograms of the values of the samples from the two images, and are not concerned with whether the images have two or three dimensions. For simplicity, each image measure will be defined with a single index to access its samples.

For more information, refer to Cost functions used in MIPAV algorithms.

Least squares measure

The least squares measure is defined by

Equation 7
<math>

E_{LS} = \sum_{j}{|S^\prime(j) - T(j)|}^2

</math>

where the summation is over all the indices for the target image voxels.

Here, S'`(j) is a registered source image and T(j) is a target image. The minimum value of this measure is zero; the maximum value depends on the range of values in the target and registered source images.

For more information, refer to Cost functions used in MIPAV algorithms.

Correlation ratio measure

See also: Cost functions used in MIPAV algorithms. The correlation ratio measure is defined by

Equation 8
<math>

E_{CR}= \frac {\sum_{k} \frac {n_k} {N} Var (S^\prime _k)} {Var (S)}

</math>

where

  • Var(S) is the variance of the registered source image S.
  • k is the number of intensity histogram bins equally distributed over the range of intensity values of the target image T.
  • S'k'' is the k-th isoset defined as the set of intensities in registered source image S' at positions where the intensity in target image T is in the k-th intensity bin.
  • nk is the number of elements in the set Sk, such that N =Sk ''n'k.
  • N is the number of samples in the target image T which is the same number of samples in the registered source image S'.
  • Var(Sk) is the variance of the values in the set Sk.

The range of values for this measure is [0,1].

Normalized mutual information measure

The normalized mutual information measure is defined by

Equation 9
<math>

E_{NMI} = \frac {H(S^\prime, T)} {H(S^\prime) + H(T)}

</math>

where

<math>

H(S^\prime, T)= -\sum_{i,j}p_{i,j}log p_{i,j}

</math>

is the standard entropy definition for probability pij estimated using the (i,j) joint histogram bins, and similarly for the marginals H(S') and H(T).

The standard entropy calculation

<math>

H(S^\prime, T)= -\sum_{k}p_{k}log p_{k}

</math>

for an image X of N samples and user-selectable k histogram intensity bins equally distributed over the range of samples in image X can be rewritten as

<math> H(X) = -\sum_{k} \frac {n_k} {N} log \left ( \frac {n_k} {N} \right )

</math>

where nk is the histogram value for the k-th intensity bin and N =S k nk. The computational effort can be reduced by factoring to get

<math>

H(X) = \left ( \frac{-1}{N} \right ) \sum_{k} n_K (logn_k -log N)

</math>

where log n'k can be a precomputed lookup table of logarithms of integer values.

The range of values for this measure is [0,1].

For more information, refer to Cost functions used in MIPAV algorithms.

Improving performance

The gradient descent applied to a control point at a time can be quite slow. Performance can be improved by taking advantage of the local control aspect of using B-splines. Since only one control point is being moved at a time, the local control aspect of using B-splines means that only some of the registered source image values will be different. Note that for an image of a given size, the number of image values, under local control, affected by moving a control point decreases as the number of control points increases.

One performance improvement can be achieved by precomputing the B-spline basis function values once for each possible sample for each dimension. Since the registration occurs by transforming the source image into the space of the target image, all samples for B-spline basis function evaluation always occur at the discrete sample coordinates for the target image. Since the number of target images samples for a dimension is xed, the B-spline basis function will be evaluated on the [0, 1] interval at equally spaced intervals (we are using open, uniform B-splines). For each dimension, a 2D array is created which stores B-splines basis function evaluations for each sample with the weight associated with each control point. Because of local control, many of these weights will be zero indicating that a sample is not affected by a particular control point. In the process of creating this 2D array of precomputed basis function evaluations, the index range of samples affected by each control point can be determined. The algorithm to determine this range does not examine the weights as they are computed; instead, the range of control points affecting a single sample are determined from the computed knot index and the known B-spline degree.

Another performance improvement involves maintaining intermediate error measure calculations. For example, in the case of the least squares error measure, an image is maintained of the current error calculations, that is, the target image subtracted from the current registered source image. A cumulative total error value is also maintained, which is the sum of the squared error values for all current values in the error image. When a control point is moved, the old values that are being replaced are first subtracted from the total error, and then the new values to be stored are added to the total error. Similar approaches are performed for the correlation ratio and normalized mutual information error measures such as storing cumulative histogram values and images which contain predetermined histogram bin indexes.

Initial placement of control points for identity map

Referring to equation 1 for the definition of the B-spline mapping function, the identity map is the one which yields


<math>
M_{j_0j_1j_2} = (\frac {j_0} {p_0-1}), (\frac{j_1} {p_1-1}), (\frac {J_2)} {P_2+1})
</math>.

This section describes how to initially place the control points to yield this identity map. Since a separate set of B-spline basis functions is defined for each dimension, it happens that the placement of the control points to provide this identity map is computed independently for each dimension. This means that the x-coordinate for each control point initially is determined by the B-spline basis defined for the X-axis, and similarly for other dimensions.

Let k be the coordinate for which the control point identity map is being computed for the associated B-spline basis. Let nk be the number of control points defined for that B-spline basis. Let ik be the index of the control point coordinate such that 0<= ik <= nk. The goal is to compute the coordinate values Bik for all ik where each coordinate value is in the [0,1] range.

For a B-spline basis of degree 1, the initial placement of the control points for the identity map is such that the control point coordinates are uniformly spaced as follows:

Equation 10
<math>

B_{i_k} = \frac {i_k} {n_k}

</math>

for coordinate k. If the problem is to register images of three dimensions, and the B-spline bases for all three dimensions are selected to have degree 1, then

Equation 11
<math>

B_{i_0, i_1, i_2} = \left ( \frac {i_0}{n_0}, \frac {i_1} {n_1}, \frac {i_2} {n_2} \right )

</math>

For a B-spline basis of degree 2 or larger, the initial placement of the control point coordinates is computed by the method of least squares. Again referring to equation 2 for the definition of the B-spline mapping function, the identity map for coordinate k is

<math>

\frac {j_k}{p_k-1} = \sum_{i_k=0} ^{n_k}N_{i_k,d_k} \left ( \frac {j_k}{p_k-1} \right ) B_{i_k}

</math>

for any target image coordinate jk satisfying 0<= jk <pk.

A system of pk equations above for nk 1 unknowns (i.e., the Bik coordinate values) is set up in a matrix form AX = C, where

<math>

\left ( X_i = B_{i_k} \right ), \left (A_{ji}=N_{i_k,d_k} \left ( \frac {j_k} {p_k-1} \right) \right ),\left (C_j = \frac {j_k} {p_k-1} \right )

</math>

The solution is computed as

<math> X = (A^TA)^{-1}A^TC

</math>

The repositioning of the control points to yield this identity map is guaranteed not have create folding in the resulting transformation.

Composition for two-pass registration

Let S be a source image and T be the target image. If the image S is registered to image T, then image S becomes the registered source image where R(T) is the registration mapping. This is graphically shown as:

BSplineComposition1.png

For B-spline registration, the R(T) mapping is based on the selected B-spline basis and control points for each axis.

In the case of two-pass registration, the registered source image S' is then registered to the same target image T, but this time using different mapping parameters, i.e., a different set of B-spline basis and control points for the axes. The output of this second registration is a new registered source image S". Let R'1'(T) be the mapping for the first pass registration and R'2'(T) be the mapping for the second pass registration. This is graphically shown as:

BSplineComposition2.png

The usefulness of a two-pass registration is that the first pass would apply a coarse-level computation to quickly arrive at an approximate registration, and then the second pass would apply a finer-level computation to continue from the point where the first pass registration finished. The first pass registration may use B-spline bases with fewer control points and a smaller degree.

Although the two-pass registration can be performed in the manner just described, it is desirable to have a final registration between the original source image S and the target image T.

This means defining a mapping R(T) having the same B-spline bases as the second pass registration mapping R'2'(T), but which maps the original source image S into the final registered source image S. This is graphically shown as:

BSplineComposition3.png

The R(T) mapping for the second pass in a two-pass registration is different in that the initial placement of the control points does not yield the identity map to the original source image S.

Instead, the initial placement of the control points for R(T) yields the output of the R'1'(T) mapping. This is achieved by initializing the R'2'(T) registration mapping in the normal manner which provides an initial placement of its control points to yield the identity map from the registered source image S. The initial placement of the control points for the R(T) mapping then are the initial placement of the control points for R'2'(T) mapped through R'1'(T).

Deformation

The deformation from the nonlinearly registered source image S to the target image T can be measured at each sample in the target image by computing the determinant of the Jacobian matrix for the nonlinear transformation. For three dimensions, the nonlinear registration transformation is defined by Equation 1. Since each Mj0j1j2 contains normalized 3D coordinates of the position in the source image mapped for each (j0, j1, j2) in the target image, a map image of 3D coordinates can be created that contains these Mj0j1j2 source images coordinates (this map image has the same dimensions as the target image). An estimate of the gradient at each sample in this map image is computed using central finite differences at interior samples and forward/backward finite differences at "outer layer" samples. Since each sample in the map image contains 3D coordinates, the estimated gradient at each sample then is a 3x3 matrix of values representing the Jacobian matrix. A single-valued deformation image with the same dimensions as the target image is created which contains the computed determinants of the Jacobian matrices for each sample.

If no deformation has occurred at a sample, the Jacobian matrix is the identity and its determinant is 1. If the source image is compressed near a sample, the determinant will be less than one. If the source image is expanded near a sample, the determinant will be greater than one. The computation of deformation is unaffected by differences in the dimensions for the source and target images. Because of the constraints on the placement of the control points, a negative determinant should not be possible, which would indicate some type of folding in the mapping.

Next

  • B-Spline Automatic Registration - you are here

See also