pytomography.io.PET.shared#
Module Contents#
Functions#
|
Obtains two tensors: the first yields the sinogram coordinates (r/theta) given two crystal IDs (shape [N_crystals_per_ring, N_crystals_per_ring, 2]), the second yields the sinogram index given two ring IDs (shape [Nrings, Nrings]) |
|
Returns two tensors: the first yields the detector coordinates (x1/y1/x2/y2) of each of the two crystals given the element of the sinogram (shape [N_crystals_per_ring, N_crystals_per_ring, 2, 2]), the second yields the ring coordinates (z1/z2) given two ring IDs (shape [Nrings*Nrings, 2]) |
|
Converts PET listmode data to sinogram |
|
Helper function to |
Obtain detector IDs from individual part IDs |
|
|
Get axial and transaxial IDs corresponding to each crystal in the scanner |
|
Obtains scanner lookup table (gives x/y/z coordinates for each detector ID) |
|
Obtains listmode data from a sinogram at the given detector IDs |
|
Smooths a PET randoms sinogram using a Gaussian filter in the r, theta, and z direction. Rebins the sinogram into (r,theta,z1,z2) before blurring (same blurring applied to z1 and z2) |
|
Converts a non-TOF randoms sinogram to a TOF randoms sinogram. |
- pytomography.io.PET.shared.sinogram_coordinates(info)[source]#
Obtains two tensors: the first yields the sinogram coordinates (r/theta) given two crystal IDs (shape [N_crystals_per_ring, N_crystals_per_ring, 2]), the second yields the sinogram index given two ring IDs (shape [Nrings, Nrings])
- Parameters:
info (dict) – PET geometry information dictionary
- Returns:
LOR coordinates and sinogram index lookup tensors
- Return type:
Sequence[torch.Tensor]
- pytomography.io.PET.shared.sinogram_to_spatial(info)[source]#
Returns two tensors: the first yields the detector coordinates (x1/y1/x2/y2) of each of the two crystals given the element of the sinogram (shape [N_crystals_per_ring, N_crystals_per_ring, 2, 2]), the second yields the ring coordinates (z1/z2) given two ring IDs (shape [Nrings*Nrings, 2])
- Parameters:
info (dict) – PET geometry information dictionary
- Returns:
Two tensors yielding spatial coordinates
- Return type:
Sequence[torch.Tensor]
- pytomography.io.PET.shared.listmode_to_sinogram(detector_ids, info, weights=None, normalization=False, tof_meta=None)[source]#
Converts PET listmode data to sinogram
- Parameters:
detector_ids (torch.Tensor) – Listmode detector ID data
info (dict) – PET geometry information dictionary
weights (torch.Tensor, optional) – Binning weights for each listmode event. Defaults to None.
normalization (bool, optional) – Whether or not this is a normalization sinogram (need to do some extra steps). Defaults to False.
tof_meta (PETTOFMeta, optional) – PET TOF metadata. Defaults to None.
- Returns:
PET sinogram
- Return type:
torch.Tensor
- pytomography.io.PET.shared._listmodeTOF_to_sinogramTOF(detector_ids, info, tof_meta, weights=None)[source]#
Helper function to
listmode_to_sinogramfor TOF data- Parameters:
detector_ids (torch.Tensor) – Listmode detector ID data
info (dict) – PET geometry information dictionary
weights (torch.Tensor, optional) – Binning weights for each listmode event. Defaults to None.
tof_meta (PETTOFMeta, optional) – PET TOF metadata. Defaults to None.
- Returns:
PET TOF sinogram
- Return type:
torch.Tensor
- pytomography.io.PET.shared.get_detector_ids_from_trans_axial_ids(ids_trans_crystal, ids_trans_submodule, ids_trans_module, ids_trans_rsector, ids_axial_crystal, ids_axial_submodule, ids_axial_module, ids_axial_rsector, info)[source]#
Obtain detector IDs from individual part IDs
- Parameters:
ids_trans_crystal (torch.Tensor) – Transaxial crystal IDs
ids_trans_submodule (torch.Tensor) – Transaxial submodule IDs
ids_trans_module (torch.Tensor) – Transaxial module IDs
ids_trans_rsector (torch.Tensor) – Transaxial rsector IDs
ids_axial_crystal (torch.Tensor) – Axial crystal IDs
ids_axial_submodule (torch.Tensor) – Axial submodule IDs
ids_axial_module (torch.Tensor) – Axial module IDs
ids_axial_rsector (torch.Tensor) – Axial rsector IDs
info (dict) – PET geometry information dictionary
- Returns:
Tensor containing (spatial) detector IDs
- Return type:
torch.Tensor
- pytomography.io.PET.shared.get_axial_trans_ids_from_info(info, return_combinations=False, sort_by_detector_ids=False)[source]#
Get axial and transaxial IDs corresponding to each crystal in the scanner
- Parameters:
info (dict) – PET geometry information dictionary
return_combinations (bool, optional) – Whether or not to return all possible combinations (crystal pairs). Defaults to False.
sort_by_detector_ids (bool, optional) – Whether or not to sort by increasing detector IDs. Defaults to False.
- Returns:
IDs corresponding to axial/transaxial components of each part
- Return type:
Sequence[torch.Tensor]
- pytomography.io.PET.shared.get_scanner_LUT(info)[source]#
Obtains scanner lookup table (gives x/y/z coordinates for each detector ID)
- Parameters:
info (dict) – PET geometry information dictionary
- Returns:
Lookup table
- Return type:
torch.Tensor[N_detectors, 3]
- pytomography.io.PET.shared.sinogram_to_listmode(detector_ids, sinogram, info)[source]#
Obtains listmode data from a sinogram at the given detector IDs
- Parameters:
detector_ids (torch.Tensor) – Detector IDs at which to obtain listmode data
sinogram (torch.Tensor) – PET sinogram
info (dict) – PET geometry information dictionary
- Returns:
Listmode data
- Return type:
torch.Tensor
- pytomography.io.PET.shared.smooth_randoms_sinogram(sinogram_random, info, sigma_r=4, sigma_theta=4, sigma_z=4, kernel_size_r=21, kernel_size_theta=21, kernel_size_z=21)[source]#
Smooths a PET randoms sinogram using a Gaussian filter in the r, theta, and z direction. Rebins the sinogram into (r,theta,z1,z2) before blurring (same blurring applied to z1 and z2)
- Parameters:
sinogram_random (torch.Tensor) – PET sinogram of randoms
info (dict) – PET geometry information dictionary
sigma_r (float, optional) – Blurring (in pixel size) in r direction. Defaults to 4.
sigma_theta (float, optional) – Blurring (in pixel size) in r direction. Defaults to 4.
sigma_z (float, optional) – Blurring (in pixel size) in z direction. Defaults to 4.
kernel_size_r (int, optional) – Kernel size in r direction. Defaults to 21.
kernel_size_theta (int, optional) – Kernel size in theta direction. Defaults to 21.
kernel_size_z (int, optional) – Kernel size in z1/z2 diretions. Defaults to 21.
- Returns:
Smoothed randoms sinogram
- Return type:
torch.Tensor
- pytomography.io.PET.shared.randoms_sinogram_to_sinogramTOF(sinogram_random, tof_meta, coincidence_timing_width)[source]#
Converts a non-TOF randoms sinogram to a TOF randoms sinogram.
- Parameters:
sinogram_random (torch.Tenor) – Randoms sinogram (non-TOF)
tof_meta (PETTOFMeta) – PET TOF metadata
coincidence_timing_width (float) – Coincidence timing width used for the acceptance of coincidence events
- Returns:
Randoms sinogram (TOF)
- Return type:
torch.Tensor