DRR
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
DiffDRR
can take a rotation parameterized in any of the following forms to move the detector plane:
axis_angle
euler_angles
(note: also need to specify theconvention
for the Euler angles)matrix
quaternion
quaternion_adjugate
(Hanson and Hanson, 2022)rotation_6d
(Zhou et al., 2019)rotation_10d
(Peretroukhin et al., 2021)`se3_log_map
If using Euler angles, the parameters are
alpha
: Azimuthal anglebeta
: Polar anglegamma
: Plane rotation anglebx
: X-dir translationby
: Y-dir translationbz
: Z-dir translationconvention
: Order of angles (e.g.,ZYX
)
(bx, by, bz)
are translational parameters and (alpha, beta, gamma)
are rotational parameters.
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.
DRR.render
DRR.render (density:<built-inmethodtensoroftypeobjectat0x7f8687e91080>, source:<built-inmethodtensoroftypeobjectat0x7f8687e91080>, target:<built-inmethodtensoroftypeobjectat0x7f8687e91080>, 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 |
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.
DRR.rescale_detector_
DRR.rescale_detector_ (scale:float)
Rescale the detector plane (inplace).
DRR.perspective_projection
DRR.perspective_projection (pose:diffdrr.pose.RigidTransform, pts:torch.Tensor)
Project points in world coordinates (3D) onto the pixel plane (2D).
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).