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