Division of Nuclear Medicine

SimSET
Random Coincidence Simulation

[News] [Installation guide] [User guide] [Programmers' info] [Resources] [Contacts]


Contents

  1. Random coincidence simulation description
         1.1 Overview
         1.2 Creating a detected photon history file
         1.3 Time-sorting the detected photon history file
         1.4 Adding randoms to the time-sorted detected photon history list
         1.5 Binning the randoms-added history file


  2. Parameter file descriptions
         2.1 timesort parameter file
         2.2 addrandoms parameter file


  3. Example PHG run-time parameter files

 

Random Coincidence Simulation Description

Overview

There are two ways to simulate random coincidences for PET with SimSET. The quickest is to do a separate singles simulation using the same detector simulation and then use the Rij = 2TSiSj formula to compute randoms for each detector pair (see, for example, MacDonald et al, 2008; Stearns et al, 2003). Alternately, SimSET offers direct simulation of randoms combined with the coincidence simulation. This option requires several steps and takes considerably more CPU time; we recommend this option only in cases where the computation from singles is likely to be inaccurate, for example in cases where there are many triples.

The remainder of this section deals with simulating random coincidences directly. Doing so requires several new parameter files, changes to the photon history generator parameters and binning parmeters, and execution of three utility programs.

Figure 1 gives an overview of randoms coincidence simulation.

 

Figure 1. Random Coincidence Generation Module for PET simulations. When using the random coincidence generation feature, photons are tracked as usual through the photon history generator, collimator, and detector modules. However, at that point a history file is created of all the photons triggering the detector. This history file is then fed through a series of three SimSET utilities: first it is time-sorted; next a time window is applied and random coincidences generated are added to the history file; finally the history file is processed using the binning module.

To simulate random events directly one needs a list of all detected photons ordered by and stamped with their detection times. This is quite different from SimSET’s ‘native’ mode: SimSET generates decays voxel-by-voxel (not in time-order) and when simulating PET always stopped tracking a photon when its annihilation partner wasn’t detected. Furthermore, importance sampling options are not compatible with direct generation of randoms, indeed, the decays and photons all need to have weight 1.

The new SimSET randoms software addresses these problems by splitting the simulation into a four-step process: first a history (list-mode) file is created for the detected photons without pruning of unmatched photons; a new utility program called timesort sorts the history list by detection time (using a new field added to the decay record); a new utility program called addrandoms scans this list with a time window, adding random events and deleting single events and triple events; the resulting list-mode file is then processed through the binning module using the utility program phgbin. (This process is a little complicated at present; if there is enough user interest in this feature, we will automate it in future versions.)

Note that this process requires lots of free disk space for the history files and intermediate sorting files: simulating a clinically realistic number of events requires hundreds of gigabytes of free disk space.

Each of the above steps is described below.

 

 [top of page] [example parameter files]

 

Creating a detected photon history file

Creating a detected photon history file requires running the photon history generator, collimator module (if collimator simulation is desired), and the detector module. The use of these modules is described elsewhere; here we just describe requirements particular to simulation of randoms. Example parameter files are given below.

The history file to be used as input to the timesort utility is the standard history file created by the detector module during a SimSET run. The history file name is given in the detector parameters file, e.g.:
STR history_file = "randPET.dethist".
The randoms software only works with the standard history file format, so the line giving custom history parameters should be omitted or set to the empty string:
STR history_params_file = "".

The run file must also be changed to use several new features. In PET simulations using previous versions of SimSET, tracking of a decay stopped if either of the annihilation photons was absorbed or left the simulation space; this improves efficiency. This is not compatable with generating random coincidences from singles .To support PET tracking both with and without the tracking of unmatched singles, we have added two new options, simulate_PET_coincidences_only and simulate_PET_coincidences_plus_singles. Previously setting “simulate_SPECT = false” automatically made the simulation a PET simulation. Now one must specify whether one wants to simulate only those coincidences composed of photons from the same annihilation (“simulate_PET_coincidences_only = true”, much more efficient when randoms generation is not desired) or all photons including unmatched singles (“simulate_PET_coincidences_plus_singles = true”, necessary when simulating randoms). For a randoms simulation the flags must be set as follows:
BOOL simulate_SPECT = false
BOOL simulate_PET_coincidences_only = false
BOOL simulate_PET_coincidences_plus_singles = true

The binning parameters file namecan be left blank in the run file: if filled in, the simulated data will be binned without randoms.
STR bin_params_file = ""
(A separate run through the binning module after randoms have been added to the list-mode data will create the binned data with randoms.)

To allow for the generation of photons and events with a uniform weight of 1, we have added an option for SimSET to compute the number of decays to simulate from the activity distribution and scan time. (Previously the user specifed the number of decays, the activity, and the scan time – there was one piece of redundant information, necessitating the use of weights even when importance sampling was not used. Also note the type of num_to_simulate has been changed from INT to LONGLONG.) To choose this option the user sets the number of decays to 0:
LONGLONG num_to_simulate = 0

The scan time input has also been changed to a real number – this allows the user to set up very short runs (e.g., 0.01 scan time) to check they have set everything up correctly:
REAL length_of_scan = 250.0

In addition, all the importance sampling features must be set to false. In the run file this means simulate_stratification, simulate_forced_detection, and forced_non_absorption must be set false:
BOOL simulate_stratification = false
BOOL simulate_forced_detection = false
BOOL forced_non_absorption = false

In the detector parameters file do_forced_interaction must be set false:
BOOL do_forced_interaction = false

Outside of the above changes, the run and detector parameter files can be identical to those used for other simulations. To run the simulation to create the detected photon history file, use the phg command:

phg randPET.phgin

 [top of page] [example parameter files]

 

Time-sorting the detected photon history file

We have created a new utility program to sort history files by detection time, timesort. timesort can sort any SimSET history file from the phg, collimator or detector modules.

When used for randoms simulation, timesort takes the detected photon history file output by the detector module (see above) and sorts the decays within the file by detection time.

timesort requires a parameter file with three parameters:
# INPUT HISTORY FILE
STR history_file = "randPET.dethist"
# SORTED (OUTPUT) HISTORY FILE
STR sorted_history_file = "randPET.dethist.srtd"
# BUFFER MEMORY SIZE (IN MEGABYTES)
INT buffer_size = 200

The first parameter must give the same file name given for the history file in the detector parameters file. The second is the output file name for the sorted history file data. The third is the size buffer used for the sub-sorting of the data: 200 megabytes is a good size as long as it doesn’t cause memory problems on your system, e.g., if you only have 500MB RAM you may wish to reduce this to 50.

Once the file is created, timesort is run by:
timesort –d -r randPET.tsparms

(The “-d” specifies that a detector history file will be used as input. timesort also accepts phg history files if the flag -p is used, or collimator history files if the flag -c is used. Only the detector history file should be used for randoms simulations, however. The flag “-r” causes randPET.dethist to be deleted after the time-sorted file is created – a little cleaning up.)

 

 [top of page] [example parameter files]

 

Adding randoms to the time-sorted detected photon history list

We have created a new program to add randoms to time-sorted list-mode files, addrandoms. It requires a parameter file with 4 parameters:
# detector_type can be dual-headed or cylindrical
ENUM detector_type = cylindrical
# Time-sorted input history file
STR history_file = "randPET.dethist.srtd"
# Output history file for the new randoms-added data.
STR randoms_history_file = "randPET.randhist"
# Coincidence timing window in nanoseconds.
REAL coincidence_timing_window_in_ns = 5

The detector type must be block or cylindrical. (Randoms simulation is currently incompatible with the dual-head detectors.We suggest using two block detectors instead.)

The second parameter must be the file name for the input time-sorted history file (the output history file from the timesort program). The third parameter is a file name for the output from addrandoms, a history file with randoms added to it (and with all other singles and all triples removed). The fourth parameter gives the desired timing window in nanoseconds. Every detected photon opens a window this long. If no other photons arrive within this timing window, the photon is discarded. If exactly one other photon arrives within the window, a true event (if the second photon is from the same decay) or random event (if its from a different decay) is added to the output list-mode file. If two or more other photons arrive within the window, the photons are discarded.

To run addrandoms enter:
addrandoms randPET.arparms
on the command line.

 [top of page] [example parameter files]

 

Binning the randoms-added history file

Binning of the randoms-added data uses the previously existing bin utility function (also called phgbin, though we are phasing that name out) that bins history files. This function and its parameters are described on the binning web page. Here we describe how to use bin for randoms-added history files and some new binning options added for randoms events.

bin is called with a command line argument specifying an modified version of the run file used to created a detected photon history file. The necessary modifications are to change the detector parameters filename and to add a binning parameters filename:
# DETECTOR PARAMETER FILE
STR detector_params_file = "randPET.bin.detparms"
# BINNING PARAMATER FILE
STR bin_params_file = "randPET.binparms"

randPET.bin.detparms can be a copy of randPET.detparms except the line specifying the history file must give the randoms-added history file output by addrandoms:
STR history_file = "randPET.arhist"

randPET.binparms is the binning parameters file. It has two new parameters, “accept_randoms” and “scatterRandomParam”. To include randoms in the binned data, one must set:
BOOL accept_randoms = true

scatterRandomParam defines a new array of options for binning trues/randoms/scatter. It replaces the parameter “scatterParam”. scatterRandomParam controls how the trues, scatter and randoms get binned. The options are described on the binning web page. The most popular options will probably be: scatterRandomParam = 0, which causes trues, scatter, and randoms to all be binned together (as they are in actual scans); scatterRandomParam = 1, which creates separate bins for trues and scatter (i.e., if the user has selected distance-angle binning, there will be separate distance-angle arrays for true and scatter events); and scatterRandomParam = 6, which creates separate bins for trues, scatter, and randoms. In the example in the samples/fastTest/randPET directory, we set:
INT scatter_param = 6

 

 [top of page] [example parameter files]

 

Parameter file descriptions

This section defines in detail.the parameter files used exclusively in random coincidence simulations. Descriptions of the other parameter files mentioned above are found on the photon history generator, collimator module, detector module, and binning module web pages. The parameter files are the same format as the other SimSET parameter files, ascii text files consisting of entries of the following format:

DATA_TYPE parameter_name = value

For example,

STR randoms_history_file = "randPET.arhist"


More detailed information on the general format of parameter files can be found in
Appendix VI. Parameter type definitions for the random coincidence simulation parameters file follow.

 

timesort parameter file

The timesort parameter file consists of entries for each of the simulation options described in table 1 below:

Parameter name Units Data type
history_file STR
Input history file (ouput from the detector module)
sorted_history_file STR
Output time-sorted history file (for input to addrandoms)
buffer_size megabytes INT
Controls the size of the buffers used to sort the data.

Table 1: Simulation options for timesort

 

 [top of page] [example parameter files]

 

addrandoms parameter file

The addrandoms parameter file consists of entries for each of the simulation options described in table 2 below:

Parameter name Units Data type
detector_type ENUM
Detector type used to create the history file (must be dual-headed or cylindrical in the current version)
history_file STR
Input history file (output from the timesort utility)
randoms_history_file STR
Output history file with added randoms (for input to the binning module)
coincidence_timing_window_in_ns

nanoseconds

INT
Photons arriving less with a detected time differing by less than the timing window will be considered in coincidence.

Table 2: Simulation options for timesort

 

 [top of page] [example parameter files]

 

 

Example randoms simulation parameter files

An example running a randoms simulation is given in the fastTest directory. Links to the parameter files are given below.

  1. Main run parameter file.
  2. Collimator parameter file.
  3. Detector parameter file.
  4. timesort utility parameter file.
  5. addrandoms utility parameter file.
  6. bin utility parameter file.
  7. Detector parameter file for binning utility.
  8. Binning parameter file for binning utility.

 

 

[top of page]
Last revised by: Robert Harrison
Revision date: 28 Jan 2009

Photon History List
The Photon History List. contains a decay record followed by a photon record(s) for each photon that reaches the Target Cylinder and satisfies the user-specified criteria.
Statistical Summary
Regardless of what parameters are specified, and what type of simulation is run, the PHG produces detailed statistical information which provides a summary of the simulation results.
Productivity Table
This table is used for the importance sampling technique of stratification. It also appears in the Data Tables section below because once created, it is then used as input data for subsequent simulations.
Simulation Summary
This is information printed on the screen during the simulation. It provides a detailed description of the input parameters used in the simulation. It also provides a summary of the number and weights of photons entering and being accepted by each module. Within a given module certain characteristic information may also be printed.
Binned Data
Tracked photons may be passed to the Binning Module, where they are sorted into sinograms, projections or other histogram formats as specified by the user. Photons may also be sorted by energy and scattering history.
Data Tables
These tables are supplied with the PHG package. They provide information for operations like importance sampling and scatter modelling.
Simulation Options
These options are specified in a text file referred to as the PHG run-time parameters and often abbreviated as phg_params or run_params.
Attenuation Distribution
This file defines the distribution of attenuating material being simulated. Like the activity distribution, it is also created by the object editor.
Activity Distribution
This file defines the distribution of isotope being simulated. It is created by the object editor.