pytomography.utils.sss#

Module Contents#

Functions#

total_compton_cross_section(energy)

Computes the total compton cross section of interaction \(\sigma\) at the given photon energies

photon_energy_after_compton_scatter_511kev(cos_theta)

Computes the corresponding photon energy after a 511keV photon scatters

diff_compton_cross_section(cos_theta, energy)

Computes the differential cross section \(d\sigma/d\omega\) at given photon energies and scattering angles

detector_efficiency(scatter_energy[, ...])

Computes the probability a photon of given energy is detected within the energy limits of the detector

tof_efficiency(offset, tof_bins_dense_centers, tof_meta)

Computes the probability that a coincidence event with timing difference offset is detected in each of the TOF bins specified by tof_bins_dense_centers.

get_sample_scatter_points(attenuation_map[, stepsize, ...])

Selects a subset of points in the attenuation map used as scatter points.

get_sample_detector_ids(proj_meta[, ...])

Selects a subset of detector IDs in the PET scanner used for obtaining scatter estimates in the sparse sinogram

compute_sss_sparse_sinogram(object_meta, proj_meta, ...)

Generates a sparse single scatter simulation sinogram for non-TOF PET data.

compute_sss_sparse_sinogram_TOF(object_meta, ...[, ...])

Generates a sparse single scatter simulation sinogram for TOF PET data.

interpolate_sparse_sinogram(scatter_sinogram_sparse, ...)

Interpolates a sparse SSS sinogram estimate using linear interpolation on all oblique planes.

scale_estimated_scatter(proj_scatter, system_matrix, ...)

Given an interpolated (but unscaled) SSS sinogram/listmode, scales the scatter estimate by considering back projection of masked data. The mask corresponds to all locations below a certain attenuation value, where it is likely that all detected events are purely due to scatter.

get_sss_scatter_estimate(object_meta, proj_meta, ...)

Main function used to get SSS scatter estimation during PET reconstruction

pytomography.utils.sss.total_compton_cross_section(energy)[source]#

Computes the total compton cross section of interaction \(\sigma\) at the given photon energies

Parameters:

energy (torch.Tensor) – Energies of photons considered

Returns:

Cross section at each corresponding energy

Return type:

torch.Tensor

pytomography.utils.sss.photon_energy_after_compton_scatter_511kev(cos_theta)[source]#

Computes the corresponding photon energy after a 511keV photon scatters

Parameters:

cos_theta (torch.Tensor) – Angle of scatter

Returns:

Photon energy after scattering.

Return type:

torch.Tensor

pytomography.utils.sss.diff_compton_cross_section(cos_theta, energy)[source]#

Computes the differential cross section \(d\sigma/d\omega\) at given photon energies and scattering angles

Parameters:
  • cos_theta (torch.Tensor) – Cosine of the scattering angle

  • energy (torch.Tensor) – Energy of the incident photon before scattering

Returns:

Differential compton cross section

Return type:

torch.Tensor

pytomography.utils.sss.detector_efficiency(scatter_energy, energy_resolution=0.15, energy_threshhold=430)[source]#

Computes the probability a photon of given energy is detected within the energy limits of the detector

Parameters:
  • scatter_energy (torch.Tensor) – Energy of the photon impinging the detector

  • energy_resolution (float, optional) – Energy resolution of the crystals (represented as a fraction of 511keV). This is the uncertainty of energy measurements. Defaults to 0.15.

  • energy_threshhold (float, optional) – Lower limit of energies detected by the crystal which are registered as events. Defaults to 430.

Returns:

Probability that the photon gets detected

Return type:

torch.Tensor

pytomography.utils.sss.tof_efficiency(offset, tof_bins_dense_centers, tof_meta)[source]#

Computes the probability that a coincidence event with timing difference offset is detected in each of the TOF bins specified by tof_bins_dense_centers.

Parameters:
  • offset (torch.Tensor) – Timing offset (in spatial units) between a coincidence event. When this function is used in SSS, offset has shape \((N_{TOF}, N_{coinc})\) where \(N_{coinc}\) is the number of coincidence events considered, and \(N_{TOF}\) is the number of time of flight bins in the sinogram.

  • tof_bins_dense_centers (torch.Tensor) – The centers of each of the dense TOF bins. These are seperate from the TOF bins of the sinogram: these TOF bins correspond to the partioning of the integrals in Watson(2007) Equation 2. When used in SSS, this tensor has shape \((N_{coinc}, N_{denseTOF})\) where \(N_{denseTOF}\) are the number of dense TOF bins considered.

  • tof_meta (PETTOFMeta) – TOF metadata for the sinogram

Returns:

Relative probability of detecting the event at offset offset in each of the tof_bins_dense_centers locations.

Return type:

torch.Tensor

pytomography.utils.sss.get_sample_scatter_points(attenuation_map, stepsize=4, attenuation_cutoff=0.004)[source]#

Selects a subset of points in the attenuation map used as scatter points.

Parameters:
  • attenuation_map (torch.Tensor) – Attenuation map

  • stepsize (float, optional) – Stepsize in x/y/z between sampled points. Defaults to 4.

  • attenuation_cutoff (float, optional) – Only consider points above this threshhold. Defaults to 0.004.

Returns:

Tensor of coordinates

Return type:

torch.Tensor

pytomography.utils.sss.get_sample_detector_ids(proj_meta, sinogram_interring_stepsize=4, sinogram_intraring_stepsize=4)[source]#

Selects a subset of detector IDs in the PET scanner used for obtaining scatter estimates in the sparse sinogram

Parameters:
  • proj_meta (ProjMeta) – PET projection metadata (sinogram/listmode)

  • sinogram_interring_stepsize (int, optional) – Axial stepsize between rings. Defaults to 4.

  • sinogram_intraring_stepsize (int, optional) – Stepsize of crystals within a given ring. Defaults to 4.

Returns:

Crystal index within ring, ring index, and detector ID pairs corresponding to all sampled LORs.

Return type:

Sequence[torch.Tensor, torch.Tensor, torch.Tensor]

pytomography.utils.sss.compute_sss_sparse_sinogram(object_meta, proj_meta, pet_image, attenuation_image, image_stepsize=4, attenuation_cutoff=0.004, sinogram_interring_stepsize=4, sinogram_intraring_stepsize=4)[source]#

Generates a sparse single scatter simulation sinogram for non-TOF PET data.

Parameters:
  • object_meta (ObjectMeta) – Object metadata corresponding to reconstructed PET image used in the simulation

  • proj_meta (ProjMeta) – Projection metadata specifying the details of the PET scanner

  • pet_image (torch.Tensor) – PET image used to estimate the scatter

  • attenuation_image (torch.Tensor) – Attenuation map used in scatter simulation

  • image_stepsize (int, optional) – Stepsize in x/y/z between sampled scatter points. Defaults to 4.

  • attenuation_cutoff (float, optional) – Only consider points above this threshhold. Defaults to 0.004.

  • sinogram_interring_stepsize (int, optional) – Axial stepsize between rings. Defaults to 4.

  • sinogram_intraring_stepsize (int, optional) – Stepsize of crystals within a given ring. Defaults to 4.

Returns:

Estimated sparse single scatter simulation sinogram.

Return type:

torch.Tensor

pytomography.utils.sss.compute_sss_sparse_sinogram_TOF(object_meta, proj_meta, pet_image, attenuation_image, tof_meta, image_stepsize=4, attenuation_cutoff=0.004, sinogram_interring_stepsize=4, sinogram_intraring_stepsize=4, num_dense_tof_bins=25, N_splits=1)[source]#

Generates a sparse single scatter simulation sinogram for TOF PET data.

Parameters:
  • object_meta (ObjectMeta) – Object metadata corresponding to reconstructed PET image used in the simulation

  • proj_meta (ProjMeta) – Projection metadata specifying the details of the PET scanner

  • pet_image (torch.Tensor) – PET image used to estimate the scatter

  • attenuation_image (torch.Tensor) – Attenuation map used in scatter simulation

  • tof_meta (PETTOFMeta) – PET TOF Metadata corresponding to the sinogram estimate

  • attenuation_image – Attenuation map used in scatter simulation

  • image_stepsize (int, optional) – Stepsize in x/y/z between sampled scatter points. Defaults to 4.

  • attenuation_cutoff (float, optional) – Only consider points above this threshhold. Defaults to 0.004.

  • sinogram_interring_stepsize (int, optional) – Axial stepsize between rings. Defaults to 4.

  • sinogram_intraring_stepsize (int, optional) – Stepsize of crystals within a given ring. Defaults to 4.

  • num_dense_tof_bins (int, optional) – Number of dense TOF bins used when partioning the emission integrals (these integrals must be partioned for TOF-based estimation). Defaults to 25.

  • N_splits (int) –

Returns:

Estimated sparse single scatter simulation sinogram.

Return type:

torch.Tensor

pytomography.utils.sss.interpolate_sparse_sinogram(scatter_sinogram_sparse, proj_meta, idx_intraring, idx_ring)[source]#

Interpolates a sparse SSS sinogram estimate using linear interpolation on all oblique planes.

Parameters:
  • scatter_sinogram_sparse (torch.Tensor) – Estimated sparse SSS sinogram from the compute_sss_sparse_sinogram or compute_sss_sparse_sinogram_TOF functions

  • proj_meta (ProjMeta) – PET projection metadata corresponding to the sinogram

  • idx_intraring (torch.Tensor) – Intraring indices corresponding to non-zero locations of the sinogram (obtained via the get_sample_detector_ids function)

  • idx_ring (torch.Tensor) – Interring indices corresponding to non-zero locations of the sinogram (obtained via the get_sample_detector_ids function)

Returns:

Interpolated SSS sinogram

Return type:

torch.Tensor

pytomography.utils.sss.scale_estimated_scatter(proj_scatter, system_matrix, proj_data, attenuation_image, attenuation_image_cutoff=0.004, sinogram_random=None)[source]#

Given an interpolated (but unscaled) SSS sinogram/listmode, scales the scatter estimate by considering back projection of masked data. The mask corresponds to all locations below a certain attenuation value, where it is likely that all detected events are purely due to scatter.

Parameters:
  • proj_scatter (torch.Tensor) – Estimated (but unscaled) SSS data.

  • system_matrix (SystemMatrix) – PET system matrix

  • proj_data (torch.Tensor) – PET projection data corresponding to all detected events

  • attenuation_image (torch.Tensor) – Attenuation map

  • attenuation_image_cutoff (float, optional) – Mask considers regions below this value (forward projected). In particular, the attenuation map is masked above this value, then forward projected. Regions equal to zero in the forward projection are considered for the mask. This allows for hollow regions within the attenuation map to still be considered. Defaults to 0.004.

  • sinogram_random (torch.Tensor | None, optional) – Projection data of estimated random events. Defaults to None.

Returns:

Scaled SSS projection data (sinogram/listmode).

Return type:

torch.Tensor

pytomography.utils.sss.get_sss_scatter_estimate(object_meta, proj_meta, pet_image, attenuation_image, system_matrix, proj_data=None, image_stepsize=4, attenuation_cutoff=0.004, sinogram_interring_stepsize=4, sinogram_intraring_stepsize=4, sinogram_random=None, tof_meta=None, num_dense_tof_bins=25, N_splits=1)[source]#

Main function used to get SSS scatter estimation during PET reconstruction

Parameters:
  • object_meta (ObjectMeta) – Object metadata corresponding to pet_image.

  • proj_meta (ProjMeta) – Projection metadata corresponding to proj_data.

  • pet_image (torch.Tensor) – Reconstructed PET image used to get SSS estimate

  • attenuation_image (torch.Tensor) – Attenuation map corresponding to PET image

  • system_matrix (SystemMatrix) – PET system matrix

  • proj_data (torch.Tensor | None) – All measured coincident events (sinogram/listmode). If None, then assumes listmode (coincidence events stored in proj_meta).

  • image_stepsize (int, optional) – Spacing between points in object space used to obtain initial sparse sinogram estimate. Defaults to 4.

  • attenuation_cutoff (float, optional) – Only consider point located at attenuation values above this value as scatter points. Defaults to 0.004.

  • sinogram_interring_stepsize (int, optional) – Sinogram interring spacing for initial sparse sinogram estimate. Defaults to 4.

  • sinogram_intraring_stepsize (int, optional) – Sinogram intraring spacing for initial sparse sinogram estimate. Defaults to 4.

  • sinogram_random (torch.Tensor | None, optional) – Estimated randoms. Defaults to None.

  • tof_meta (PETTOFMeta, optional) – TOFMetadata corresponding to proj_data (if TOF is considered). Defaults to None.

  • num_dense_tof_bins (int, optional) – Number of dense TOF bins to use for partioning emission integrals when performing a TOF estimate. This is seperate from TOF bins used in the PET data. Defaults to 25.

  • N_splits (int, optional) – Splits the TOF bins into subsets and loops over them sequentially (as opposed to parallel) for scatter estimation. Defaults to 1.

Returns:

Estimated SSS projection data (sinogram/listmode)

Return type:

torch.Tensor