:py:mod:`kernel1d` ================== .. py:module:: kernel1d Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: kernel1d.Kernel1D kernel1d.ArbitraryKernel1D kernel1d.FunctionKernel1D kernel1d.GaussianKernel1D .. py:class:: Kernel1D(a_min, a_max) .. py:method:: normalization_constant(x, a) Computes the normalization constant for the kernel :param x: Positions where the kernel is being evaluated :type x: torch.Tensor[Lx] :param a: Source-detector distances at which to compute the normalization constant :type a: torch.Tensor[Ld] :returns: Normalization constant at each source-detector distance :rtype: torch.Tensor[Ld] .. py:method:: __call__(a) Returns the kernel evaluated at each source detector distance :param x: x values at which to evaluate the kernel :type x: torch.Tensor[Lx] :param a: source-detector distances at which to evaluate the kernel :type a: torch.Tensor[Ld] :returns: Kernel evaluated at each source-detector distance and x value :rtype: torch.Tensor[Ld, Lx] .. py:class:: ArbitraryKernel1D(kernel, amplitude_fn, sigma_fn, amplitude_params, sigma_params, dx0, a_min = -torch.inf, a_max = torch.inf, grid_sample_mode = 'bilinear') Bases: :py:obj:`Kernel1D` .. py:method:: normalization_constant(x, a) Computes the normalization constant for the kernel :param x: Positions where the kernel is being evaluated :type x: torch.Tensor[Lx] :param a: Source-detector distances at which to compute the normalization constant :type a: torch.Tensor[Ld] :returns: Normalization constant at each source-detector distance :rtype: torch.Tensor[Ld] .. py:method:: __call__(x, a, normalize = False) Calls the kernel function :param x: Positions where the kernel is being evaluated :type x: torch.Tensor[Lx] :param a: Source-detector distances at which to compute the kernel :type a: torch.Tensor[Ld] :param normalize: Whether or not to normalize the output of the kernel. Defaults to False. :type normalize: bool, optional :returns: Kernel evaluated at each source-detector distance and x value :rtype: torch.Tensor[Ld,Lx] .. py:class:: FunctionKernel1D(kernel_fn, amplitude_fn, sigma_fn, amplitude_params, sigma_params, a_min=-torch.inf, a_max=torch.inf) Bases: :py:obj:`Kernel1D` .. py:method:: _compute_norm_via_integral() 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 :rtype: torch.Tensor .. py:method:: normalization_constant(x, a) Computes the normalization constant for the kernel :param x: Positions where the kernel is being evaluated :type x: torch.Tensor[Lx] :param a: Source-detector distances at which to compute the normalization constant :type a: torch.Tensor[Ld] :returns: Normalization constant at each source-detector distance :rtype: torch.Tensor[Ld] .. py:method:: __call__(x, a, normalize = False) Computes the kernel at each source-detector distance :param x: Positions where the kernel is being evaluated :type x: torch.Tensor[Lx] :param a: Source-detector distances at which to compute the kernel :type a: torch.Tensor[Ld] :param normalize: Whether or not to normalize the output. Defaults to False. :type normalize: bool, optional :returns: Kernel evaluated at each source-detector distance and x value :rtype: torch.Tensor[Ld,Lx] .. py:class:: GaussianKernel1D(amplitude_fn, sigma_fn, amplitude_params, sigma_params, a_min = -torch.inf, a_max = torch.inf) Bases: :py:obj:`FunctionKernel1D` .. py:method:: normalization_constant(x, a) 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. :param x: Values at which to compute the kernel :type x: torch.Tensor[Lx] :param a: Source-detector distances at which to compute the normalization constant :type a: torch.Tensor[Ld] :returns: Normalization constant at each source-detector distance :rtype: torch.Tensor[Ld]