r492: no message
[ctsim.git] / doc / ctsim-concepts.tex
1 \chapter{Concepts}\index{Concepts}%
2 \setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
3 \setfooter{\thepage}{}{}{}{}{\thepage}%
4
5 \section{Overview}\label{conceptoverview}\index{Concepts,Overview}%
6 In \ctsim, a phantom object, or a geometrical description of the object
7 of a CT study is constructed and an image can be created.  Then a
8 scanner geometry can be specified, and the projection data simulated.
9 Finally that projection data can be reconstructed using various user
10 controlled algorithms producing an image of the phantom or study object.
11
12 In order to use \ctsim\ effectively, some knowledge of how \ctsim\ works
13 and the approach taken is required. \ctsim\ deals with a variety of
14 object, but the two objects we need to be concerned with are the 'phantom' and
15 the 'scanner'.
16
17 \section{Phantoms}\label{conceptphantom}\index{Concepts,Phantoms}%
18 \subsection{Overview}\label{phantomoverview}\index{Concepts,Phantoms,Overview}%
19
20 \ctsim\ uses geometrical objects to
21 describe the object being scanned. A phantom is composed a one or more
22 phantom elements. These elements are simple geometric shapes,
23 specifically, rectangles, triangles, ellipses, sectors and segments.
24 With these the standard phantoms used in the CT literature (the Herman
25 and the Shepp-Logan) can be constructed.  In fact
26 \ctsim\ provides a shortcut to construct those phantoms for you.  It also
27 allows you to write a file in which the composition of your own phantom is
28 described.
29
30 The types of phantom elements and their definitions are taken from Herman's 1980
31 book\cite{HERMAN80}.
32
33 \subsection{Phantom File}\label{phantomfile}\index{Concepts,Phantoms,File}
34 Each line in the text file describes an element of the
35 phantom.  Each line contains seven entries, in the following form:
36 \begin{verbatim}
37 item cx cy dx dy r a
38 \end{verbatim}
39 The first entry defines the type of the element, one
40 of {\tt rectangle}, {\tt ellipse}, {\tt triangle}, {\tt sector}, or {\tt segment}.
41 {\tt cx}, {\tt cy}, {\tt dx} and {\tt dy} have different meanings depending on the element type.
42
43 {\tt r} is the rotation applied to the object in degrees counterclockwise,
44 and {\tt a} is the X-ray attenuation coefficient of the object.
45 Where objects overlap, the attenuations of the overlapped objects are summed.
46
47
48
49 \subsection{Phantom Elements}\label{phantomelements}\index{Concepts,Phantoms,Elements}
50
51 \subsubsection{ellipse}
52 Ellipses use dx and dy to define the semi-major and semi-minor axis lengths,
53 with the centre of the ellipse at cx and cy.  Of note, the commonly used
54 phantom described by Shepp and Logan\cite{SHEPP74} uses only ellipses.
55
56 \subsubsection{rectangle}
57 Rectangles use
58 cx  and cy to define the position of the centre of the rectangle with respect
59 to the origin.  dx and dy  are the half-width and half-height of the
60 rectangle.
61
62 \subsubsection{triangle}
63 Triangles are drawn with the centre of the base at cx,cy, with a base
64 width of 2*dx in x direction, and a height of dy.  Rotations are then
65 applied about the origin.
66
67 \subsubsection{sector}
68 It appears that dx and dy
69 define the end points of a radius of the sector, from which the radius and
70 the angle of the two arms of the sector are calculated.  But then
71 orientation and centreing of the sector don't make much sense yet.
72
73 \subsubsection{segment}
74 Segments are the segments of a circle between a chord and the
75 perimeter of the circle.  This also isn't clear to me, but it appears that
76 perhaps the distance from chord to circle perimeter, and circle radius is
77 defined by dx and dy. Chord is always horizontal through the origin, then
78 translated and then rotated (???).
79
80 \subsection{Phantom Size}
81 Also note that the overall dimensions of the phantom are increased by 1\%
82 above the specified sizes to avoid clipping due to round-off errors.  If the phantom is defined as
83 a rectangle of size 0.1 by 0.1, the actual phantom has extent $\pm$0.101 in
84 each direction.
85
86 \section{Scanner}\label{conceptscanner}\index{Concepts,Scanner}%
87 \subsection{Geometries}
88 This is where things get tricky.  There are two possible approaches.  The
89 simple approach would be to define the size of a phantom which is put at
90 the centre of the scanner.  The scanner would have it's bore size defined,
91 or perhaps better, the field of view defined. Here, field of view would be
92 the radius or diameter of the circular area from which data is collected
93 and an image reconstructed.  In a real CT scanner, if the object being
94 scanned is larger than the field of view, you get image artifacts.  And of
95 course you can't stuff an object into a scanner if the object is larger
96 than the bore!  In this model, the scanner size or field of view would
97 be used as the standard length scale.
98
99 However, \ctsim\ takes another approach.  I believe this approach arose
100 because the "image" of the phantom produced from the phantom description
101 was being matched to the reconstruction image of the phantom.  That is,
102 the dimensions of the 'before' and 'after' images  were being matched.
103 The code has a Phantom object and a Scanner object.  The geometry of the
104 Scanner is defined in part by the properties of the Phantom.  In fact,
105 all dimensions are determined in terms of the phantom size, which is used
106 as the standard length scale.     Remember, as mentioned above, the
107 phantom dimensions are also padded by 1\%.
108
109 The maximum of the phantom length and height is used as the phantom
110 dimension, and one can think of a square bounding box of this size
111 which completely contains the phantom.  Let $l_p$ be the width (or height)
112 of this square.
113
114 \subsubsection{Focal Length \& Field of View}
115 The two other important variables are the field-of-view-ratio ($f_{vR}$)
116 and the focal-length-ratio ($f_{lR}$).  These are used along with $l_p$ to
117 define the focal length and the field of view (not ratios) according to
118 \latexonly{\begin{equation}
119 f_l = \sqrt{2} (l_p/2)(f_{lR})= (l_p/\sqrt{2}) f_{lR}
120 \end{equation}
121 \begin{equation}
122 f_v = \sqrt{2}l_p f_{vR}
123 \end{equation}}
124 So the field of view ratio is specified in units of the phantom diameter,
125 whereas the focal length is specified in units of the phantom radius.  The
126 factor of
127 \latexonly{$\sqrt(2)$}
128 \latexignore{sqrt(2)}
129 can be understood if one refers to figure 1, where
130 we consider the case of a first generation parallel beam CT scanner.
131
132 \subsubsection{Parallel Geometry}\label{geometryparallel}\index{Concepts,Scanner,Geometries,Parallel}
133 \begin{figure}
134 \includegraphics[width=\textwidth]{ctsimfig1.eps}
135 \caption{Geometry used for a 1st generation, parallel beam CT scanner.}
136 \end{figure}
137
138 In figure 1A, the excursion of the source and detector need only be $l_p$,
139 the height (or width) of the phantom's bounding square. However, if the
140 field of view were only $l_p$, then the projection shown in figure 1B
141 would clip the corners of the phantom.  By increasing the field of view by
142 $\sqrt{2}$ the whole phantom is included in every projection.  Of course,
143 if the field-of-view ratio $f_{vR}$ is larger than 1, there is no problem.
144 However, if $f_{vR}$ is less than one and thus the scanner is smaller than
145 the phantom, then distortions will occur without warning from the program.
146
147 The code also sets the detector length equal to the field of view in this
148 case.  The focal length is chosen to be $\sqrt{2}l_p$ so the phantom will
149 fit between the source and detector at all rotation angles, when the focal
150 length ratio is specified as 1.  Again, what happens if the focal length
151 ratio is chosen less than 1?
152
153 The other thing to note is that in this code the detector array is set to
154 be the same size as the field-of-view $f_v$, equation (2).  So, one has to
155 know the size of the phantom to specify a given scanner geometry with a
156 given source-detector distance (or $f_l$ here) and a given range of
157 excursion ($f_v$ here).
158
159 \subsubsection{Divergent Geometries}\label{geometrydivergent}\index{Concepts,Scanner,Geometries,Divergent}
160 Next consider the case of equilinear (second generation) and equiangular
161 (third, fourth, and fifth generation) geometries.
162 The parts of the code  relevant to this
163 discussion are the same for both modes.  In the equilinear mode, a single
164 source produces a fan beam which is read by a linear array of detectors.  If
165 the detectors occupy an arc of a circle, then the geometry is equiangular.
166 See figure 2.
167 \begin{figure}
168 \includegraphics[width=\textwidth]{ctsimfig2.eps}
169 \caption{Equilinear and equiangular geometries.}
170 \end{figure}
171
172 For these geometries, the following logic is executed:  A variable dHalfSquare
173 $d_{hs}$ is defined as
174 \latexonly{\begin{equation}
175 d_{hs} = (f_v)/(2\sqrt{2}) = (l_p/2) f_{vR}
176 \end{equation}}
177 This is then subtracted from the focal length $f_l$ as calculated above, and
178 assigned to a new variable $\mathrm{dFocalPastPhm} = f_l - d_{hs}$.  Since $f_l$ and
179 $d_{hs}$ are derived from the phantom dimension and the input focal length and field of view ratios, one can write,
180 \latexonly{
181 \begin{equation}
182 \mathrm{dFocalPastPhm} = f_l -d_{hs}
183     = \sqrt{2}(l_p/2) f_{lR} - (l_p/2) f_{vR} = l_p(\sqrt{2}f_{lR} - f_{vR})
184 \end{equation}
185 }
186 If this quantity is less than or equal to zero, then at least for some
187 projections  the source is inside the phantom.  Perhaps a figure will help at
188 this point. Consider first the case where $f_{vR} = f_{lR} =1 $, figure 3. The
189 square in the figure bounds the phantom and has sides $l_p$.  For this case
190 then,
191 \latexonly{
192 \[
193 f_l=\sqrt{2}l_p/2 = l_p/\sqrt{2},
194 \]
195 \[
196 f_v = \sqrt{2}l_p,
197 \]
198 and
199 \[
200 d_{hs} = {l_p}/{2}.
201 \]
202 Then
203 \[
204 \mathrm{dFocalPastPhm} = ({l_p}/{2}) (\sqrt{2}-1)
205 \]
206 }
207 \begin{figure}
208 \includegraphics[height=0.5\textheight]{ctsimfig3.eps}
209 \caption{Equilinear and equiangluar geometry when focal length ratio =
210 field of view ratio = 1.}
211 \end{figure}
212 The angle $\alpha$ is now defined as shown in figure 3, and the detector
213 length is adjusted to subtend the angle $2\alpha$ as shown.  Note that the
214 size of the detector array may have changed and the field of view is not
215 used.
216 For a circular array of detectors, the detectors are spaced around a
217 circle covering an angular distance of $2\alpha$.  The dotted circle in
218 figure 3 indicates the positions of the detectors in this case. Note that
219 detectors at the ends of the range would not be illuminated by the source.
220
221 Now, consider increasing the focal length ratio to two leaving the
222 field of view ratio as 1,  as in  Figure 4.  Now the detectors array is
223 denser, and the real field of view is closer to that specified, but note
224 again that the field of view is not used. Instead, the focal length is
225 used to give a distance from the centre of the phantom to the source, and
226 the detector array is adjusted to give an angular coverage to include the
227 whole phantom.
228 \begin{figure}
229 \includegraphics[width=\textwidth]{ctsimfig4.eps}
230 \caption{Equilinear and equiangluar geometry when focal length ratio = 2
231 and the field of view ratio = 1.}
232 \end{figure}
233 Now consider a focal length ratio of 4 (figure 5). As expected, the angle
234 $\alpha$ is smaller still.  The dotted square is the bounding square of
235 the phantom rotated by 45 degrees, corresponding to the geometry of a
236 projection taken at that angle.  Note that the fan beam now clips the top
237 and bottom corners of the bounding square.  This illustrates that one may
238 still be clipping the phantom, despite \ctsim\'s best efforts.  You have
239 been warned.
240 \begin{figure}
241 \includegraphics[width=\textwidth]{ctsimfig5.eps}
242 \caption{Equilinear and equiangluar geometry when focal length ratio = 4.}
243
244 \end{figure}
245
246
247 \section{Reconstruction}\label{conceptreconstruction}\index{Concepts,Reconstruction}%
248 \subsection{Overview}
249 \subsection{Filtered Backprojection}
250 \subsection{Direct Inverse Fourier}
251 This method is not currently implemented in \ctsim, however it is planned for a
252 future release. This method does not give as accurate result as filtered
253 backprojection mostly due to interpolation occuring in the frequency domain rather
254 than the spatial domain. The technique is comprised of two sequential steps:
255 filtering projections and then backprojecting the filtered projections. Though
256 these two steps are sequential, each view position can be processed individually.
257 This parallelism is exploited in the MPI versions of \ctsim\ where the data from
258 all the views are spread about amongst all of the processors. This has been testing
259 in a 16-CPU cluster with good results.
260
261 \subsubsection{Filter projections}
262 The projections for a single view have their frequency data multipled by
263 a filter of absolute(w). \ctsim\ permits four different ways to accomplish this
264 filtering. Two of the methods use convolution of the projection data with the
265 inverse fourier transform of absolute(x). The other two methods perform an fourier
266 transform of the projection data and multiply that by the absolute(x) filter and
267 then perform an inverse fourier transform.
268
269 \subsubsection{Backprojection of filtered projections}