pytomography.utils.misc
#
Module Contents#
Functions#
|
Reverse cumulative sum along the first axis of a tensor of shape [batch_size, Lx, Ly, Lz]. |
|
Given the radial distance to center of object space from the scanner, computes the distance between each parallel plane (i.e. (y-z plane)) and a detector located at +x. This function is used for SPECT PSF modeling where the amount of blurring depends on thedistance from the detector. |
|
Given an object tensor, finds the nearest neighbour (corresponding to |
|
Obtains the number of blank z-slices at the sup ( |
Prints all the available SPECT collimator parameters |
- pytomography.utils.misc.rev_cumsum(x)[source]#
Reverse cumulative sum along the first axis of a tensor of shape [batch_size, Lx, Ly, Lz]. since this is used with SPECT attenuation correction, the initial voxel only contributes 1/2.
- Parameters:
x (torch.tensor[batch_size,Lx,Ly,Lz]) – Tensor to be summed
- Returns:
The cumulatively summed tensor.
- Return type:
torch.tensor[batch_size, Lx, Ly, Lz]
- pytomography.utils.misc.get_distance(Lx, r, dx)[source]#
Given the radial distance to center of object space from the scanner, computes the distance between each parallel plane (i.e. (y-z plane)) and a detector located at +x. This function is used for SPECT PSF modeling where the amount of blurring depends on thedistance from the detector.
- Parameters:
Lx (int) – The number of y-z planes to compute the distance of
r (float) – The radial distance between the central y-z plane and the detector at +x.
dx (float) – The spacing between y-z planes in Euclidean distance.
- Returns:
An array of distances for each y-z plane to the detector.
- Return type:
np.array[Lx]
- pytomography.utils.misc.get_object_nearest_neighbour(object, shifts)[source]#
Given an object tensor, finds the nearest neighbour (corresponding to
shifts
) for each voxel (done by shifting object by i,j,k)- Parameters:
object (torch.Tensor) – Original object
shifts (list[int]) – List of three integers [i,j,k] corresponding to neighbour location
- Returns:
Shifted object whereby each voxel corresponding to neighbour [i,j,k] of the
object
.- Return type:
torch.Tensor
- pytomography.utils.misc.get_blank_below_above(proj)[source]#
Obtains the number of blank z-slices at the sup (
blank_above
) and inf (blank_below
) of the projection data. This method is entirely empircal, and looks for z slices where there are zero detected counts.- Parameters:
proj (torch.tensor) – Projection data from a scanner
- Returns:
A tuple of two elements corresponding to the number of blank slices at the inf, and the number of blank slices at the sup.
- Return type:
Sequence[int]