pytomography.projectors.SPECT.spect_system_matrix
#
Module Contents#
Classes#
System matrix for SPECT imaging. By default, this applies to parallel hole collimators, but appropriate use of proj2proj_transforms can allow this system matrix to also model converging/diverging collimator configurations as well. |
|
SPECT system matrix where the object space is a vector of length \(N\) consisting of the mean activities for each masks in |
- class pytomography.projectors.SPECT.spect_system_matrix.SPECTSystemMatrix(obj2obj_transforms, proj2proj_transforms, object_meta, proj_meta, n_parallel=1)[source]#
Bases:
pytomography.projectors.system_matrix.SystemMatrix
System matrix for SPECT imaging. By default, this applies to parallel hole collimators, but appropriate use of proj2proj_transforms can allow this system matrix to also model converging/diverging collimator configurations as well.
- Parameters:
obj2obj_transforms (Sequence[Transform]) – Sequence of object mappings that occur before forward projection.
proj2proj_transforms (Sequence[Transform]) – Sequence of proj mappings that occur after forward projection.
object_meta (SPECTObjectMeta) – SPECT Object metadata.
proj_meta (SPECTProjMeta) – SPECT projection metadata.
n_parallel (int) – Number of projections to use in parallel when applying transforms. More parallel events may speed up reconstruction time, but also increases GPU usage. Defaults to 1.
- compute_normalization_factor(subset_idx=None)[source]#
Function used to get normalization factor \(H^T_m 1\) corresponding to projection subset \(m\).
- Parameters:
subset_idx (int | None, optional) – Index of subset. If none, then considers all projections. Defaults to None.
- Returns:
normalization factor \(H^T_m 1\)
- Return type:
torch.Tensor
- set_n_subsets(n_subsets)[source]#
Sets the subsets for this system matrix given
n_subsets
total subsets.- Parameters:
n_subsets (int) – number of subsets used in OSEM
- Return type:
list
- get_projection_subset(projections, subset_idx)[source]#
Gets the subset of projections \(g_m\) corresponding to index \(m\).
- Parameters:
projections (torch.tensor) – full 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 \(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
- forward(object, subset_idx=None)[source]#
Applies forward projection to
object
for a SPECT imaging system.- Parameters:
object (torch.tensor[batch_size, Lx, Ly, Lz]) – The object to be forward projected
subset_idx (int, optional) – Only uses a subset of angles \(g_m\) corresponding to the provided subset index \(m\). If None, then defaults to the full projections \(g\).
- Returns:
forward projection estimate \(g_m=H_mf\)
- Return type:
torch.tensor
- backward(proj, subset_idx=None, return_norm_constant=False)[source]#
Applies back projection to
proj
for a SPECT imaging system.- Parameters:
proj (torch.tensor) – projections \(g\) which are to be back projected
subset_idx (int, optional) – Only uses a subset of angles \(g_m\) corresponding to the provided subset index \(m\). If None, then defaults to the full projections \(g\).
return_norm_constant (bool) – Whether or not to return \(H_m^T 1\) along with back projection. Defaults to ‘False’.
- Returns:
the object \(\hat{f} = H_m^T g_m\) obtained via back projection.
- Return type:
torch.tensor
- class pytomography.projectors.SPECT.spect_system_matrix.SPECTSystemMatrixMaskedSegments(obj2obj_transforms, proj2proj_transforms, object_meta, proj_meta, masks)[source]#
Bases:
SPECTSystemMatrix
SPECT system matrix where the object space is a vector of length \(N\) consisting of the mean activities for each masks in
masks
. This system matrix can be used in reconstruction algorithms to obtain maximum liklihood estimations for the average value of \(f\) inside each of the masks.- Parameters:
obj2obj_transforms (Sequence[Transform]) – Sequence of object mappings that occur before forward projection.
proj2proj_transforms (Sequence[Transform]) – Sequence of proj mappings that occur after forward projection.
object_meta (SPECTObjectMeta) – SPECT Object metadata.
proj_meta (SPECTProjMeta) – SPECT proj metadata.
masks (torch.Tensor) – Masks corresponding to each segmented region.
- forward(activities, angle_subset=None)[source]#
Implements forward projection \(HUa\) on a vector of activities \(a\) corresponding to self.masks.
- Parameters:
activities (torch.tensor[batch_size, n_masks]) – Activities in each mask region.
angle_subset (list, optional) – Only uses a subset of angles (i.e. only certain values of \(j\) in formula above) when back projecting. Useful for ordered-subset reconstructions. Defaults to None, which assumes all angles are used.
- Returns:
Forward projected projections where Ltheta is specified by self.proj_meta and angle_subset.
- Return type:
torch.tensor[batch_size, Ltheta, Lx, Lz]
- backward(proj, angle_subset=None, prior=None, normalize=False, return_norm_constant=False)[source]#
Implements back projection \(U^T H^T g\) on projections \(g\), returning a vector of activities for each mask region.
- Parameters:
proj (torch.tensor[batch_size, Ltheta, Lr, Lz]) – projections which are to be back projected
angle_subset (list, optional) – Only uses a subset of angles (i.e. only certain values of \(j\) in formula above) when back projecting. Useful for ordered-subset reconstructions. Defaults to None, which assumes all angles are used.
prior (Prior, optional) – If included, modifes normalizing factor to \(\frac{1}{\sum_j H_{ij} + P_i}\) where \(P_i\) is given by the prior. Used, for example, during in MAP OSEM. Defaults to None.
normalize (bool) – Whether or not to divide result by \(\sum_j H_{ij}\)
return_norm_constant (bool) – Whether or not to return \(1/\sum_j H_{ij}\) along with back projection. Defaults to ‘False’.
- Returns:
the activities in each mask region.
- Return type:
torch.tensor[batch_size, n_masks]