📄 tmcimg.tex
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% This is a slightly-older version of tMCimg.xhtml. Being LaTeX,
% however, it does give better formatted output.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% tMCimg Documentation
% Copyright (C) 2004 Jonathan Stott
%
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public License
% as published by the Free Software Foundation; either version 2
% of the License, or (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 59 Temple Place - Suite 330,
% Boston, MA 02111-1307, USA.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[12pt]{article}
\setlength{\evensidemargin}{0pt}
\setlength{\oddsidemargin}{0pt}
\setlength{\leftmargin}{0pt}
\setlength{\rightmargin}{0pt}
\setlength{\topmargin}{0pt}
\setlength{\headheight}{0pt}
\setlength{\headsep}{0pt}
\setlength{\textwidth}{6.5in}
\setlength{\textheight}{8.5in}
\setlength{\parindent}{5ex}
\setlength{\parskip}{\baselineskip}
\newcommand{\tMCimg}{t\raise1pt\hbox{M}\raise-1pt\hbox{C}img}
\begin{document}
\centerline{\Large\bf The \tMCimg\ Monte Carlo Modeling Program}
\tMCimg\ uses a Monte Carlo algorithm to model the transport of
photons through 3D highly volumes with spatially varying optical
properties and arbitrary boundary conditions. Both highly-scattering
tissues (e.g. white matter) and weakly scattering tissues
(e.g. cerebral spinal fluid) are supported. Using the clinical
structural information provided by MRI, X-Ray CT, or ultrasound,
accurate solutions to the photon migration forward problem are found
in times ranging from minutes to hours, depending on the optical
properties and the computing resources available.
In brief, each photon is propagated as follows:
\noindent
For every photon in the simulation:
\begin{enumerate}
\item Set the initial position and direction according to the
configuration file
\item Until the photon ``escapes''
\begin{enumerate}
\item Select the distance to the next scattering event. This is an
exponentially distributed random variable.
\item Move, possibly reflecting or refracting off of interfaces, to
the next scattering event. As the photon is moved from voxel to
voxel, it is attenuated according to the local absorption.
\item Add the contribution of this photon's path to the accumulated
photon fluence.
\item Scatter into a new direction according to some (possibly
isotropic) phase function.
\item Iterate until the photon leaves the system, or the time limit
is exceeded.
\end{enumerate}
\item Finally, save to disk.
\end{enumerate}
\section{Input File Formats}
\label{sec:input_file}
Two input files control the behavior of \tMCimg. The input file
({\tt *.cfg}) defines the optical properties and the simulation parameters.
The segmentation (by convention, {\tt *.bin}) is the mapping between
voxels and tissue types (and thus, indirectly, the optical properties).
\subsection{Input File}
\label{sub:input_file}
Figure~\ref{fig:sample_cfg} shows an example configuration file. All
configuration files share some general properties:
\begin{itemize}
\item Keywords are not case sensitivie.
\item Comments are introduced by a semicolon (;) and continue to the
end of the current line.
\item Equal signs (=) are always optional. Grouping ({}) and
array ([]) delimiters are never optional.
\item The order keywords appear in is not important except for
``source'', ``detector'', and ``tissue''. For ``source'',
``detector'', and ``tissue'', items are defined in the order they
are declared (these keywords are special because they define elements
of a list and not single-valued parameters).
\item If a keyword other than ``source'', ``detector'', or ``tissue''
appears multiple times, only the final declaration is used.
\item The amount of white-space (including newlines) is not
significant (i.e.\ thirty spaces, tabs, and new-lines are no more
effective than a single space). The sole exception to this is
inside a {\em quoted} filename. Filenames are quoted using double
quotes (``'').
\item Some keywords may be abbreviated. See the source file
{\tt parser.l} for details.
\end{itemize}
\begin{figure}[p]
\small
\begin{verbatim}
nphotons = 100000 ; Number of photons
freq = 0 ; Amp. mod. freq. (MHz)
seed = 1 ; RNG seed
start_time = 0.000e-9 gate_width = 0.100e-9
ngate = 20
segfile sph.50.50.25.seg ;; segmentation file
dx 2 ;; Voxel size, (in mm)
nxvox = 50 nyvox = 50
nzvox = 25 ;; Size of system (in voxels)
;; Region of interest within system volume (in voxels).
;; Only voxels in the ROI are written out to the .2pt file.
image_x 0 49 image_y 0 49 image_z 0 24
; Tissue types are numbered in the order they're declared.
; Tissue type 0 is hardcoded, user-defined types begin
; with 1.
tissue { mua = 0.0 mus = 0.3 g = 0.0 n = 1.0 }
tissue { mua = 0.0 mus = 0.3 g = 0.0 n = 1.4 }
source { pos = [ 50 51 1 ] dir = [ 0 0 1 ]
na = 0.8 rad = 0.250 }
source { pos = [ 40 41 1 ] dir = [ 0 0 1 ]
na = 0.8 rad = 0.250 }
; Location is [x y z], in mm.
detector { pos [ 10 10 2 ] dir [0 0 1 ] rad 2.0 }
detector { pos [ 30 40 2 ] dir [0 0 1 ] rad 2.0 }
detector { pos [ 40 70 2 ] dir [0 0 1 ] rad 2.0 }
detector { pos [ 60 20 2 ] dir [0 0 1 ] rad 2.0 }
detector { pos [ 70 10 2 ] dir [0 0 1 ] rad 2.0 }
\end{verbatim}
\caption{Sample {\tt .cfg} file.}
\label{fig:sample_cfg}
\end{figure}
Table~\ref{tbl:keywords} lists all the keywords recognized by the
parser. Most of the fields are self-explanitory, but a few require
additional explanation.
``Source'' introduces a source definition. The definition is
surrounded by curly brackets `\{\}'. The position and direction
(``pos'' and ``dir'') must be specified. The source radius and
numerical aperature (``rad'' and ``na'') are optional and default to
zero. Sources are numbered in the order they're defined. The origin
is taken to be the bottom-left corner of the volume (voxel numbering
begins at 0).
``Detector'' introduces a detector definition. The definition is
surrounded with by curly brackets `\{\}'. The position and radius
(``pos'' and ``rad'') must be specified. The direction and numerical
aperature (``dir'' and ``na'') are optional. The numerical aperature
defaults to zero. The direction is not used if the numerical
aperature is zero; if the numerical aperature is non-zero, a
dirrection must be supplied.
``Tissue'' defines a set of tissue optical properties. Tissue type 0
is implicitly defined to be `air'. Any photon encountering a voxel of
tissue type 0 is assumed to have left the system. {\em Assigning
photons to detectors is done if and when the photon encounters a voxel
of tissue type 0}. Tissue types 1 and higher are user defined. The
maximum number of tissue types is currently around 100. This value
may be increased in the future. For every ``tissue'' declaration, the
absorption coefficient, scattering coefficient, scattering anisotropy,
and index of refraction ($\mu_a$, $\mu_s$, $g$, and $n$) must be
defined. The segmentation file (see
Section~\ref{sub:segmentation_file}) contains a series of indices
mapping individual voxels on to tissue types.
``C0'' defines the vacuum speed of light. By default, the speed of
light is in $2.99792458\times10^{11}\,\mbox{mm/s}$. This (and this
alone) sets the fundamental length scale of the program to be millimeters.
By changing ``c0'', it is possible to change the dimensions of the
program from mm to cm (or m or $\mu\mbox{m}$ or whatever), provided
all tissue properties, etc., are adjusted appropriately.
It's probably easier, though, to specify everything in mm and change
``dx'' to get a reasonable voxel size out.
``Nxvox'', ``nyvox'', and ``nzvox'' specify the number of voxels in
each dimension. There must be at least one voxel in each direction.
Non-rectangular coordinate systems are not supported.
``Dx'', ``dy'', and ``dz'' define the size of the voxels. Currently
only cubic voxels are supported. If more than one of ``dx'', ``dy'',
and ``dz'' are specified, the largest value is used for all three
sides. If none are specified, the size is implicitly set to
$1\,\mbox{mm}$.
``Img\_x'', ``img\_y'', and ``img\_z'' define a region of interest.
Often, one is interested in computing the two-point Green's function
in only a subset of the full segmented region, but truncating the
volume would introduce edge artifacts. The solution is to define a
region of interest that encompases only a subset of the total volume.
The two-point Green's function is only computed within the region of
interest, which saves on both disk space and memory. If no region of
interest is defined, the entire volume is assumed to be of interest.
The region of interest is specified in voxels. {\em Voxels are
numbered starting with 0.}
\begin{table}[p]
\begin{center}
\begin{tabular}{|c|c|l|}
\hline
Keyword & Default & Description \\
\hline
\hline
; & N/A & Begin a comment \\
\hline
nphotons & required & Number of photons to run (per source) \\
\hline
seed & required & Random number seed \\
\hline
segfile & required & Tissue segmentation file \\
\hline
freq & required & Modulation frequency\\
\hline
c0 & $3\times10^11\,\mbox{mm/s}$ & Vacuum speed of light\\
\hline
start\_time & required & Start time of first time gate \\
\hline
gate\_width & required & Width of each time gate \\
\hline
ngates & required & Total number of time gates\\
\hline
\hline
tissue & N/A & Introduce tissue definintion \\
\hline
mus & required & Tissue $\mu_s$ \\
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -