KAHIBARO
Discord Login Register

5.4. Time Units

Table of Contents

`ns`

Time in GATE is always specified with explicit units from the Geant4 system of units. For time, the base unit is the second, written as s, and smaller units are defined as multiples of this base unit. In GATE Python scripts you never write a bare number to represent time. You always multiply a numerical value by a unit symbol provided by the GATE or Geant4 units module.

The nanosecond ns is the most commonly used time unit for fast detector simulations. It is particularly important in PET, SPECT, CT detectors, and in any study that involves detector timing, coincidences, or time-of-flight.

Numerically, one nanosecond is defined as:

$$
1 \,\text{ns} = 10^{-9} \,\text{s}
$$

In code, a typical usage in an OpenGATE Python script would look like:

python
import opengate as gate
from opengate import g4_units
sim = gate.Simulation()
sim.run_timing_intervals = [0, 10 * g4_units.ns]

This example sets a short simulation interval of 10 nanoseconds. For detector response, you will often configure timing resolutions or coincidence windows on the order of a few hundred picoseconds to a few nanoseconds. Even if a timing parameter is conceptually sub-nanosecond, it is still expressed as a fraction of ns, for example 0.2 * g4_units.ns for 200 ps.

Always write time values as number unit, for example 5 g4_units.ns. A bare number such as 5 is interpreted as a dimensionless quantity, not as time, and will produce incorrect simulations or runtime errors.

Because ns is small compared to typical acquisition durations, it is mainly used for describing detector-level processes, such as timing resolution, trigger windows, and time stamps of individual hits or singles. You will see time values in output files, such as ROOT trees or CSV data, expressed in these same units, often nanoseconds, so matching your analysis code to the correct unit is essential.

When you read or write time data, remember that:

$$
t_{\text{ns}} = t_{\text{s}} \times 10^{9},
\quad
t_{\text{s}} = t_{\text{ns}} \times 10^{-9}
$$

If you export time data and use it in another program that expects seconds, you must convert from nanoseconds to seconds accordingly.

`us`

The microsecond us is a larger time unit that is useful when you describe processes that occur on slower time scales compared to fast detector electronics. It is defined as:

$$
1 \,\text{µs} = 10^{-6} \,\text{s}
$$

and relates to the nanosecond by:

$$
1 \,\text{µs} = 1000 \,\text{ns}
$$

In GATE scripts, it is typically written as g4_units.us or a similar symbol provided by the units module:

python
from opengate import g4_units
dead_time = 2 * g4_units.us

The microsecond unit is well suited for modeling detector dead time, shaping times in electronics, or acquisition bin widths in certain counting experiments where events are grouped in time intervals that are longer than nanoseconds but still relatively short compared to the full scan duration.

When you change a parameter from nanoseconds to microseconds, you must adjust the numerical value accordingly. For example, a 500 ns dead time can be expressed as:

python
dead_time = 500 * g4_units.ns

or equivalently:

python
dead_time = 0.5 * g4_units.us

Both represent the same physical time.

Do not confuse ns and us in code and analysis. A value that is off by a factor of 1000 in time can drastically change detector count rates, coincidence rates, and the apparent behavior of dead time or pile-up.

Microseconds are also sometimes used in time-dependent simulations where sources or geometries change in steps that are faster than the total acquisition, but slower than individual detector events, for example pulsed beams or fast mechanical motions.

`ms`

The millisecond ms is often used for describing time intervals that are still relatively short on the human scale, but much longer than electronic timing windows. It is defined by:

$$
1 \,\text{ms} = 10^{-3} \,\text{s}
$$

It also relates to the other time units by:

$$
1 \,\text{ms} = 1000 \,\text{µs} = 10^{6} \,\text{ns}
$$

In GATE scripts you write it as g4_units.ms:

python
from opengate import g4_units
frame_duration = 100 * g4_units.ms

Milliseconds become relevant when you describe acquisition frames, motion steps, rotation increments of detectors, or other processes where the system state changes on a time scale of tens to hundreds of milliseconds. Dynamic imaging protocols, such as time-resolved PET or SPECT, may define temporal frames that last from milliseconds to seconds, depending on the application.

When you set up time intervals for dynamic simulations in GATE, you can define a list of times, each with an explicit unit. For example, three frames of 200 ms, 300 ms, and 500 ms could be defined as cumulative time boundaries:

python
sim.run_timing_intervals = [
    0 * g4_units.s,
    0.2 * g4_units.s,
    0.5 * g4_units.s,
    1.0 * g4_units.s,
]

Even though the values are naturally expressed in milliseconds, they are passed as seconds. You can equivalently use g4_units.ms to keep numbers near 1:

python
sim.run_timing_intervals = [
    0 * g4_units.ms,
    200 * g4_units.ms,
    500 * g4_units.ms,
    1000 * g4_units.ms,
]

Both approaches are acceptable as long as you keep the units consistent.

Choose a time unit so that the numerical values you write are in a comfortable range, neither extremely small nor extremely large. For frame or motion durations, ms or s are usually clearer than ns, which can hide large numbers and increase the chance of mistakes.

When exporting or analyzing data, remember to convert milliseconds to seconds or other units required by your analysis tools:

$$
t_{\text{s}} = t_{\text{ms}} \times 10^{-3}
$$

`s`

The second s is the base unit of time in the International System of Units, and it is also the fundamental time unit in Geant4 and GATE. All other time units are derived from the second. Conceptually, every time quantity in the simulation is internally stored as a multiple of the second, regardless of the unit you use in your script.

The relationships between the units introduced earlier and the second are:

$$
1 \,\text{s} = 10^{3} \,\text{ms} = 10^{6} \,\text{µs} = 10^{9} \,\text{ns}
$$

In GATE, the second is written as g4_units.s:

python
from opengate import g4_units
acquisition_time = 600 * g4_units.s

Seconds are the natural choice for describing overall acquisition durations, such as scan time in PET or SPECT, exposure time in CT, or irradiation time in radiation therapy simulations. They are also typically used when you convert between activity in becquerels and the number of decays simulated over a given time interval, which is covered in other chapters on radioactivity and activity units.

Because activity is measured in becquerels, where:

$$
1 \,\text{Bq} = 1 \,\text{decay per second}
$$

using seconds directly can simplify reasoning about the expected number of decays in a simulation interval.

For dynamic simulations, frame durations or time points over several minutes or hours are still conveniently expressed in seconds:

python
frame1_end = 60 * g4_units.s    # 1 minute
frame2_end = 120 * g4_units.s   # 2 minutes

If you ever need longer times, such as hours, you typically still express them in seconds, for example:

$$
1 \,\text{hour} = 3600 \,\text{s}
$$

and then write 3600 * g4_units.s in code.

All time units in GATE, including ns, us, ms, and s, represent the same physical dimension. You can freely choose the unit for each parameter, but you must stay consistent in your calculations and in any manual conversions. Mixing units carelessly leads to large systematic errors in timing, activity modeling, and time-dependent geometry.

As you build more complex simulations, you will often combine several time scales, from nanoseconds for detector hits to seconds or minutes for the entire acquisition. Using the correct GATE time units for each of these scales is essential for a clear and reliable simulation setup.

Views: 13

Comments

Please login to add a comment.

Don't have an account? Register now!