kernel1d#

Module Contents#

Classes#

class kernel1d.Kernel1D(a_min, a_max)[source]#
Parameters:
  • a_min (float) –

  • a_max (float) –

normalization_constant(x, a)[source]#

Computes the normalization constant for the kernel

Parameters:
  • x (torch.Tensor[Lx]) – Positions where the kernel is being evaluated

  • a (torch.Tensor[Ld]) – Source-detector distances at which to compute the normalization constant

Returns:

Normalization constant at each source-detector distance

Return type:

torch.Tensor[Ld]

__call__(a)[source]#

Returns the kernel evaluated at each source detector distance

Parameters:
  • x (torch.Tensor[Lx]) – x values at which to evaluate the kernel

  • a (torch.Tensor[Ld]) – source-detector distances at which to evaluate the kernel

Returns:

Kernel evaluated at each source-detector distance and x value

Return type:

torch.Tensor[Ld, Lx]

class kernel1d.ArbitraryKernel1D(kernel, amplitude_fn, sigma_fn, amplitude_params, sigma_params, dx0, a_min=-torch.inf, a_max=torch.inf, grid_sample_mode='bilinear')[source]#

Bases: Kernel1D

Parameters:
  • kernel (torch.Tensor) –

  • amplitude_fn (Callable) –

  • sigma_fn (Callable) –

  • amplitude_params (torch.Tensor) –

  • sigma_params (torch.Tensor) –

  • dx0 (float) –

  • a_min (float) –

  • a_max (float) –

  • grid_sample_mode (str) –

normalization_constant(x, a)[source]#

Computes the normalization constant for the kernel

Parameters:
  • x (torch.Tensor[Lx]) – Positions where the kernel is being evaluated

  • a (torch.Tensor[Ld]) – Source-detector distances at which to compute the normalization constant

Returns:

Normalization constant at each source-detector distance

Return type:

torch.Tensor[Ld]

__call__(x, a, normalize=False)[source]#

Calls the kernel function

Parameters:
  • x (torch.Tensor[Lx]) – Positions where the kernel is being evaluated

  • a (torch.Tensor[Ld]) – Source-detector distances at which to compute the kernel

  • normalize (bool, optional) – Whether or not to normalize the output of the kernel. Defaults to False.

Returns:

Kernel evaluated at each source-detector distance and x value

Return type:

torch.Tensor[Ld,Lx]

class kernel1d.FunctionKernel1D(kernel_fn, amplitude_fn, sigma_fn, amplitude_params, sigma_params, a_min=-torch.inf, a_max=torch.inf)[source]#

Bases: Kernel1D

Parameters:
  • kernel_fn (Callable) –

  • amplitude_fn (Callable) –

  • sigma_fn (Callable) –

  • amplitude_params (torch.Tensor) –

  • sigma_params (torch.Tensor) –

_compute_norm_via_integral()[source]#

Compute the normalization constant by integrating k(x) 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.

Returns:

Integral of k(x) from -infinity to infinity

Return type:

torch.Tensor

normalization_constant(x, a)[source]#

Computes the normalization constant for the kernel

Parameters:
  • x (torch.Tensor[Lx]) – Positions where the kernel is being evaluated

  • a (torch.Tensor[Ld]) – Source-detector distances at which to compute the normalization constant

Returns:

Normalization constant at each source-detector distance

Return type:

torch.Tensor[Ld]

__call__(x, a, normalize=False)[source]#

Computes the kernel at each source-detector distance

Parameters:
  • x (torch.Tensor[Lx]) – Positions where the kernel is being evaluated

  • a (torch.Tensor[Ld]) – Source-detector distances at which to compute the kernel

  • normalize (bool, optional) – Whether or not to normalize the output. Defaults to False.

Returns:

Kernel evaluated at each source-detector distance and x value

Return type:

torch.Tensor[Ld,Lx]

class kernel1d.GaussianKernel1D(amplitude_fn, sigma_fn, amplitude_params, sigma_params, a_min=-torch.inf, a_max=torch.inf)[source]#

Bases: FunctionKernel1D

Parameters:
  • amplitude_fn (Callable) –

  • sigma_fn (Callable) –

  • amplitude_params (torch.Tensor) –

  • sigma_params (torch.Tensor) –

  • a_min (float) –

  • a_max (float) –

normalization_constant(x, a)[source]#

Computes the normalization constant for the kernel. For small FOV to sigma ratios, the normalization constant is computed using the definite integral of the kernel. For large FOV to sigma ratios, the normalization constant is computed by summing the values of the kernel; this prevents normalization errors when the Gaussian function is large compared to the pixel size.

Parameters:
  • x (torch.Tensor[Lx]) – Values at which to compute the kernel

  • a (torch.Tensor[Ld]) – Source-detector distances at which to compute the normalization constant

Returns:

Normalization constant at each source-detector distance

Return type:

torch.Tensor[Ld]