rayTracing
- matRad_rayTracing(stfElement, ct, V, rot_coordsV, lateralCutoff)
matRad visualization of two-dimensional dose distributions on ct including segmentation
call
[radDepthV, radDepthCube] = matRad_rayTracing(stf,ct,V,rot_coordsV,lateralCutoff)
- Input:
stfElement – matRad steering information struct of single(!) beam
ct – ct cube
V – linear voxel indices e.g. of voxels inside patient.
rot_coordsV coordinates in beams eye view inside the patient
lateralCutoff – lateral cut off used for ray tracing (optional)
- matRad_siddonRayTracer(isocenterCube, resolution, sourcePoint, targetPoint, cubes)
siddon ray tracing through 3D cube to calculate the radiological depth according to Siddon 1985 Medical Physics. The raytracer expects the isocenter in cube coordinates!
call
- [alphas,l,rho,d12,vis] = matRad_siddonRayTracer(isocenter, …
resolution, … sourcePoint, … targetPoint, … cubes)
- Input:
isocenterCube – isocenter in cube coordinates [mm]
resolution – resolution of the cubes [mm/voxel]
sourcePoint – source point of ray tracing
targetPoint – target point of ray tracing
cubes – cell array of cubes for ray tracing (it is possible to pass multiple cubes for ray tracing to save computation time)
- Output:
alphas – relative distance between start and endpoint for the intersections with the cube
l – lengths of intersections with cubes
rho – densities extracted from cubes
d12 – distance between start and endpoint of ray tracing
ix – indices of hit voxels
- References
Copyright 2015-2026 the matRad development team.
This file is part of the matRad project. It is subject to the license terms in the LICENSE file found in the top-level directory of this distribution and at https://github.com/e0404/matRad/LICENSE.md. No part of the matRad project, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the LICENSE file.
- class matRad_RayTracerSiddon(cubes, grid)
Bases:
matRad_RayTracer- matRad_RayTracerSiddon Ray tracer using Siddon’s algorithm
Implements ray tracing through a CT volume using Siddon’s algorithm, which analytically computes the exact intersection lengths of a ray with each voxel by tracking parametric alpha values at which the ray crosses each set of parallel CT planes (x, y, z).
This class overrides traceRays() from matRad_RayTracer with a vectorized implementation that handles multiple rays simultaneously, significantly improving performance over the default loop.
- References:
Siddon RL (1985), “Fast calculation of the exact radiological path for a three-dimensional CT array”, Med. Phys. 12(2):252-5.
- Usage example:
tracer = matRad_RayTracerSiddon(cubes, grid); [alphas, l, rho, d12, ix] = tracer.traceRays(isocenter, sourcePoints, targetPoints);
Copyright 2026 the matRad development team.
This file is part of the matRad project. It is subject to the license terms in the LICENSE file found in the top-level directory of this distribution and at https://github.com/e0404/matRad/LICENSE.md. No part of the matRad project, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the LICENSE file.
- class matRad_RayTracer(cubes, grid)
Bases:
handle- matRad_RayTracer Base class for ray tracing through a patient CT volume
This class provides the infrastructure for ray tracing in beam’s-eye-view (BEV) coordinates to compute radiological depths along rays from a radiation source through a patient CT grid.
- Subclasses must implement the abstract method:
- traceRay() - trace a single ray and return path segment lengths,
density values, and intersected voxel indices
- Subclasses can optionally override:
- traceRays() - trace multiple rays in a vectorized or otherwise accelerated manner
(default: loop over traceRay)
- Usage example:
tracer = matRad_SomeRayTracerSubclass(cubes, grid); [radDepthsV, radDepthCube] = tracer.traceCube(stfElement, V);
Copyright 2026 the matRad development team.
This file is part of the matRad project. It is subject to the license terms in the LICENSE file found in the top-level directory of this distribution and at https://github.com/e0404/matRad/LICENSE.md. No part of the matRad project, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the LICENSE file.
matRad_RayTracer Construct a ray tracer instance cubes - cell array of density/material cubes to trace through grid - CT grid struct with fields x, y, z and resolution
- Property Summary
- lateralCutOff
- forcePrecision = []
override precision (double or single), otherwise inherited
- enableGPU = false
whether to use GPU arrays for ray tracing (if supported by subclass implementation)
- Method Summary
- traceRays(this, isocenter, sourcePoints, targetPoints)
- traceRay(this, isocenter, sourcePoint, targetPoint)
- traceCube(this, stfElement, voxelIndices, rotCoordsV)