pytomography.projectors.PET
#
Submodules#
Package Contents#
Classes#
System matrix of PET list mode data. Forward projections corresponds to computing the expected counts along all LORs specified: in particular it approximates \(g_i = \int_{\text{LOR}_i} h(r) f(r) dr\) where index \(i\) corresponds to a particular detector pair and \(h(r)\) is a Gaussian function that incorporates time-of-flight information (\(h(r)=1\) for non-time-of-flight). The integral is approximated in the discrete object space using Joseph3D projections. In general, the system matrix implements two different projections, the quantity \(H\) which projects to LORs corresponding to all detected events, and the quantity \(\tilde{H}\) which projects to all valid LORs. The quantity \(H\) is used for standard forward/back projection, while \(\tilde{H}\) is used to compute the sensitivity image. |
- class pytomography.projectors.PET.PETLMSystemMatrix(object_meta, proj_meta, obj2obj_transforms=[], attenuation_map=None, N_splits=1, device=pytomography.device)[source]#
Bases:
pytomography.projectors.SystemMatrix
System matrix of PET list mode data. Forward projections corresponds to computing the expected counts along all LORs specified: in particular it approximates \(g_i = \int_{\text{LOR}_i} h(r) f(r) dr\) where index \(i\) corresponds to a particular detector pair and \(h(r)\) is a Gaussian function that incorporates time-of-flight information (\(h(r)=1\) for non-time-of-flight). The integral is approximated in the discrete object space using Joseph3D projections. In general, the system matrix implements two different projections, the quantity \(H\) which projects to LORs corresponding to all detected events, and the quantity \(\tilde{H}\) which projects to all valid LORs. The quantity \(H\) is used for standard forward/back projection, while \(\tilde{H}\) is used to compute the sensitivity image.
- Parameters:
object_meta (SPECTObjectMeta) – Metadata of object space, containing information on voxel size and dimensions.
proj_meta (PETLMProjMeta) – PET listmode projection space metadata. This information contains the detector ID pairs of all detected events, as well as a scanner lookup table and time-of-flight metadata. In addition, this meadata contains all information regarding event weights, typically corresponding to the effects of attenuation \(\mu\) and \(\eta\).
obj2obj_transforms (Sequence[Transform]) – Object to object space transforms applied before forward projection and after back projection. These are typically used for PSF modeling in PET imaging.
attenuation_map (torch.tensor[float] | None, optional) – Attenuation map used for attenuation modeling. If provided, all weights will be scaled by detection probabilities derived from this map. Note that this scales on top of any weights provided in
proj_meta
, so if attenuation is already accounted for there, this is not needed. Defaults to None.N_splits (int) – Splits up computation of forward/back projection to save GPU memory. Defaults to 1.
device (str) – The device on which forward/back projection tensors are output. This is seperate from
pytomography.device
, which handles internal computations. The reason for having the option of a second device is that the projection space may be very large, and certain GPUs may not have enough memory to store the projections. Ifdevice
is not the same aspytomography.device
, then one must also specify the samedevice
in any reconstruction algorithm used. Defaults topytomography.device
.
- set_n_subsets(n_subsets)[source]#
Returns a list where each element consists of an array of indices corresponding to a partitioned version of the projections.
- Parameters:
n_subsets (int) – Number of subsets to partition the projections into
- Returns:
List of arrays where each array corresponds to the projection indices of a particular subset.
- Return type:
list
- get_projection_subset(projections, subset_idx)[source]#
Obtains subsampled projections \(g_m\) corresponding to subset index \(m\). For LM PET, its always the case that \(g_m=1\), but this function is still required for subsampling scatter \(s_m\) as is required in certain reconstruction algorithms
- Parameters:
projections (torch.Tensor) – total projections \(g\)
subset_idx (int) – subset index \(m\)
- Returns:
subsampled projections \(g_m\).
- Return type:
torch.Tensor
- get_weighting_subset(subset_idx)[source]#
Computes the relative weighting of a given subset (given that the projection space is reduced). This is used for scaling parameters relative to \(\tilde{H}_m^T 1\) in reconstruction algorithms, such as prior weighting \(\beta\)
- Parameters:
subset_idx (int) – Subset index
- Returns:
Weighting for the subset.
- Return type:
float
- compute_atteunation_probability_projection(idx)[source]#
Computes probabilities of photons being detected along an LORs corresponding to
idx
.- Parameters:
idx (torch.tensor) – Indices of the detector pairs.
- Returns:
The probabilities of photons being detected along the detector pairs.
- Return type:
torch.Tensor
- compute_sens_factor(N_splits=10)[source]#
Computes the normalization factor \(\tilde{H}^T w\) where \(w\) is the weighting specified in the projection metadata that accounts for attenuation/normalization correction.
- Parameters:
N_splits (int, optional) – Optionally splits up computation to save memory on GPU. Defaults to 10.
- compute_normalization_factor(subset_idx=None)[source]#
Function called by reconstruction algorithms to get the sensitivty image \(\tilde{H}_m^T w\).
- Parameters:
subset_idx (int | None, optional) – Subset index \(m\). If none, then considers backprojection over all subsets. Defaults to None.
- Returns:
Normalization factor.
- Return type:
torch.tensor
- forward(object, subset_idx=None)[source]#
Computes forward projection. In the case of list mode PET, this corresponds to the expected number of detected counts along each LOR corresponding to a particular object.
- Parameters:
object (torch.tensor) – Object to be forward projected
subset_idx (int, optional) – Subset index \(m\) of the projection. If None, then assumes projection to the entire projection space. Defaults to None.
- Returns:
Projections corresponding to the expected number of counts along each LOR.
- Return type:
torch.tensor
- backward(proj, subset_idx=None, return_norm_constant=False)[source]#
Computes back projection. This corresponds to tracing a sequence of LORs into object space.
- Parameters:
proj (torch.tensor) – Projections to be back projected
subset_idx (int, optional) – Subset index \(m\) of the projection. If None, then assumes projection to the entire projection space. Defaults to None.
return_norm_constant (bool, optional) – Whether or not to return the normalization constant: useful in reconstruction algorithms that require \(H_m^T 1\). Defaults to False.
- Returns:
_description_
- Return type:
torch.tensor