plot_drr
def plot_drr(
img:torch.Tensor, title:str | None=None, ticks:bool | None=True, axs:matplotlib.axes._axes.Axes | None=None,
cmap:str='gray', **imshow_kwargs
):Plot an image generated by a DRR module.
Uses matplotlib and imageio to plot DRRs and animate optimization over DRRs.
Plot an image generated by a DRR module.
Plot a 2D rendered segmentation mask. Meant to be called after plot_drr.
Animate the optimization of a DRR.
df is a pandas.DataFrame with columns ["alpha", "beta", "gamma", "bx", "by", "bz"]. Each row in df is an iteration of optimization with the updated values for that timestep.
Uses pyvista and trame to interactively visualize DRR geometry in 3D.
def drr_to_mesh(
subject:Subject, # torchio.Subject with a `volume` attribute
method:str, # Either `surface_nets` or `marching_cubes`
threshold:float=150, # Min value for marching cubes (Hounsfield units)
extract_largest:bool=True, # Extract the largest connected component from the mesh
verbose:bool=True, # Display progress bars for mesh processing steps
):Convert the CT in a DRR object into a mesh.
If using method=="surface_nets", ensure you have pyvista>=0.43 and vtk>=9.3 installed.
The mesh processing steps are:
method=="marching_cubes")Call self as a function.
For a given pose (not batched), turn the camera and detector into a mesh. Additionally, render the DRR for the pose. Convert into a texture that can be applied to the detector mesh.
Add a camera to an existing scene.
Given a DRR and a RigidTransform, render the 3D scene in PyVista. **kwargs are passed to drr_to_mesh.