pytomography.utils.misc#
Module Contents#
Functions#
|
Reverse cumulative sum along the first axis of a tensor of shape [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 |
Prints all the available SPECT collimator parameters |
|
|
Checks if class corresponding to instance implements the method |
|
Returns a 1D gaussian blurring kernel |
- pytomography.utils.misc.rev_cumsum(x)[source]#
Reverse cumulative sum along the first axis of a tensor of shape [Lx, Ly, Lz]. since this is used with SPECT attenuation correction, the initial voxel only contributes 1/2.
- Parameters:
x (torch.tensor[Lx,Ly,Lz]) – Tensor to be summed
- Returns:
The cumulatively summed tensor.
- Return type:
torch.tensor[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, mode='replicate')[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.print_collimator_parameters()[source]#
Prints all the available SPECT collimator parameters
- pytomography.utils.misc.check_if_class_contains_method(instance, method_name)[source]#
Checks if class corresponding to instance implements the method
method_name- Parameters:
instance (Object) – A python object
method_name (str) – Name of the method of the object being checked
- pytomography.utils.misc.get_1d_gaussian_kernel(sigma, kernel_size, padding_mode='zeros')[source]#
Returns a 1D gaussian blurring kernel
- Parameters:
sigma (float) – Sigma (in pixels) of blurring pixels
kernel_size (int) – Size of kernel used
padding_mode (str, optional) – Type of padding. Defaults to ‘zeros’.
- Returns:
Torch Conv1d layer corresponding to the gaussian kernel
- Return type:
Conv1d