KAHIBARO
Discord Login Register

Coordinate Systems

Image coordinates

When you use medical images such as CT or MRI to build a GATE simulation, you move between at least two coordinate systems. The first is the image coordinate system, which belongs to the scanner and the DICOM files. It is discrete, voxel based, and uses indices rather than physical distances. Understanding this system clearly is essential before you can place the image correctly inside a GATE geometry.

In image coordinates, each voxel is addressed by integer indices, usually written as $(i, j, k)$ or $(x\_\text{idx}, y\_\text{idx}, z\_\text{idx})$. These indices specify the column, row, and slice number in the stored image array. The array indexing convention depends on the software you use, but conceptually you always have three orthogonal index directions.

Image coordinates are tied to the voxel grid, not to millimeters. To convert indices to physical coordinates, you need three pieces of information that come with the image:

  1. The voxel spacing along each axis, often written as $(\Delta x, \Delta y, \Delta z)$. DICOM calls these values pixel spacing in plane and slice thickness in the slice direction.
  2. An image origin. This is the physical location of a specific voxel, often the corner or center of the voxel with indices $(0, 0, 0)$. Different software can define this origin slightly differently, so you must verify how your input library interprets it.
  3. An orientation, which tells you how the image axes are oriented in a patient or scanner reference frame, for example patient left to right, posterior to anterior, and inferior to superior.

If we assume a simple case where the image axes are already aligned with a standard patient or scanner frame, and the origin is at the center of voxel $(0, 0, 0)$, then the physical position of voxel $(i, j, k)$ in the image frame is often written as

$$
x = x\_0 + i \, \Delta x, \quad
y = y\_0 + j \, \Delta y, \quad
z = z\_0 + k \, \Delta z,
$$

where $(x\_0, y\_0, z\_0)$ is the physical coordinate of the origin voxel.

Always check how your image reading library defines:

  1. The origin (voxel corner or center).
  2. The index ordering $(i, j, k)$ versus $(x, y, z)$.
  3. The orientation of each axis in patient space.
    Misinterpreting any of these points is a common source of geometry and dose misalignment in simulations.

DICOM stores orientation using direction cosines. Two vectors describe the direction of the image rows and columns in a patient coordinate system. The slice direction is obtained from the cross product of these vectors. Libraries that read DICOM, such as SimpleITK or pydicom combined with external tools, usually expose the orientation as a rotation matrix or as direction cosines. In many workflows, this orientation is already applied to build a consistent physical coordinate frame for the image, but you should verify this explicitly.

Finally, be aware that storing formats like NIfTI or MHD may have their own conventions about axis ordering and handedness. Mixing images from different formats without checking the metadata can invert axes, flip left and right, or change the slice order. When you later import these image-based volumes into GATE, such changes will directly affect where materials and activity are placed.

Simulation coordinates

In GATE, all geometry is ultimately defined in a continuous, three dimensional simulation coordinate system. This is the coordinate system in which you position the world volume, detectors, phantoms, and sources. Every volume has a placement defined by a translation and rotation relative to its parent volume. To use medical images as voxelized geometry or as activity maps, you must map from the image coordinates to this simulation coordinate system in a consistent way.

The GATE simulation coordinates are expressed in physical units, typically millimeters. The world volume defines the reference frame. Its center is usually set to coordinate $(0, 0, 0)$ in GATE. Child volumes, including voxelized phantoms, are placed in this frame or in the frame of an intermediate parent. The position of any voxel in a CT based phantom is therefore determined by two steps: the mapping from voxel indices to physical coordinates within the voxelized volume, and the placement of that volume within the world.

Conceptually, you can describe this mapping with a simple relationship. If $(i, j, k)$ are image indices, and $(x\_\text{img}, y\_\text{img}, z\_\text{img})$ is the corresponding position in the image’s own physical frame, you first build

$$
\mathbf{r}\_\text{img}(i, j, k) =
\begin{bmatrix}
x\_\text{img} \\
y\_\text{img} \\
z\_\text{img}
\end{bmatrix}
=
\mathbf{R}\_\text{img}
\begin{bmatrix}
i \, \Delta x \\
j \, \Delta y \\
k \, \Delta z
\end{bmatrix}
+
\mathbf{r}\_0,
$$

where $\mathbf{R}\_\text{img}$ is the orientation matrix derived from the image metadata and $\mathbf{r}\_0$ is the origin in physical space. Then, to place the voxelized object inside the GATE world, you apply the placement of the volume

$$
\mathbf{r}\_\text{sim} =
\mathbf{R}\_\text{place} \, \mathbf{r}\_\text{img} + \mathbf{T}\_\text{place},
$$

where $\mathbf{R}\_\text{place}$ is the rotation of the voxel volume in the world and $\mathbf{T}\_\text{place}$ is its translation.

In practice, GATE and the OpenGATE Python interface manage most of these transformations for you when you define an image based volume using the image’s size and spacing. However, you are responsible for providing consistent parameters that match the original image. This is especially important when you want to align a CT derived material map with a separate activity distribution or with an external structure set.

When mapping images into GATE, you must keep these points consistent:

  1. The voxel spacing and dimensions from the image must match the dimensions you use for the voxelized volume.
  2. The origin and orientation from the image must be translated correctly into the placement and rotation of the volume in the world.
  3. All related images, for example CT, activity map, and dose grid, must share the same spatial reference or be transformed to a common frame before import.
    Any mismatch can produce incorrect dose distributions, misaligned sources, or detectors that are placed outside the patient.

A useful habit is to define a clear simulation reference frame at the start of your project and keep it consistent. For example, you can choose a patient based frame where the $z$ axis points from inferior to superior, the $x$ axis from patient left to right, and the $y$ axis from posterior to anterior. You then position your world volume so that its origin corresponds to a meaningful anatomical point, such as the scanner isocenter or the center of the CT field of view. All subsequent geometry, including voxelized phantoms and detector arrays, is positioned relative to this frame.

Visualization inside GATE is an important tool to verify that your mapping between image and simulation coordinates is correct. After importing a voxelized geometry, you should visually inspect whether the volume appears at the expected location, whether its orientation is correct, and whether external objects such as beams, sources, or detectors intersect the intended regions. Detecting a left right flip, a slice reversal, or an incorrect translation at this stage is far easier than interpreting an incorrect dose map after a long simulation.

Finally, remember that the dose you compute, the fluence you score, and the detector signals you record all depend on correct spatial alignment. A strong mental picture of how image coordinates and simulation coordinates relate is therefore a core skill for any image based GATE simulation.

Views: 11

Comments

Please login to add a comment.

Don't have an account? Register now!