kernel2d#
Module Contents#
Classes#
Attributes#
- class kernel2d.Kernel2D(a_min, a_max)[source]#
- Parameters:
a_min (float) –
a_max (float) –
- normalization_constant(a)[source]#
Computes the normalization constant for the kernel at each source-detector distance a. This method should be implemented in the child class.
- Parameters:
a (torch.Tensor[Ld]) – Source detector distances
- Returns:
Normalization at each source-detector distance
- Return type:
torch.Tensor[Ld]
- __call__(yv, a)[source]#
Computes the kernel value at each point in the meshgrid defined by xv and yv for each source-detector distance a. This method should be implemented in the child class.
- Parameters:
xv (torch.Tensor[Lx,Ly]) – Meshgrid x-coordinates
yv (torch.Tensor[Lx,Ly]) – Meshgrid y-coordinates
a (torch.Tensor[Ld]) – Source-detector distances
- Returns:
Kernel values at each point in the meshgrid for each source-detector distance
- Return type:
torch.Tensor[Ld,Lx,Ly]
- class kernel2d.FunctionalKernel2D(kernel_fn, amplitude_fn, sigma_fn, amplitude_params, sigma_params, a_min=-torch.inf, a_max=torch.inf)[source]#
Bases:
Kernel2D- Parameters:
kernel_fn (Callable) –
amplitude_fn (Callable) –
sigma_fn (Callable) –
amplitude_params (torch.Tensor) –
sigma_params (torch.Tensor) –
a_min (float) –
a_max (float) –
- _compute_norm_via_integral()[source]#
Compute the normalization constant by integrating k(x,y) from -infinity to infinity. To do this, a variable transformation is used to convert the integral to a definite integral over the range [-pi/2, pi/2]. The definite integral is computed using the Simpson’s rule.
- Return type:
None
- normalization_constant(xv, yv, a)[source]#
Obtains the normalization constant for the 2D kernel
- Parameters:
xv (torch.Tensor[Lx,Ly]) – Meshgrid x-coordinates
yv (torch.Tensor[Lx,Ly]) – Meshgrid y-coordinates
a (torch.Tensor[Ld]) – Source-detector distances
- Returns:
Normalization constant at each source-detector distance
- Return type:
torch.Tensor[Ld]
- __call__(xv, yv, a, normalize=False)[source]#
Computes the kernel at each source detector distance
- Parameters:
xv (torch.Tensor[Lx,Ly]) – Meshgrid x-coordinates
yv (torch.Tensor[Lx,Ly]) – Meshgrid y-coordinates
a (torch.Tensor[Ld]) – Source-detector distances
normalize (bool, optional) – Whether or not to normalize the output of the kernel. Defaults to False.
- Returns:
Kernel at each source-detector distance
- Return type:
torch.Tensor[Ld,Lx,Ly]
- class kernel2d.NGonKernel2D(N_sides, Nx, collimator_width, amplitude_fn, sigma_fn, amplitude_params, sigma_params, a_min=-torch.inf, a_max=torch.inf, rot=0)[source]#
Bases:
Kernel2D- Parameters:
N_sides (int) –
Nx (int) –
collimator_width (float) –
amplitude_fn (Callable) –
sigma_fn (Callable) –
amplitude_params (torch.Tensor) –
sigma_params (torch.Tensor) –
rot (float) –
- normalization_constant(xv, yv, a)[source]#
Computes the normalization constant for the kernel at each source-detector distance a.
- Parameters:
xv (torch.Tensor[Lx,Ly]) – Meshgrid x-coordinates
yv (torch.Tensor[Lx,Ly]) – Meshgrid y-coordinates
a (torch.Tensor[Ld]) – Source-detector distances
- Returns:
Normalization constant at each source detector distance.
- Return type:
torch.Tensor[Ld]
- __call__(xv, yv, a, normalize=False)[source]#
Computes the kernel at each source detector distance
- Parameters:
xv (torch.Tensor[Lx,Ly]) – Meshgrid x-coordinates
yv (torch.Tensor[Lx,Ly]) – Meshgrid y-coordinates
a (torch.Tensor[Ld]) – Source-detector distances
normalize (bool, optional) – Whether or not to normalize the output of the kernel. Defaults to False.
- Returns:
Kernel at each source-detector distance
- Return type:
torch.Tensor[Ld,Lx,Ly]