Units and Conventions - xcist/documentation GitHub Wiki

Units

Unless specified otherwise, the standard units in CatSim are
• mm for length
• s for time
• degrees for angles

Coordinate system

Figure 1 shows CatSim’s coordinate system, as viewed from the back of the gantry. Note that we use a left-handed system!


Figure 1: Schematic of CatSim coordinate system and conventions

The Z axis is defined as the axis of rotation of the source-detector assembly, or the axis of rotation of the subject. The "central ray" is defined as the ray originating at the source (the center of the x-ray focal spot) and perpendicular to the Z axis. The origin of the coordinate system is defined as the intersection of the Z axis and the central ray. This is often referred to as "isocenter". The distance from the x-ray source to the origin is defined as the Source to-Isocenter Distance, (SID). The intersection of the central ray and the detector surface is defined as the "pierce point", and the distance from the origin to the pierce point is defined as the Detector-to-Isocenter Distance (DID). The distance from the source to the pierce point is defined as the Source-to-Detector Distance (SDD). SDD = SID + DID.

The patient table, when withdrawn from the scanner, lies along the positive Z axis.

The view angle is the angle from the positive Y axis to the central ray. Therefore, for a view angle of 90°, the source is at
(X = -SID, Y = 0).

Data storage within Matlab variables

We feel that the convention described below makes things conceptually easier when programming within Matlab, because the direction of the indices is the same as the direction of the coordinates. However, this does cause some issues.

Projection images

From Figure 1, we can see that detector rows are numbered in the same direction as the Z coordinates, and, when the source is at 0°, the detector columns are numbered in the same direction as the X axis. When projection data are produced in CatSim, these data are stored in internal Matlab matrices.


Figure 2: CatSim's "internal" projection image data storage

From inside Matlab, we reference the pixels within a projection image matrix by applying the pixel’s indices in the order (DetectorColumn, DetectorRow). Be careful to distinguish between this and the Matlab concept of referencing by (row, column). A Matlab “row” corresponds to a CatSim DetectorColumn index, and a Matlab “column” corresponds to a CatSim DetectorRow index. Therefore, a “row” of pixels in Figure 3 is not a Matlab “row”!!! This is confusing but correct, and necessary. The reason for this is that we want our data to be stored (in computer memory) in “DetectorRow major” order, i.e. we want data to be stored in memory such that the fastest-changing dimension of our array to be the DetectorColumn dimension.

Within the Matlab level of CatSim, one should primarily think in terms of Figure 3, and reference matrices using the convention:

PixelValue = DetectorProjection(DetectorColumn, DetectorRow);

However, for some functions, it’s more efficient to operate on the transform, so be aware of situations where the detector projection is transformed!

Image volumes

When a phantom is defined, the orientation of the phantom within the system is determined by the coordinate system shown in Figure 1. If the phantom is voxelized, then the ordering of the elements in the voxelized matrix is also determined by this system: increasing matrix indices correspond to increasing voxel coordinates, as shown in Figure 3. The same convention also applies to images produced using CatSimRecon. The actual coordinate of each voxel is determined by the voxel’s indices, combined with variables that define the origin and voxel size in each dimension.


Figure 3: CatSim's "internal" image volume data storage

From inside Matlab, we reference the voxels within an image volume matrix by applying the voxel’s indices in the order (X, Y, Z). Be careful to distinguish between this and the Matlab concept of referencing by (row, column). A Matlab “row” corresponds to a CatSim X index, and a Matlab “column” corresponds to a CatSim Y index. Therefore, a “row” of voxels in Figure 3 is not a Matlab “row”!!! This is confusing but correct, and necessary. The reason for this is that we want our data to be in “Z major, X minor” order, i.e. we want data to be stored in memory such that the fastest-changing dimension of our array to be the X dimension, and the slowest-changing to be the Z dimension. Mathematically stated, we want the data to be stored (in computer memory) in the sequence:

In this way, we can reference a single image “slice” (an XY plane at constant Z) using the Matlab syntax:

ImageXYPlane = ImageVolume(:,:,k);

We can pass this image to another Matlab function or to a C function by reference, and the entire image slice will be stored in contiguous memory. For some CatSim functions, in particular C functions that use the Distance-Driven concept for forward or back-projection, it’s more efficient to operate on each XZ plane, rather than XY planes. In that case, the matrix must be reordered to be in Y-major, Z-minor order. This reordering is performed in the Matlab functions that act as “wrappers” to the C functions. Therefore, this housekeeping is generally transparent at the Matlab level; mention is made here primarily for informational purposes. Within the Matlab level of CatSim, one should think in terms of Figure 3, and reference matrices using the convention:

VoxelValue = ImageVolme(X, Y, Z)

Data storage in files

A long-standing convention in image display is to write from the top left corner of the display – the display columns are therefore written from left to right (like Figure 2), but the display rows are written from top to bottom (unlike Figure 2). Television works this way, and therefore a great number of image display software standards assume this format by default (such as the DICOM standard, and commonly-used utilities like ImageJ). Therefore, if we write data to files in the CatSim’s “internal” format as defined above, the lowest index (and therefore lowest coordinate) gets written first. When such a files is displayed, the lowest index (coordinate) gets written first, at the top of the display. Therefore, the image appears to be flipped top-to-bottom.

Fortunately, the common display conventions are the same as CatSim’s conventions when it comes to which dimension is fastest-changing and which is slowest. In television “raster scanning” sweeps across all columns along a row (sweep X’s left to right, at constant Y) and then increments the row to create a 2D image. Subsequent images (in time) can be thought of as subsequent “slices”, or increasing Z. Therefore, our convention of “DetectorRow major” works out fine to display detector projections, and our convention of “Z major, X minor” works out fine to display image volumes.

Projection images

When CatSim writes projection images to file, they’re written in CatSim’s “internal” format. When displayed, these images appear as shown in Figure 4.

We made this choice to be compatible with the format written by actual scanners, and because people who are familiar with working with projection images expect this format.


Figure 4: CatSim's "external" projection image data storage, as displayed


Back to Main menu

⚠️ **GitHub.com Fallback** ⚠️