Geometry#

How to describe a scanner: see Describing your scanner: the geometry.

tigre.geometry(mode='cone', nVoxel=None, default=False, high_resolution=True)#

Create a scanner geometry.

Parameters:
  • mode ({"cone", "parallel", "fan"}, optional) – "cone" (default): an empty cone-beam geometry to fill in, or the default one if default=True. "parallel": a parallel-beam geometry with 1 mm voxels and detector pixels, sized from nVoxel. "fan": the default 2D fan-beam geometry.

  • nVoxel (numpy.ndarray, optional) – Number of voxels (z, y, x). Required for "parallel"; with default=True it replaces the default image size.

  • default (bool, optional) – For "cone", return tigre.geometry_default() instead of an empty geometry. Default False.

  • high_resolution (bool, optional) – With default=True: a 512³ image and 512² detector (True, the default) or a 64³ image and 128² detector (False).

Returns:

Geometry – The geometry.

Examples

>>> import numpy as np
>>> import tigre
>>> geo = tigre.geometry()                                  # empty, fill in yourself
>>> geo = tigre.geometry(default=True, high_resolution=False)  # 64^3 test geometry
>>> geo = tigre.geometry(mode="parallel", nVoxel=np.array([64, 64, 64]))
class tigre.utilities.geometry.Geometry#

Description of a CT scanner, used by every TIGRE operator.

Create one with tigre.geometry() (or tigre.geometry_default()) and set its attributes. Python orders vector attributes like NumPy indices: (z, y, x) for the image and (v, u) for the detector, the reverse of MATLAB. See Describing your scanner: the geometry for the coordinate system.

DSD#

Distance from the source to the detector, in mm. One value, or one per angle.

Type:

float or numpy.ndarray

DSO#

Distance from the source to the origin, in mm. One value, or one per angle.

Type:

float or numpy.ndarray

nDetector#

Number of detector pixels, (v, u).

Type:

numpy.ndarray

dDetector#

Size of a detector pixel, (v, u), in mm.

Type:

numpy.ndarray

sDetector#

Size of the detector, nDetector * dDetector.

Type:

numpy.ndarray

nVoxel#

Number of voxels, (z, y, x).

Type:

numpy.ndarray

dVoxel#

Size of a voxel, (z, y, x), in mm.

Type:

numpy.ndarray

sVoxel#

Size of the image, nVoxel * dVoxel.

Type:

numpy.ndarray

offOrigin#

Offset of the image centre from the origin, (z, y, x), in mm. Shape (3,), or (N, 3) for one per angle (for example helical scans). Default 0.

Type:

numpy.ndarray, optional

offDetector#

Offset of the detector centre, (v, u), in mm. Shape (2,) or (N, 2). Default 0.

Type:

numpy.ndarray, optional

rotDetector#

Detector rotation (roll, pitch, yaw) in radians; roll rotates the detector in its own plane. Shape (3,) or (N, 3). Default 0.

Type:

numpy.ndarray, optional

COR#

Centre-of-rotation shift along y, in mm. One value, or one per angle. Default 0. See tigre.computeCOR().

Type:

float or numpy.ndarray, optional

accuracy#

Sampling step of the "interpolated" projector, in voxels. Default 0.5.

Type:

float, optional

mode#

Beam geometry. Default "cone".

Type:

{“cone”, “parallel”}

Notes

check_geo (called by every operator) checks that the sizes are consistent and expands per-angle attributes; you do not need to call it.

tigre.geometry_default#

alias of ConeGeometryDefault

tigre.fan_geometry_default#

alias of FanGeometryDefault

tigre.computeCOR(data, geo, angles, slc=None)#

Estimate the centre of rotation from the data.

Finds the shift for which every ray agrees with its conjugate ray, half a turn later, in one detector row (T. Liu, Optical Engineering, 2009).

Parameters:
  • data (numpy.ndarray) – Projections, shape (len(angles), *geo.nDetector).

  • geo (Geometry) – The scanner geometry.

  • angles (numpy.ndarray) – Projection angles in radians. The scan should cover a full circle.

  • slc (int, optional) – Detector row to use. Default: the central row.

Returns:

float – Centre-of-rotation offset in mm at the rotation axis, with the sign geo.COR expects: set geo.COR to this value.

Geometries with moving sources or detectors#

tigre.staticDetectorGeo(geo, angles, rot=0)#

Geometry for a fixed detector and a source that moves on an arc.

As in digital breast tomosynthesis: the detector stays still and the source moves around the origin. Per-angle DSD, offDetector and rotDetector are set to describe it.

Parameters:
  • geo (Geometry) – A cone-beam geometry for the central position (it is not modified).

  • angles (numpy.ndarray) – Angle of the source, in radians, measured from the line through the detector centre perpendicular to the detector. 0 means the source faces the detector.

  • rot (float, optional) – Rotation of the whole setup around the origin, in degrees. Default 0.

Returns:

Geometry – A new geometry. Pass geo.angles (shape (N, 3)) as the angles to the operators and algorithms.

tigre.staticDetLinearSourceGeo(geo, s_pos, s_rot=0, rot=0)#

Geometry for a fixed detector and a source that moves along a line.

Parameters:
  • geo (Geometry) – A cone-beam geometry for the central position (it is not modified).

  • s_pos (numpy.ndarray) – Positions of the source along its line, in mm. At 0 the source, origin and detector centre are aligned on the x axis.

  • s_rot (float or numpy.ndarray, optional) – Angle between the source’s line and the detector, in degrees, seen from above (x-y plane), anticlockwise. Default 0.

  • rot (float or numpy.ndarray, optional) – Rotation of source and detector around the origin, in degrees, seen from above, anticlockwise. Default 0.

Returns:

Geometry – A new geometry. Pass geo.angles (shape (N, 3)) as the angles to the operators and algorithms.

tigre.ArbitrarySourceDetMoveGeo(geo, s_pos, d_pos=None, d_rot=None)#

Geometry for a source and detector that move freely around a fixed object.

Parameters:
  • geo (Geometry) – A cone-beam geometry (it is not modified).

  • s_pos (numpy.ndarray) – Source positions (x, y, z) in mm, shape (N, 3). The source of geo sits at (DSO, 0, 0).

  • d_pos (numpy.ndarray, optional) – Detector centre positions (x, y, z) in mm, shape (N, 3). Default (DSO - DSD, 0, 0) for every position.

  • d_rot (numpy.ndarray, optional) – Detector rotations (roll, pitch, yaw) in degrees, shape (N, 3). Default: no rotation, the detector facing the origin.

Returns:

Geometry – A new geometry. Pass geo.angles (shape (N, 3)) as the angles to the operators and algorithms.

Curved detectors#

tigre.utilities.curved_detector.flatten_detector(proj, geo, oversample=1, arclength=None)#

Resample projections from a curved (cylindrical) detector onto a flat one.

TIGRE’s projectors assume a flat detector. Resample curved-detector data with this function, then reconstruct as usual; geo must then describe the flat detector returned.

Parameters:
  • proj (numpy.ndarray) – Projections measured on the curved detector, shape (N, v, u).

  • geo (Geometry) – The scanner geometry; geo.DSD is the radius of the detector arc.

  • oversample (int, optional) – Flat-detector columns per curved-detector column. Default 1.

  • arclength (float, optional) – Angle covered by the detector arc, in radians. Default geo.sDetector[1], which assumes sDetector was given as an angle.

Returns:

numpy.ndarray – Projections on the flat detector, float32, shape (N, v, u_flat).