pytomography.projectors.system_matrix#

Module Contents#

Classes#

SystemMatrix

Abstract class for a general system matrix \(H:\mathbb{U} \to \mathbb{V}\) which takes in an object \(f \in \mathbb{U}\) and maps it to corresponding projections \(g \in \mathbb{V}\) that would be produced by the imaging system. A system matrix consists of sequences of object-to-object and proj-to-proj transforms that model various characteristics of the imaging system, such as attenuation and blurring. While the class implements the operator \(H:\mathbb{U} \to \mathbb{V}\) through the forward method, it also implements \(H^T:\mathbb{V} \to \mathbb{U}\) through the backward method, required during iterative reconstruction algorithms such as OSEM.

ExtendedSystemMatrix

Abstract class for a general system matrix \(H:\mathbb{U} \to \mathbb{V}\) which takes in an object \(f \in \mathbb{U}\) and maps it to corresponding projections \(g \in \mathbb{V}\) that would be produced by the imaging system. A system matrix consists of sequences of object-to-object and proj-to-proj transforms that model various characteristics of the imaging system, such as attenuation and blurring. While the class implements the operator \(H:\mathbb{U} \to \mathbb{V}\) through the forward method, it also implements \(H^T:\mathbb{V} \to \mathbb{U}\) through the backward method, required during iterative reconstruction algorithms such as OSEM.

class pytomography.projectors.system_matrix.SystemMatrix(obj2obj_transforms, proj2proj_transforms, object_meta, proj_meta)[source]#

Abstract class for a general system matrix \(H:\mathbb{U} \to \mathbb{V}\) which takes in an object \(f \in \mathbb{U}\) and maps it to corresponding projections \(g \in \mathbb{V}\) that would be produced by the imaging system. A system matrix consists of sequences of object-to-object and proj-to-proj transforms that model various characteristics of the imaging system, such as attenuation and blurring. While the class implements the operator \(H:\mathbb{U} \to \mathbb{V}\) through the forward method, it also implements \(H^T:\mathbb{V} \to \mathbb{U}\) through the backward method, required during iterative reconstruction algorithms such as OSEM.

Parameters:
  • obj2obj_transforms (Sequence[Transform]) – Sequence of object mappings that occur before forward projection.

  • im2im_transforms (Sequence[Transform]) – Sequence of proj mappings that occur after forward projection.

  • object_meta (ObjectMeta) – Object metadata.

  • proj_meta (ProjMeta) – Projection metadata.

  • proj2proj_transforms (list[pytomography.transforms.Transform]) –

initialize_transforms()[source]#

Initializes all transforms used to build the system matrix

abstract forward(object, **kwargs)[source]#

Implements forward projection \(Hf\) on an object \(f\).

Parameters:
  • object (torch.tensor[batch_size, Lx, Ly, Lz]) – The object to be forward 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.

Returns:

Forward projected proj where Ltheta is specified by self.proj_meta and angle_subset.

Return type:

torch.tensor[batch_size, Ltheta, Lx, Lz]

abstract backward(proj, angle_subset=None, return_norm_constant=False)[source]#

Implements back projection \(H^T g\) on a set of projections \(g\).

Parameters:
  • proj (torch.Tensor) – proj which is 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.

  • return_norm_constant (bool) – Whether or not to return \(1/\sum_j H_{ij}\) along with back projection. Defaults to ‘False’.

Returns:

the object obtained from back projection.

Return type:

torch.tensor[batch_size, Lr, Lr, Lz]

abstract get_subset_splits(n_subsets)[source]#

Returns a list of subsets corresponding to a partition of the projection data used in a reconstruction algorithm.

Parameters:

n_subsets (int) – number of subsets used in OSEM

Returns:

list of index arrays for each subset

Return type:

list

class pytomography.projectors.system_matrix.ExtendedSystemMatrix(system_matrices, obj2obj_transforms=None, proj2proj_transforms=None)[source]#

Bases: SystemMatrix

Abstract class for a general system matrix \(H:\mathbb{U} \to \mathbb{V}\) which takes in an object \(f \in \mathbb{U}\) and maps it to corresponding projections \(g \in \mathbb{V}\) that would be produced by the imaging system. A system matrix consists of sequences of object-to-object and proj-to-proj transforms that model various characteristics of the imaging system, such as attenuation and blurring. While the class implements the operator \(H:\mathbb{U} \to \mathbb{V}\) through the forward method, it also implements \(H^T:\mathbb{V} \to \mathbb{U}\) through the backward method, required during iterative reconstruction algorithms such as OSEM.

Parameters:
  • obj2obj_transforms (Sequence[Transform]) – Sequence of object mappings that occur before forward projection.

  • im2im_transforms (Sequence[Transform]) – Sequence of proj mappings that occur after forward projection.

  • object_meta (ObjectMeta) – Object metadata.

  • proj_meta (ProjMeta) – Projection metadata.

  • system_matrices (Sequence[SystemMatrix]) –

  • proj2proj_transforms (Sequence[pytomography.transforms.Transform]) –

forward(object, angle_subset=None)[source]#

Forward transform \(H' = \sum_n v_n \otimes B_n H_n A_n\), This adds an additional dimension to the projection space.

Parameters:
  • object (torch.Tensor[1,Lx,Ly,Lz]) – Object to be forward projected. Must have a batch size of 1.

  • angle_subset (Sequence[int], 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 projection.

Return type:

torch.Tensor[N_gates,…]

backward(proj, angle_subset=None)[source]#

Back projection \(H' = \sum_n v_n^T \otimes A_n^T H_n^T B_n^T\). This maps an extended projection back to the original object space.

Parameters:
  • proj (torch.Tensor[N,...]) – Projection data to be back-projected.

  • angle_subset (Sequence[int], 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.. Defaults to None.

Returns:

Back projection.

Return type:

torch.Tensor[1,Lx,Ly,Lz]

get_subset_splits(n_subsets)[source]#

Returns a list of subsets (where each subset contains indicies corresponding to different angles). For example, if the projections consisted of 6 total angles, then get_subsets_splits(2) would return [[0,2,4],[1,3,5]].

Parameters:

n_subsets (int) – number of subsets used in OSEM

Returns:

list of index arrays for each subset

Return type:

list

compute_normalization_factor(angle_subset=None)[source]#

Function called by reconstruction algorithms to get the normalization factor \(H' = \sum_n v_n^T \otimes A_n^T H_n^T B_n^T\) 1.

Returns:

Normalization factor.

Return type:

torch.Tensor[1,Lx,Ly,Lz]

Parameters:

angle_subset (list[int]) –