DRR

Module for computing digitally reconstructed radiographs

DRR

DRR is a PyTorch module that compues differentiable digitally reconstructed radiographs. The viewing angle for the DRR (known generally in computer graphics as the camera pose) is parameterized by the following parameters:

  • SDD : source-to-detector distance (i.e., the focal length of the C-arm)
  • \(\mathbf R \in \mathrm{SO}(3)\) : a rotation
  • \(\mathbf t \in \mathbb R^3\) : a translation
Tip

DiffDRR can take a rotation parameterized in any of the following forms to move the detector plane:

If using Euler angles, the parameters are

  • alpha : Azimuthal angle
  • beta : Polar angle
  • gamma : Plane rotation angle
  • bx : X-dir translation
  • by : Y-dir translation
  • bz : Z-dir translation
  • convention : Order of angles (e.g., ZYX)

(bx, by, bz) are translational parameters and (alpha, beta, gamma) are rotational parameters.


source

DRR

 DRR (subject:torchio.data.subject.Subject, sdd:float, height:int,
      delx:float, width:int|None=None, dely:float|None=None, x0:float=0.0,
      y0:float=0.0, p_subsample:float|None=None, reshape:bool=True,
      reverse_x_axis:bool=True, patch_size:int|None=None,
      renderer:str='siddon', persistent:bool=True, **renderer_kwargs)

PyTorch module that computes differentiable digitally reconstructed radiographs.

Type Default Details
subject Subject TorchIO wrapper for the CT volume
sdd float Source-to-detector distance (i.e., the C-arm’s focal length)
height int Height of the rendered DRR
delx float X-axis pixel size
width int | None None Width of the rendered DRR (default to height)
dely float | None None Y-axis pixel size (if not provided, set to delx)
x0 float 0.0 Principal point X-offset
y0 float 0.0 Principal point Y-offset
p_subsample float | None None Proportion of pixels to randomly subsample
reshape bool True Return DRR with shape (b, 1, h, w)
reverse_x_axis bool True If True, obey radiologic convention (e.g., heart on right)
patch_size int | None None Render patches of the DRR in series
renderer str siddon Rendering backend, either “siddon” or “trilinear”
persistent bool True Set persistent value in torch.nn.Module.register_buffer
renderer_kwargs

The forward pass of the DRR module generated DRRs from the input CT volume. The pose parameters (i.e., viewing angles) from which the DRRs are generated are passed to the forward call.


source

DRR.render

 DRR.render (density:<built-inmethodtensoroftypeobjectat0x7f44262e4b00>,
             source:<built-inmethodtensoroftypeobjectat0x7f44262e4b00>,
             target:<built-inmethodtensoroftypeobjectat0x7f44262e4b00>,
             mask_to_channels:bool=False, **kwargs)
Type Default Details
density tensor Volume from which to render DRRs
source tensor World coordinates of X-ray source
target tensor World coordinates of X-ray target
mask_to_channels bool False If True, structures from the CT mask are rendered in separate channels
kwargs

source

DRR.forward

 DRR.forward (*args, parameterization:str=None, convention:str=None,
              calibration:diffdrr.pose.RigidTransform=None,
              mask_to_channels:bool=False, **kwargs)

Generate DRR with rotational and translational parameters.


source

DRR.rescale_detector_

 DRR.rescale_detector_ (scale:float)

Rescale the detector plane (inplace).


source

DRR.perspective_projection

 DRR.perspective_projection (pose:diffdrr.pose.RigidTransform,
                             pts:torch.Tensor)

Project points in world coordinates (3D) onto the pixel plane (2D).


source

DRR.inverse_projection

 DRR.inverse_projection (pose:diffdrr.pose.RigidTransform,
                         pts:torch.Tensor)

Backproject points in pixel plane (2D) onto the image plane in world coordinates (3D).