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