r490: 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 \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 $\sqrt(2)$ can be understood if one refers to figure 1, where
127 we consider the case of a first generation parallel beam CT scanner.
128
129 \subsubsection{Parallel Geometry}\label{geometryparallel}\index{Concepts,Scanner,Geometries,Parallel}
130 \begin{figure}
131 \includegraphics[width=\textwidth]{ctsimfig1.eps}
132 \caption{Geometry used for a 1st generation, parallel beam CT scanner.}
133 \end{figure}
134
135 In figure 1A, the excursion of the source and detector need only be $l_p$,
136 the height (or width) of the phantom's bounding square. However, if the
137 field of view were only $l_p$, then the projection shown in figure 1B
138 would clip the corners of the phantom.  By increasing the field of view by
139 $\sqrt{2}$ the whole phantom is included in every projection.  Of course,
140 if the field-of-view ratio $f_{vR}$ is larger than 1, there is no problem.
141 However, if $f_{vR}$ is less than one and thus the scanner is smaller than
142 the phantom, then distortions will occur without warning from the program.
143
144 The code also sets the detector length equal to the field of view in this
145 case.  The focal length is chosen to be $\sqrt{2}l_p$ so the phantom will 
146 fit between the source and detector at all rotation angles, when the focal
147 length ratio is specified as 1.  Again, what happens if the focal length
148 ratio is chosen less than 1?
149
150 The other thing to note is that in this code the detector array is set to
151 be the same size as the field-of-view $f_v$, equation (2).  So, one has to 
152 know the size of the phantom to specify a given scanner geometry with a 
153 given source-detector distance (or $f_l$ here) and a given range of
154 excursion ($f_v$ here).  
155
156 \subsubsection{Divergent Geometries}\label{geometrydivergent}\index{Concepts,Scanner,Geometries,Divergent}
157 Next consider the case of equilinear (second generation) and equiangular 
158 (third, fourth, and fifth generation) geometries.  
159 The parts of the code  relevant to this
160 discussion are the same for both modes.  In the equilinear mode, a single 
161 source produces a fan beam which is read by a linear array of detectors.  If
162 the detectors occupy an arc of a circle, then the geometry is equiangular.
163 See figure 2. 
164 \begin{figure}
165 \includegraphics[width=\textwidth]{ctsimfig2.eps}
166 \caption{Equilinear and equiangular geometries.}
167 \end{figure}
168
169 For these geometries, the following logic is executed:  A variable dHalfSquare
170 $d_{hs}$ is defined as
171 \begin{equation}
172 d_{hs} = (f_v)/(2\sqrt{2}) = (l_p/2) f_{vR}
173 \end{equation}
174 This is then subtracted from the focal length $f_l$ as calculated above, and 
175 assigned to a new variable $\mathrm{dFocalPastPhm} = f_l - d_{hs}$.  Since $f_l$ and 
176 $d_{hs}$ are derived from the phantom dimension and the input focal length and field of view ratios, one can write, 
177 \begin{equation}
178 \mathrm{dFocalPastPhm} = f_l -d_{hs} 
179         = \sqrt{2}(l_p/2) f_{lR} - (l_p/2) f_{vR} = l_p(\sqrt{2}f_{lR} - f_{vR})
180 \end{equation}
181 If this quantity is less than or equal to zero, then at least for some
182 projections  the source is inside the phantom.  Perhaps a figure will help at
183 this point. Consider first the case where $f_{vR} = f_{lR} =1 $, figure 3. The
184 square in the figure bounds the phantom and has sides $l_p$.  For this case
185 then, 
186 \[ 
187 f_l=\sqrt{2}l_p/2 = l_p/\sqrt{2},
188 \]
189 \[
190 f_v = \sqrt{2}l_p, 
191 \]
192 and 
193 \[
194 d_{hs} = {l_p}/{2}.
195 \]
196 Then 
197 \[
198 \mathrm{dFocalPastPhm} = ({l_p}/{2}) (\sqrt{2}-1)
199 \]
200 \begin{figure}
201 \includegraphics[height=0.5\textheight]{ctsimfig3.eps}
202 \caption{Equilinear and equiangluar geometry when focal length ratio =
203 field of view ratio = 1.}
204 \end{figure}
205 The angle $\alpha$ is now defined as shown in figure 3, and the detector
206 length is adjusted to subtend the angle $2\alpha$ as shown.  Note that the
207 size of the detector array may have changed and the field of view is not
208 used.  
209 For a circular array of detectors, the detectors are spaced around a
210 circle covering an angular distance of $2\alpha$.  The dotted circle in
211 figure 3 indicates the positions of the detectors in this case. Note that 
212 detectors at the ends of the range would not be illuminated by the source.
213
214 Now, consider increasing the focal length ratio to two leaving the
215 field of view ratio as 1,  as in  Figure 4.  Now the detectors array is
216 denser, and the real field of view is closer to that specified, but note
217 again that the field of view is not used. Instead, the focal length is
218 used to give a distance from the centre of the phantom to the source, and
219 the detector array is adjusted to give an angular coverage to include the
220 whole phantom.  
221 \begin{figure}
222 \includegraphics[width=\textwidth]{ctsimfig4.eps}
223 \caption{Equilinear and equiangluar geometry when focal length ratio = 2
224 and the field of view ratio = 1.}
225 \end{figure}
226 Now consider a focal length ratio of 4 (figure 5). As expected, the angle
227 $\alpha$ is smaller still.  The dotted square is the bounding square of
228 the phantom rotated by 45 degrees, corresponding to the geometry of a
229 projection taken at that angle.  Note that the fan beam now clips the top
230 and bottom corners of the bounding square.  This illustrates that one may
231 still be clipping the phantom, despite \ctsim\'s best efforts.  You have
232 been warned.  
233 \begin{figure}
234 \includegraphics[width=\textwidth]{ctsimfig5.eps}
235 \caption{Equilinear and equiangluar geometry when focal length ratio = 4.}
236
237 \end{figure}
238
239
240 \section{Reconstruction}\label{conceptreconstruction}\index{Concepts,Reconstruction}%
241 \subsection{Overview}
242 \subsection{Filtered Backprojection}
243 \subsection{Direct Inverse Fourier}
244 This method is not currently implemented in \ctsim, however it is planned for a
245 future release. This method does not give as accurate result as filtered
246 backprojection mostly due to interpolation occuring in the frequency domain rather
247 than the spatial domain. The technique is comprised of two sequential steps:
248 filtering projections and then backprojecting the filtered projections. Though
249 these two steps are sequential, each view position can be processed individually.
250 This parallelism is exploited in the MPI versions of \ctsim\ where the data from
251 all the views are spread about amongst all of the processors. This has been testing
252 in a 16-CPU cluster with good results.
253
254 \subsubsection{Filter projections}
255 The projections for a single view have their frequency data multipled by
256 a filter of absolute(w). \ctsim\ permits four different ways to accomplish this
257 filtering. Two of the methods use convolution of the projection data with the
258 inverse fourier transform of absolute(x). The other two methods perform an fourier
259 transform of the projection data and multiply that by the absolute(x) filter and
260 then perform an inverse fourier transform.
261
262 \subsubsection{Backprojection of filtered projections}