⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tmcimg.xhtml

📁 蒙特卡罗模拟光子成像C语言版,代码简洁专业
💻 XHTML
📖 第 1 页 / 共 2 页
字号:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" 
		  "http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd"
		[ <!ENTITY mathml "http://www.w3.org/1998/Math/MathML"> ]>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
  <title>tMCimg Monte Carlo photon transport</title>
  <meta name="Generator" content="/usr/bin/emacs" />
  <!-- These two are for the benefit of HTML-only browsers -->
  <meta http-equiv="Content-Language" content="en-us" />
  <meta http-equiv="Content-Type" content="text/xml; charset=iso-8859-1" />
  
  <style type="text/css">
    body      { margin-left:    5%;
                margin-right:   5%;
                margin-top:    1em;
                margin-bottom: 1em;
    }

    p         { text-indent: 5ex; }

    table     { margin-left: 10%;
                margin-right: 10%;
		margin-top: 1ex;
                width: 80%; 
		border-collapse: collapse;
		border: thin solid black; }
   th         { text-align: center;
                padding: 0.5ex;
		border-collapse: collapse;
		border: thin solid black; }
   td         { border-collapse: collapse;
		border: thin solid black;
                padding: 0.5ex;
		vertical-align: middle;
   }
    caption   { margin-top:    1ex;
                margin-left: 15%;
                margin-right: 15%;
		margin-bottom: 1ex;
		font-size: small;
                caption-side: bottom; }

  div.padbox  { margin-left: 10%;
		margin-right: 10%;
		margin-top: 1ex;
		width: 80%;
  }
  div.divcaption {
		font-size:     small;
		text-align:    center;
  }

  .noindent   { text-indent: 0; }
  .noborder   { border: none; }
  </style>
</head>
<!-- ====================================================================
     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.
 ==================================================================== -->
<body>
<h1 id="Title">The <code>tMCimg</code> Monte Carlo Transport Program</h1>

<p class="noindent">
<code>tMCimg</code> 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; for every photon in the simulation:
</p>

<ol>
    <li>Set the initial position and direction according to the
    configuration file</li>
    <li> Until the photon ``escapes''</li>
    <ol style="list-style-type: upper-alpha;">
	<li> Select the distance to the next scattering event (an
	exponentially distributed random variable)</li>
	<li> 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 and the distance traveled in each type of
	tissue is recorded.</li>
	<li> As the photon moves, its position is sampled at regular
	time intervals and this is used to update the accumulated
	photon density.</li>
	<li> Scatter into a new direction according to some (possibly
	isotropic) phase function.</li>
	<li> Iterate until the photon leaves the system, or the time
	limit is exceeded.</li>
	<li> If the photon exists near a detector, add a line to the
	history file.</li>
    </ol>
    <li> Finally, save the final photon density to disk.</li>
</ol>

<h2 id="sec-input_file">1 Input File Formats</h2>

<p class="noindent">
Two input files control the behavior of <code>tMCimg</code>.  The
input file (<code>*.cfg</code>) defines the optical properties and the
simulation parameters.  The segmentation (by convention,
<code>*.bin</code>) is the mapping between voxels and tissue types
(and thus, indirectly, the optical properties).
</p>

<h3 id="sub-input_file">1.1 Input File</h3>

<p class="noindent">
<a href="tMCimg.xhtml#fig-sample_cfg">Figure&nbsp;1</a> shows an
example configuration file.  All configuration files share some
general properties:
</p>

<ul>
    <li> Keywords are not case sensitivie.</li>
    <li> Comments are introduced by a semicolon (;) and continue to the
         end of the current line.</li>
    <li> Equal signs (=) are always optional.  Grouping ({}) and 
         array ([]) delimiters are never optional.</li>
    <li> All times have dimensions of seconds.</li>
    <li> Frequencies have dimensions of megahertz (MHz).</li>
    <li> Most lengths are in mm, inverse lengths are in 1/mm
         (unless you change the vacuum speed of light from its default).
	 The two exceptions are "nxvox" and "image_x", which are in
         voxels.</li>
    <li> The order keywords appear in the configuration file 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). </li>
    <li> If a keyword other than "source", "detector", or "tissue"
         appears multiple times, only the final declaration is used.</li>
    <li> 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</em> filename.  Filenames are quoted using double
         quotes ("").</li>
    <li> Some keywords may be abbreviated.  See the source file
         <code>parser.l</code> for details.</li>
</ul>

<div class="padbox">
    <pre id="fig-sample_cfg">
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 }
    </pre>
    <div class="divcaption">
	Figure 1. Sample configuration file.
    </div>
</div>

<p>
<a href="tMCimg.xhtml#tbl-keywords">Table&nbsp;1</a> lists all the
keywords recognized by the parser.  Most of the fields are
self-explanitory, but a few require additional explanation.
</p>

<p>
"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). <em>The numerical aperature code is buggy and should
not be used; just leave the NA unspecified!</em>
</p>

<p>
"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.  <em>The numerical aperature code
is buggy and should not be used; leave the NA unspecified!</em>
</p>

<p>
"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 only done if and when the photon encounters a voxel
of tissue type 0</em>.  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 
(<math xmlns="&mathml;">
    <msub><mi>&mu;</mi><mo>a</mo></msub>
    <mtext>,</mtext>
</math>
<math xmlns="&mathml;">
    <msub><mi>&mu;</mi><mo>s</mo></msub>
    <mtext>,</mtext>
</math>
<math xmlns="&mathml;">
    <mi>g</mi>
    <mtext>,</mtext>
</math>
and
<math xmlns="&mathml;">
    <mi>n</mi>
    <mtext>,</mtext>
</math>)
must be defined.  The segmentation file
(see <a href="tMCimg.xhtml#sub-segmentation_file">Section&nbsp;1.2</a>)
contains a series of indices mapping individual voxels on to tissue
types.
</p>

<p>
"C0" defines the vacuum speed of light.  By default, the speed of
light is 
<math xmlns="&mathml;">
    <mrow>
	<mn>2.99792458</mn>
	<mo>&times;</mo>
	<msup>
	    <mn>10</mn>
	    <mn>11</mn>
	</msup>
	<mpadded lspace="0.1em">
	    <mtext>mm/s.</mtext>
	</mpadded>
    </mrow>
</math>
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;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.
</p>

<p>
"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.
</p>

<p>
"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&nbsp;mm.
</p>

<p>
"Image_x", "image_y", and "image_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 always
numbered starting with 0.</em>
</p>

<table id="tbl-keywords">
    <tr>
	<th>Keyword</th>
	<th>Default</th>
	<th>Description</th>
    </tr>
    <tr>
	<td align="center">;</td>
	<td>N/A</td>
	<td>Begin a comment</td>
    </tr>
    <tr>
	<td>nphotons</td>
	<td>required</td>
	<td>Number of photons to run (per source)</td>
    </tr>
    <tr>
	<td>seed</td>
	<td>required</td>
	<td>Random number seed</td>
    </tr>
    <tr>
	<td>segfile</td>
	<td>required</td>
	<td>Tissue segmentation file</td>
    </tr>
    <tr>
	<td>freq</td>
	<td>required</td>
	<td>Modulation frequency</td>
    </tr>
    <tr>
	<td>c0</td>
	<td>3e11&nbsp;mm/s</td>
	<td>Vacuum speed of light</td>
    </tr>
    <tr>
	<td>start_time</td>
	<td>required</td>
	<td>Start time of first time gate</td>
    </tr>
    <tr>
	<td>gate_width</td>
	<td>required</td>
	<td>Width of each time gate</td>
    </tr>
    <tr>
	<td>ngates</td>
	<td>required</td>
	<td>Total number of time gates</td>
    </tr>
    <tr>
	<td>tissue</td>
	<td>N/A</td>
	<td>Introduce tissue definintion</td>
    </tr>
    <tr>
	<td>mus</td>
	<td>required</td>
	<td>Tissue scattering coefficient (1/mm)</td>
    </tr>
    <tr>
	<td>mua</td>
	<td>required</td>
	<td>Tissue absorption coefficient (1/mm)</td>
    </tr>
    <tr>
	<td>g</td>
	<td>required</td>
	<td>Tissue anisotropy parameter</td>
    </tr>
    <tr>
	<td>n</td>
	<td>required</td>
	<td>Tissue index of refraction</td>
    </tr>
    <tr>
	<td>detector</td>
	<td>N/A</td>
	<td>Introduce detector definition</td>
    </tr>
    <tr>
	<td>source</td>
	<td>N/A</td>
	<td>Introduce source definition</td>
    </tr>
    <tr>
	<td>pos</td>
	<td>required</td>
	<td>Source/Detector position</td>
    </tr>
    <tr>
	<td>dir</td>
	<td>varies</td>
	<td>Source/Detector direction</td>
    </tr>
    <tr>
	<td>rad</td>
	<td>varies</td>
	<td>Source/Detector radius</td>
    </tr>
    <tr>
	<td>na</td>
	<td>0</td>
	<td>Source/Detector numerical aperature</td>
    </tr>
    <tr>
	<td>dx</td>
	<td>1</td>
	<td rowspan="3">mm per voxel, urrently only square voxels
	                are supported</td>
    </tr>
    <tr>
	<td>dy</td>
	<td>1</td>
    </tr>
    <tr>
	<td>dz</td>
	<td>1</td>
    </tr>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -