pytomography.mappings.SPECT.psf - PyTomography 0.3.3 documentation

Hide navigation sidebar
Hide table of contents sidebar
Back to top
Toggle table of contents sidebar

# `pytomography.mappings.SPECT.psf`

## Module Contents

### Classes

`SPECTPSFNet` | obj2obj network 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 `PSFMeta` parameter.

### Functions

`get_PSF_transform`(sigma, kernel_size[, ...]) | Creates a 2D convolutional layer that is used for PSF modeling.

pytomography.mappings.SPECT.psf.get_PSF_transform(sigma, kernel_size, kernel_dimensions='2D', delta=1e-12, device=pytomography.device)

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

  Parameters:

    - sigma (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

    - delta (float, optional) – Used to prevent division by 0 when sigma=0. Defaults to 1e-9.

    - device (str, optional) – Pytorch device used for computation. Defaults to ‘cpu’.

    - kernel_dimensions (str, optional) – Whether or not blurring is done independently in each transaxial slice (‘1D’) or if blurring is done between transaxial slices (‘2D’). Defaults to ‘2D’.

  Returns:

    Convolutional neural network layer used to apply blurring to objects of shape [batch_size, Lx, Ly, Lz]

  Return type:

    torch.nn.Conv2d

class pytomography.mappings.SPECT.psf.SPECTPSFNet(psf_meta, device=None)

  Bases: `pytomography.mappings.MapNet`

  obj2obj network 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 `PSFMeta` parameter.

  Parameters:

    - psf_meta (PSFMeta) – Metadata corresponding to the parameters of PSF blurring

    - device (str, optional) – Pytorch device used for computation. If None, uses the default device pytomography.device Defaults to None.

  initialize_network(object_meta, image_meta)

    Function used to initalize the mapping network using corresponding object and image metadata

    Parameters:

      - object_meta (ObjectMeta) – Object metadata.

      - image_meta (ImageMeta) – Image metadata.

    Return type:

      None

  compute_kernel_size()

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

    Returns:

      The corresponding kernel size used for PSF blurring.

    Return type:

      int

  get_sigma(radius, dx, shape, collimator_slope, collimator_intercept)

    Uses PSF Meta data information to get blurring \(\sigma\) as a function of distance from detector. It is assumed that `sigma=collimator_slope*d + collimator_intercept` where \(d\) is the distance from the detector.

    Parameters:

      - radius (float) – The distance from the detector

      - dx (float) – Transaxial plane pixel spacing

      - shape (tuple) – Tuple containing (Lx, Ly, Lz): dimensions of object space

      - collimator_slope (float) – See collimator intercept

      - collimator_intercept (float) – Collimator slope and collimator intercept are defined such that sigma(d) = collimator_slope*d + collimator_intercept

      - detector. (where sigma corresponds to sigma of a Gaussian function that characterizes blurring as a function of distance from the) –

    Returns:

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

    Return type:

      array

  forward(object_i, i, norm_constant=None)

    Applies PSF modeling for the situation where an object is being detector by a detector at the \(+x\) axis.

    Parameters:

      - object_i (torch.tensor) – Tensor of size [batch_size, Lx, Ly, Lz] being projected along its first axis i (int): The projection index: used to find the corresponding angle in image space corresponding to object i norm_constant (torch.tensor, optional): A tensor used to normalize the output during back projection. Defaults to None.

      - i (int) –

      - norm_constant (torch.Tensor | None) –

    Returns:

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

        an PSF corrected projection.

    Return type:

      torch.tensor