pytomography.transforms.SPECT.psf#

Module Contents#

Classes#

Seperable1DBlurNet

Network used to apply Gaussian blurring to each plane parallel to the detector head. The typical network used for low/medium energy SPECT PSF modeling.

PSF2D

SPECTPSFTransform

obj2obj transform used to model the effects of PSF blurring in SPECT. The smoothing kernel used to apply PSF modeling uses a Gaussian kernel with width \(\sigma\) dependent on the distance of the point to the detector; that information is specified in the SPECTPSFMeta parameter. There are a few potential arguments to initialize this transform (i) psf_meta, which contains relevant collimator information to obtain a Gaussian PSF model that works for low/medium energy SPECT (ii) kernel_f, an callable function that gives the kernel at any source-detector distance \(d\), or (iii) psf_operator, a network configured to automatically apply full PSF modeling to a given object \(f\) at all source-detector distances. Only one of the arguments should be given.

Functions#

get_1D_PSF_layer_gaussian(sigmas, kernel_size)

Creates a 1D convolutional layer that is used for PSF modeling.

get_1D_PSF_layer_square(sigmas, kernel_size)

class pytomography.transforms.SPECT.psf.Seperable1DBlurNet(layer_r, layer_z=None)[source]#

Bases: torch.nn.Module

Network used to apply Gaussian blurring to each plane parallel to the detector head. The typical network used for low/medium energy SPECT PSF modeling.

Parameters:
  • layer_r (nn.Conv1d) – Kernel used for blurring in radial direction

  • layer_z (nn.Conv1d | None) – Kernel used for blurring in sup/inf direction.

forward(input)[source]#

Applies PSF blurring to input. Each X-plane gets a different blurring kernel applied, depending on detector distance.

Parameters:

input (torch.tensor) – Object to apply Gaussian blurring to

Returns:

Blurred object, adjusted such that subsequent summation along the x-axis models the CDR

Return type:

torch.tensor

class pytomography.transforms.SPECT.psf.PSF2D(psf_operator, distances, kernel_size, dr)[source]#
__call__(input)[source]#
pytomography.transforms.SPECT.psf.get_1D_PSF_layer_gaussian(sigmas, kernel_size)[source]#

Creates a 1D convolutional layer that is used for PSF modeling.

Parameters:
  • sigmas (array) – Array of length Lx corresponding to blurring (sigma of Gaussian) as a function of distance from scanner

  • kernel_size (int) – Size of the kernel used in each layer. Needs to be large enough to cover most of Gaussian

Returns:

Convolutional neural network layer used to apply blurring to objects of shape [Lx, L1, L2] where Lx is treated as a batch size, L1 as the channel (or group index) and L2 is the axis being blurred over

Return type:

torch.nn.Conv2d

pytomography.transforms.SPECT.psf.get_1D_PSF_layer_square(sigmas, kernel_size)[source]#
Parameters:
  • sigmas (numpy.array) –

  • kernel_size (int) –

Return type:

torch.nn.Conv1d

class pytomography.transforms.SPECT.psf.SPECTPSFTransform(psf_meta=None, psf_operator=None, assume_padded=True)[source]#

Bases: pytomography.transforms.Transform

obj2obj transform used to model the effects of PSF blurring in SPECT. The smoothing kernel used to apply PSF modeling uses a Gaussian kernel with width \(\sigma\) dependent on the distance of the point to the detector; that information is specified in the SPECTPSFMeta parameter. There are a few potential arguments to initialize this transform (i) psf_meta, which contains relevant collimator information to obtain a Gaussian PSF model that works for low/medium energy SPECT (ii) kernel_f, an callable function that gives the kernel at any source-detector distance \(d\), or (iii) psf_operator, a network configured to automatically apply full PSF modeling to a given object \(f\) at all source-detector distances. Only one of the arguments should be given.

Parameters:
  • psf_meta (SPECTPSFMeta) – Metadata corresponding to the parameters of PSF blurring. In most cases (low/medium energy SPECT), this should be the only given argument.

  • kernel_f (Callable) – Function \(PSF(x,y,d)\) that gives PSF at every source-detector distance \(d\). It should be able to take in 1D numpy arrays as its first two arguments, and a single argument for the final argument \(d\). The function should return a corresponding 2D PSF kernel.

  • psf_operator (Callable) – Network that takes in an object \(f\) and applies all necessary PSF correction to return a new object \(\tilde{f}\) that is PSF corrected, such that subsequent summation along the x-axis accurately models the collimator detector response.

  • assume_padded (bool) –

_configure_simple_model()[source]#

Internal function to configure Gaussian modeling. This is called when psf_meta is given in initialization

_configure_manual_net()[source]#

Internal function to configure the PSF net. This is called when psf_operator is given in initialization

configure(object_meta, proj_meta)[source]#

Function used to initalize the transform using corresponding object and projection metadata

Parameters:
Return type:

None

_compute_kernel_size(radius, axis)[source]#

Function used to compute the kernel size used for PSF blurring. In particular, uses the min_sigmas attribute of SPECTPSFMeta to determine what the kernel size should be such that the kernel encompasses at least min_sigmas at all points in the object.

Returns:

The corresponding kernel size used for PSF blurring.

Return type:

int

_get_sigma(radius)[source]#

Uses PSF Meta data information to get blurring \(\sigma\) as a function of distance from detector.

Parameters:

radius (float) – The distance from the detector.

Returns:

An array of length Lx corresponding to blurring at each point along the 1st axis in object space

Return type:

array

forward(object, ang_idx)[source]#

Applies the PSF transform \(A:\mathbb{U} \to \mathbb{U}\) for the situation where an object is being detector by a detector at the \(+x\) axis.

Parameters:
  • object_i (torch.tensor) – Tensor of size [Lx, Ly, Lz] being projected along its first axis

  • ang_idx (int) – The projection indices: used to find the corresponding angle in projection space corresponding to each projection angle in object_i.

  • object (torch.Tensor) –

Returns:

Tensor of size [Lx, Ly, Lz] such that projection of this tensor along the first axis corresponds to n PSF corrected projection.

Return type:

torch.tensor

backward(object, ang_idx)[source]#

Applies the transpose of the PSF transform \(A^T:\mathbb{U} \to \mathbb{U}\) for the situation where an object is being detector by a detector at the \(+x\) axis. Since the PSF transform is a symmetric matrix, its implemtation is the same as the forward method.

Parameters:
  • object_i (torch.tensor) – Tensor of size [Lx, Ly, Lz] being projected along its first axis

  • ang_idx (int) – The projection index

  • object (torch.Tensor) –

Returns:

Tensor of size [Lx, Ly, Lz] such that projection of this tensor along the first axis corresponds to n PSF corrected projection.

Return type:

torch.tensor