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