Add regression verification script
[ctsim.git] / doc / ctsim-concepts.tex
1 \chapter{Concepts}
2 \setheader{{\it CHAPTER \thechapter}}{}{}{\ctsimheadtitle}{}{{\it CHAPTER \thechapter}}
3 \ctsimfooter
4
5 \section{Conceptual Overview}\index{Conceptual overview}
6 The operation of \ctsim\ begins with the phantom object.  A
7 phantom object consists of geometric elements.  A scanner is
8 specified and the collection of x-ray data, or projections, is
9 simulated. This projection data can be reconstructed using various
10 user-controlled algorithms producing an image of the phantom
11 object. These reconstructions can be visually and statistically
12 compared to the original phantom object.
13
14 In order to use \ctsim\ effectively, some knowledge of how
15 \ctsim\ works and the approach taken is required. \ctsim\ deals with a
16 variety of object, but the two primary objects that we need to be
17 concerned with are the \helprefn{phantom}{conceptphantom} and the
18 \helprefn{scanner}{conceptscanner}.
19
20 \section{Phantoms}\label{conceptphantom}
21
22 \ctsim\ uses geometrical objects to describe the object being
23 scanned. A phantom is composed of one or more phantom elements.
24 These elements are simple geometric shapes, specifically,
25 rectangles, triangles, ellipses, sectors and segments. With these
26 elements, the standard phantoms used in the CT literature can be
27 constructed.  In fact, \ctsim\ provides a shortcut to load the
28 published phantoms of Herman\cite{HERMAN80} and
29 Shepp-Logan\cite{SHEPP74}. \ctsim\ also reads text files of
30 user-defined phantoms.
31
32 The types of phantom elements and their definitions are taken with
33 permission from G.T. Herman's publication\cite{HERMAN80}.
34
35 \subsection{Phantom File}\label{phantomfile}\index{Phantom!File syntax}
36 Each line in the text file describes an element of the
37 phantom.  Each line contains seven entries, in the following form:
38 \begin{verbatim}
39 element-type cx cy dx dy r a
40 \end{verbatim}
41 The first entry defines the type of the element, either
42 \texttt{rectangle}, \texttt{ellipse}, \texttt{triangle},
43 \texttt{sector}, or \texttt{segment}.
44
45 For all phantom elements, \texttt{r} is the rotation applied to the object in degrees
46 counterclockwise and \texttt{a} is the X-ray attenuation
47 coefficient of the object. Where objects overlap, the attenuations
48 of the overlapped objects are summed.
49
50 As opposed to the \texttt{r} and \texttt{a} fields, the \texttt{cx},
51 \texttt{cy}, \texttt{dx} and \texttt{dy} fields have different
52 meanings depending on the element type.
53
54
55
56 \subsection{Phantom Elements}\label{phantomelements}\index{Phantom!Elements}
57
58 \subsubsection{ellipse}
59 Ellipses use \texttt{dx} and \texttt{dy} to define the semi-major and
60 semi-minor axis lengths with the center of the ellipse at \texttt{(cx,cy)}.
61 Of note, the commonly used phantom described by
62 Shepp and Logan\cite{SHEPP74} uses only ellipses.
63
64 \subsubsection{rectangle}
65 Rectangles use \texttt{(cx,cy)} to define the position of
66 the center of the rectangle with respect to the origin.  \texttt{dx}
67 and \texttt{dy} are the half-width and half-height of the rectangle.
68
69 \subsubsection{triangle}
70 Triangles are drawn with the center of the base at \texttt{(cx,cy)}
71 and a base half-width of \texttt{dx} and a height of \texttt{dy}.
72 Rotations are then applied about the center of the base.
73
74 \subsubsection{segment}
75 Segments are complex. They are the portion of an circle between a
76 chord and the perimeter of the circle.  \texttt{dy} sets the
77 radius of the circle. Segments start with the center of the chord
78 located at \texttt{(0,0)} and the chord horizontal. The half-width
79 of the chord is set by \texttt{dx}.  The portion of an circle
80 lying below the chord is then added. The imaginary center of this
81 circle is located at \texttt{(0,-dy)}. The segment is then rotated
82 by \texttt{r} and then translated by \texttt{(cx,cy)}.
83
84 \subsubsection{sector}
85 Sectors are the like a ``pie slice'' from a circle. The radius of
86 the circle is set by \texttt{dy}. Sectors are defined similarly to
87 segments. In this case, though, a chord is not drawn.  Instead,
88 the lines are drawn from the origin of the circle \texttt{(0,-dy)}
89 to the points \texttt{(-dx,0)} and \texttt{(dx,0)}. The perimeter
90 of the circle is then drawn between those two points and lies
91 below the x-axis. The sector is then rotated and translated the
92 same as a segment.
93
94 \subsection{Phantom Size}\index{Phantom!Size}
95 The overall dimensions of the phantom are increased by 1\% above the
96 specified sizes to avoid clipping due to round-off errors from
97 sampling the polygons of the phantom elements.  So, if the phantom is
98 defined as a rectangle of size 0.1 by 0.1, the phantom size is
99 0.101 in each direction.
100
101 \section{Scanner}\label{conceptscanner}\index{Scanner!Concepts}%
102 Understanding the scanning geometry is the most complicated aspect of
103 using \ctsim. For real-world CT simulators, this is actually quite
104 simple. The geometry is fixed by the manufacturer during the
105 construction of the scanner and can not be changed. \ctsim,
106 being a very flexible simulator, gives tremendous options in
107 setting up the geometry for a scan.
108
109 \subsection{Dimensions}
110 The geometry for a scan starts with the size of
111 the phantom being scanned. This is because \ctsim\ allows for
112 statistical comparisons between the original phantom image and
113 it's reconstructions. Since CT scanners scan a circular area, the
114 first important variable is the diameter of the circle surround
115 the phantom, the \emph{phantom diameter}. Remember, as mentioned
116 above, the phantom dimensions are padded by 1\%.
117
118 The other important geometry variables for scanning phantoms are
119 the \emph{view diameter}, \emph{scan diameter}, \emph{focal
120 length}, and \emph{center-detector length}. These variables are input into \ctsim\ in terms of
121 ratios rather than absolute values.
122
123 \subsubsection{Phantom Diameter}\index{Phantom!Diameter}
124 The phantom diameter is automatically calculated by \ctsim\ from
125 the phantom definition. The maximum of the phantom length and
126 height is used to define the square that completely surrounds the
127 phantom. Let \latexonly{$p_l$}\latexignore{\emph{Pl}} be the width
128 and height of this square. The diameter of this boundary box,
129 \latexonly{$p_d$,}\latexignore{\emph{Pd},} is given by the
130 Pythagorean theorem and is
131 \latexignore{\\\centerline{\emph{Pl x sqrt(2)}}\\}
132 \latexonly{\begin{equation}p_d = p_l \sqrt{2}\end{equation}}
133 CT scanners collect projections around a
134 circle rather than a square. The diameter of this circle is
135 the diameter of the boundary square \latexonly{$p_d$.}
136 \latexignore{\emph{Pd}.}
137 \latexonly{These relationships are diagrammed in figure~\ref{phantomgeomfig}.}
138 \begin{figure}
139 \centerline{\image{8cm;0cm}{scangeometry.eps}}
140 \latexonly{\caption{\label{phantomgeomfig} Phantom Geometry}}
141 \end{figure}
142
143 \subsubsection{View Diameter}\index{View diameter}
144 The \emph{view diameter} is the area that is being processed
145 during scanning of phantoms as well as during rasterization of
146 phantoms. By default, the \emph{view diameter} is set equal
147 to the \emph{phantom diameter}. It may be useful, especially for
148 experimental reasons, to process an area larger (and maybe even
149 smaller) than the phantom. Thus, during rasterization or during
150 projections, \ctsim\ will ask for a \emph{view ratio},
151 \latexonly{$v_r$.}\latexignore{\rtfsp \emph{VR}.} The \emph{view
152 diameter} is then calculated as
153 \latexonly{\begin{equation}v_d = p_dv_r\end{equation}}
154 \latexignore{\\\centerline{\emph{Vd = Pd x VR}}\\}
155
156 By using a
157 \latexonly{$v_r$}\latexignore{\emph{VR}}
158 less than 1, \ctsim\ will allow
159 for a \emph{view diameter} less than
160 \emph{phantom diameter}.
161 This will lead to significant artifacts. Physically, this would
162 be impossible and is analogous to inserting an object into the CT
163 scanner that is larger than the scanner itself!
164
165 \subsubsection{Scan Diameter}\index{Scan diameter}
166 By default, the entire \emph{view diameter} is scanned. For
167 experimental purposes, it may be desirable to scan an area either
168 larger or smaller than the \emph{view diameter}. Thus, the concept
169 of \emph{scan ratio}, \latexonly{$s_r$,}\latexignore{\emph{SR},}
170 arises. The scan diameter,
171 \latexonly{$s_d$,}\latexignore{\emph{Sd},} is the diameter over
172 which x-rays are collected and is defined as
173 \latexonly{\begin{equation}s_d =v_d s_r\end{equation}}
174 \latexignore{\\\centerline{\emph{Sd = Vd x SR}}\\}
175 By default and
176 for all ordinary scanning, the \emph{scan ratio} is to \texttt{1}.
177 If the \emph{scan ratio} is less than \texttt{1}, you can expect
178 significant artifacts.
179
180 \subsubsection{Focal Length}\index{Focal length}
181 The \emph{focal length},
182 \latexonly{$f$,}\latexignore{\emph{F},}
183 is the distance of the X-ray source to the center of
184 the phantom. The focal length is set as a ratio,
185 \latexonly{$f_r$,}\latexignore{\emph{FR},}
186 of the view radius. Focal length is
187 calculated as
188 \latexonly{\begin{equation}f = (v_d / 2) f_r\end{equation}}
189 \latexignore{\\\centerline{\emph{F = (Vd / 2) x FR}}}
190
191 For parallel geometry scanning, the focal length doesn't matter.
192 However, for divergent geometry scanning (equilinear and equiangular),
193 the \emph{focal length ratio} should be set at \texttt{2} or more
194 to avoid artifacts. Moreover, a value of less than \texttt{1} is
195 physically impossible and it analagous to having the x-ray
196 source inside of the \emph{view diameter}.
197
198 \subsubsection{Center-Detector Length}\index{Center-Detector length}
199 The \emph{center-detector length},
200 \latexonly{$c$,}\latexignore{\emph{C},}
201 is the distance from the center of
202 the phantom to the center of the detector array. The center-detector length is set as a ratio,
203 \latexonly{$c_r$,}\latexignore{\emph{CR},}
204 of the view radius. The center-detector length is
205 calculated as
206 \latexonly{\begin{equation}f = (v_d / 2) c_r\end{equation}}
207 \latexignore{\\\centerline{\emph{F = (Vd / 2) x CR}}}
208
209 For parallel geometry scanning, the center-detector length doesn't matter.
210 A value of less than \texttt{1} is physically impossible and it analagous to
211 having the detector array inside of the \emph{view diameter}.
212
213
214 \subsection{Parallel Geometry}\label{geometryparallel}\index{Parallel geometry}\index{Scanner!Parallel}
215
216 The simplest geometry, parallel, was used in first generation
217 scanners. As mentioned above, the focal length is not used in this simple
218 geometry. The detector array is set to be the same size as the
219 \emph{scan diameter}.  For optimal scanning in this geometry, the
220 \emph{scan diameter} should be equal to the \emph{phantom
221 diameter}. This is accomplished by using the default values of
222 \texttt{1} for the \emph{view ratio} and the \emph{scan ratio}. If
223 values of less than \texttt{1} are used for these two variables,
224 significant distortions will occur.
225
226
227 \subsection{Divergent Geometries}\label{geometrydivergent}\index{Equilinear geometry}\index{Equiangular geometry}
228 \index{Scanner!Equilinear}\index{Scanner!Equiangular}
229 For both equilinear (second generation) and equiangular
230 (third, fourth, and fifth generation) geometries,
231 the x-ray beams diverge from a single source to a detector array.
232 In the equilinear mode, a single
233 source produces a fan beam which is read by a linear array of detectors.  If
234 the detectors occupy an arc of a circle, then the geometry is equiangular.
235 \latexonly{These configurations are shown in figure~\ref{divergentfig}.}
236 \begin{figure}
237 \centerline{\image{10cm;0cm}{divergent.eps}}
238 \latexonly{\caption{\label{divergentfig} Equilinear and equiangular geometries.}}
239 \end{figure}
240
241
242 \subsubsection{Fan Beam Angle}\index{Fan beam angle}
243 For these divergent beam geometries, the \emph{fan beam angle}
244 needs to be calculated. For real-world CT scanners, this is fixed
245 at the time of manufacture. \ctsim, however, calculates the
246 \emph{fan beam angle}, $\alpha$, from the \emph{scan diameter} and
247 the \emph{focal length} as
248 \latexignore{\centerline{\emph{alpha = 2 x asin (
249 (Sd / 2) / f)}}}
250 \latexonly{\begin{equation}\label{alphacalc}\alpha = 2 \sin^{-1}
251 ((s_d / 2) / f)\end{equation}}
252 \latexonly{This is illustrated in figure~\ref{alphacalcfig}.}
253 \begin{figure}
254 \centerline{\image{10cm;0cm}{alphacalc.eps}}
255 \latexonly{\caption{\label{alphacalcfig} Calculation of $\alpha$}}
256 \end{figure}
257
258
259 Empiric testing with \ctsim\ shows that for very large \emph{fan beam angles},
260 greater than approximately
261 \latexonly{$120^\circ$,}\latexignore{120 degrees,}
262 there are significant artifacts. The primary way to manage the
263 \emph{fan beam angle} is by varying the \emph{focal length} since the
264 \emph{scan diameter} is usually fixed at the size of the phantom.
265
266 To illustrate, the \emph{scan diameter} can be defined as
267 \latexonly{\begin{equation}s_d = s_r v_r p_d\end{equation}}
268 \latexignore{\\\centerline{\emph{Sd = Sr x Vr x Pd}}\\}
269
270 Further, the \emph{focal length} can be defined as
271 \latexonly{\begin{equation} f = f_r (v_r p_d / 2)\end{equation}}
272 \latexignore{\\\centerline{\emph{F = FR x (VR x Pd)$$\\}}}
273
274 Substituting these equations into \latexignore{the above
275 equation,}\latexonly{equation~\ref{alphacalc},} We have,
276 \latexonly{
277 \begin{eqnarray}
278 \alpha &=& 2\,\sin^{-1} \frac{\displaystyle s_r v_r p_d / 2}{\displaystyle f_r v_r (p_d / 2)} \nonumber \\
279 &=& 2\,\sin^{-1} (s_r / f_r)
280 \end{eqnarray}
281 } \latexignore{\\\centerline{\emph{\alpha = 2 sin (Sr / Fr)}}\\}
282
283 Since in normal scanning $s_r$ = 1, $\alpha$ depends only upon the
284 \emph{focal length ratio} in normal scanning.
285
286 \subsubsection{Detector Array Size}
287 In general, you do not need to be concerned with the detector
288 array size -- it is automatically calculated by \ctsim. For the
289 particularly interested, this section explains how the detector
290 array size is calculated.
291
292 For parallel geometry, the detector length is simply the scan
293 diameter.
294
295 For divergent beam geometries, the size of the detector array also
296 depends upon the \emph{focal length}: increasing the \emph{focal
297 length} decreases the size of the detector array.
298
299 For equiangular geometry, the detectors are equally spaced around a arc
300 covering an angular distance of $\alpha$ as viewed from the source. When
301 viewed from the center of the scanning, the angular distance is
302 \latexonly{$$\pi + \alpha - 2 \, \cos^{-1} \Big( \frac{s_d / 2}{c} \Big)$$}
303 \latexignore{\\\emph{pi + \alpha - 2 x acos ((Sd / 2) / C))}\\}
304 The dotted circle
305 \latexonly{in figure~\ref{equiangularfig}}
306 indicates the positions of the detectors in this case.
307
308 \begin{figure}
309 \centerline{\image{10cm;0cm}{equiangular.eps}}
310 \latexonly{\caption{\label{equiangularfig}Equiangular geometry}}
311 \end{figure}
312
313 For equilinear geometry, the detectors are equally spaced along a straight
314 line. The detector length depends upon
315 \latexonly{$\alpha$}\latexignore{\emph{alpha}} and the \emph{focal
316 length}. This length,
317 \latexonly{$d_l$,}\latexignore{Dl,} is calculated as
318 \latexonly{\begin{equation} d_l = 2\,(f + c) \tan (\alpha / 2)\end{equation}}
319 \latexignore{\\\centerline{\emph{2 x (F + C) x tan(\alpha/2)}}}
320 \latexonly{This geometry is shown in figure~\ref{equilinearfig}.}
321 \begin{figure}
322 \centerline{\image{10cm;0cm}{equilinear.eps}}
323 \latexonly{\caption{\label{equilinearfig} Equilinear geometry}}
324 \end{figure}
325
326
327 \section{Reconstruction}\label{conceptreconstruction}\index{Reconstruction overview}%
328
329 \subsection{Direct Inverse Fourier}
330 This method is not currently implemented in \ctsim; however, it is
331 planned for a future release. This method does not give results as
332 accurate as filtered backprojection. This is due primarily
333 to interpolation occurring in the frequency domain rather than the
334 spatial domain.
335
336 \subsection{Filtered Backprojection}\index{Filtered backprojection}\index{Symmetric multiprocessing}\index{SMP}
337 The technique is comprised of two sequential steps:
338 filtering projections followed by backprojecting the filtered projections. Though
339 these two steps are sequential, each view position can be processed independently.
340
341 \subsubsection{Parallel Computer Processing}\index{Parallel processing}
342 Since each view can be processed independently, filtered backprojection is amendable to
343 parallel processing. Indeed, this has been used in commercial scanners to speed reconstruction.
344 This parallelism is exploited both in the \ctsim\ graphical shell and
345 in the \helpref{LAM}{ctsimtextlam} version of \ctsimtext. \ctsim\ can distribute it's workload
346 amongst multiple processors working in parallel.
347
348 The graphical shell will automatically take advantage of multiple CPU's when
349 running on a \emph{Symmetric Multiprocessing}
350 computer. Dual-CPU computers are commonly available which provide a near doubling
351 in reconstruction speeds. \ctsim, though, has no limits on the number of CPU's
352 that can be used in parallel. The \emph{LAM} version
353 of \ctsimtext\ is designed to work in a cluster of computers.
354 This has been testing with a cluster of 16 computers in a
355 \urlref{Beowulf-class}{http://www.beowulf.org} cluster with excellent
356 results.
357
358 \subsubsection{Filter projections}
359 The first step in filtered backprojection reconstructions is the filtering
360 of each projection. The projections for a each view have their frequency data multipled by
361 a filter of $|w|$. \ctsim\ permits four different ways to accomplish this
362 filtering.
363
364 Two of the methods use convolution of the projection data with the
365 inverse Fourier transform of $|w|$. The other two methods perform an Fourier
366 transform of the projection data and multiply that by the $|w|$ filter and
367 then perform an inverse fourier transform.
368
369 Though multiplying by $|w|$ gives the sharpest reconstructions, in
370 practice, superior results are obtained by reducing the higher
371 frequencies. This is performed by mutiplying the $|w|$ filter by
372 another filter that attenuates the higher frequencies. \ctsim\ has
373 multiple filters for this purpose.
374
375 \subsubsection{Backprojection of filtered projections}
376 Backprojection is the process of ``smearing'' the filtered
377 projections over the reconstructing image. Various levels of
378 interpolation can be specified.
379
380 \section{Image Comparison}\label{conceptimagecompare}\index{Image!Comparison}
381 Images can be compared statistically. Three measurements can be calculated
382 by \ctsim. They are taken from the standard measurements used by
383 Herman\cite{HERMAN80}. They are:
384
385 \begin{itemize}\itemsep=0pt
386 \item[]\textbf{$d$}\quad The normalized root mean squared distance measure.
387 \item[]\textbf{$r$}\quad The normalized mean absolute distance measure.
388 \item[]\textbf{$e$}\quad The worst case distance measure over a \latexonly{$2\times2$}\latexignore{\emph{2 x 2}} pixel area.
389 \end{itemize}
390
391 These measurements are defined in equations \ref{dequation} through \ref{bigrequation}.
392 In these equations, $p$ denotes the phantom image, $r$ denotes the reconstruction
393 image, and $\bar{p}$ denotes the average pixel value of $p$. Each of the images have a
394 size of $m \times n$. In equation \ref{eequation} $[n/2]$ and $[m/2]$ denote the largest
395 integers less than $n/2$ and $m/2$, respectively.
396
397 \latexignore{These formulas are shown in the print documentation of \ctsim.}
398 %
399 %Tex2RTF can not handle the any subscripts or superscripts for the inner summation unless
400 % have a space character before the \sum
401 \latexonly{\begin{equation}\label{dequation} d =\sqrt{\frac{\displaystyle \sum_{i=1}^{n}{ \sum_{j=1}^{m}{(p_{i,j} - r_{i,j})^2}}}{\displaystyle \sum_{i=1}^{n}{ \sum_{j=1}^{m}{(p_{i,j} - \bar{p})^2}}}}\end{equation}}
402 \latexonly{\begin{equation}\label{requation}r = \frac{ \displaystyle \sum_{i=1}^{n}{ \sum_{j=1}^{m}{|p_{i,j} - r_{i,j}|}}}{ \displaystyle \sum_{i=1}^{n}{ \sum_{j=1}^{m}{|p_{i,j}|}}}\end{equation}}
403 \latexonly{\begin{equation}\label{eequation}e = \max_{1 \le k \le [n/2] \atop 1 \le l \le [m/2]}(|P_{k,l} - R_{k,l}|)\end{equation}}
404 \latexonly{where}
405 \latexonly{\begin{equation}\label{bigpequation}P_{k,l} = \textstyle \frac{1}{4} (p_{2k,2l} + p_{2k+1,2l} + p_{2k,2l+l} + p_{2k+1,2l+1})\end{equation}}
406 \latexonly{\begin{equation}\label{bigrequation}R_{k,l} = \textstyle \frac{1}{4} (r_{2k,2l} + r_{2k+1,2l} + r_{2k,2l+1} + r_{2k+1,2l+1})\end{equation}}
407 \begin{comment}
408 \end{comment}