custom_trajectory_3d#

diffct.geometry.custom_trajectory_3d(n_views, sid, sdd, source_path_fn, start_angle=0.0, device='cuda', dtype=torch.float32)[source]#

Generate custom trajectory geometry for cone-beam CT using user-defined function.

Creates a trajectory based on a user-provided function that defines the source position as a function of angle and SID.

Parameters:
  • n_views (int) – Number of projection views.

  • sid (float) – Source-to-Isocenter Distance (SID), in physical units.

  • sdd (float) – Source-to-Detector Distance (SDD), in physical units.

  • source_path_fn (Callable[[torch.Tensor, float], torch.Tensor]) – Function that takes (angles, sid) and returns source positions (n_views, 3). The function signature should be: f(angles: torch.Tensor, sid: float) -> torch.Tensor where angles has shape (n_views,) and output has shape (n_views, 3).

  • start_angle (float, optional) – Starting angle in radians (default: 0.0).

  • device (str or torch.device, optional) – Device for tensors (default: ‘cuda’).

  • dtype (torch.dtype, optional) – Data type for tensors (default: torch.float32).

Returns:

  • src_pos (torch.Tensor) – Source positions, shape (n_views, 3).

  • det_center (torch.Tensor) – Detector center positions, shape (n_views, 3).

  • det_u_vec (torch.Tensor) – Detector u-direction unit vectors, shape (n_views, 3).

  • det_v_vec (torch.Tensor) – Detector v-direction unit vectors, shape (n_views, 3).

Examples

>>> # Circular orbit with a two-lobe (figure-8) vertical motion
>>> def figure8_path(angles, sid):
...     src_pos = torch.zeros((len(angles), 3), device=angles.device, dtype=angles.dtype)
...     src_pos[:, 0] = -sid * torch.sin(angles)
...     src_pos[:, 1] = sid * torch.cos(angles)
...     src_pos[:, 2] = 50 * torch.sin(2 * angles)
...     return src_pos
>>>
>>> src_pos, det_center, det_u_vec, det_v_vec = custom_trajectory_3d(
...     n_views=360, sid=1000.0, sdd=1500.0, source_path_fn=figure8_path
... )