pytomography.io.PET.gate#

Module Contents#

Functions#

get_aligned_attenuation_map(headerfile, object_meta)

Returns an aligned attenuation map in units of inverse mm for reconstruction. This assumes that the attenuation map shares the same center point with the reconstruction space.

get_detector_info(path[, init_volume_name, ...])

Generates detector geometry information dictionary from GATE macro file

get_axial_trans_ids_from_ROOT(f, info[, j, substr])

Obtain transaxial and axial IDS (for crystals, submodules, modules, and rsectors) corresponding to each listmode event in an opened ROOT file

get_detector_ids_from_root(paths, info[, tof_meta, ...])

Obtain detector IDs corresponding to each listmode event in a set of ROOT files

get_symmetry_histogram_from_ROOTfile(f, info[, ...])

Obtains a histogram that exploits symmetries when computing normalization factors from calibration ROOT scans

get_symmetry_histogram_all_combos(info)

Obtains the symmetry histogram for detector sensitivity corresponding to all possible detector pair combinations

get_normalization_weights_cylinder_calibration(paths, ...)

Function to get sensitivty factor from a cylindrical calibration phantom

get_norm_sinogram_from_listmode_data(...)

Obtains normalization "sensitivty" sinogram from listmode data

get_norm_sinogram_from_root_data(normalization_paths, ...)

Obtain normalization "sensitivity" sinogram directly from ROOT files

get_sinogram_from_root_data(paths, info[, ...])

Get PET sinogram directly from ROOT data

get_radius(detector_ids, scanner_LUT)

Gets the radial position of all LORs

get_angle(detector_ids, scanner_LUT)

Gets the angular position of all LORs

remove_events_out_of_bounds(detector_ids, scanner_LUT, ...)

Removes all detected LORs outside of the reconstruced volume given by object_meta.

get_attenuation_map_nifti(path, object_meta)

pytomography.io.PET.gate.get_aligned_attenuation_map(headerfile, object_meta)[source]#

Returns an aligned attenuation map in units of inverse mm for reconstruction. This assumes that the attenuation map shares the same center point with the reconstruction space.

Parameters:
  • headerfile (str) – Filepath to the header file of the attenuation map

  • object_meta (ObjectMeta) – Object metadata providing spatial information about the reconstructed dimensions.

Returns:

Aligned attenuation map

Return type:

torch.Tensor

pytomography.io.PET.gate.get_detector_info(path, init_volume_name='crystal', mean_interaction_depth=0, min_rsector_difference=0)[source]#

Generates detector geometry information dictionary from GATE macro file

Parameters:
  • path (str) – Path to GATE macro file that defines geometry: should end in “.mac”

  • init_volume_name (str, optional) – Initial volume name in the GATE file. Defaults to ‘crystal’.

  • mean_interaction_depth (float, optional) – Mean interaction depth of photons within crystal. Defaults to 0.

  • min_rsector_difference (int, optional) – Minimum r_sector difference for retained events. Defaults to 0.

Returns:

PET geometry information dictionary

Return type:

dict

pytomography.io.PET.gate.get_axial_trans_ids_from_ROOT(f, info, j=None, substr='Coincidences')[source]#

Obtain transaxial and axial IDS (for crystals, submodules, modules, and rsectors) corresponding to each listmode event in an opened ROOT file

Parameters:
  • f (object) – Opened ROOT file

  • info (dict) – PET geometry information dictionary

  • j (int, optional) – Which of the detectors to consider in a coincidence event OR which detector to consider for a single (None). Defaults to None.

  • substr (str, optional) – Whether to consider coincidences or singles. Defaults to ‘Coincidences’.

Returns:

Sequence of IDs (transaxial/axial) for all components (crystals, submodules, modules, and rsectors)

Return type:

Sequence[torch.Tensor]

pytomography.io.PET.gate.get_detector_ids_from_root(paths, info, tof_meta=None, substr='Coincidences', include_randoms=True, include_scatters=True, randoms_only=False, scatters_only=False)[source]#

Obtain detector IDs corresponding to each listmode event in a set of ROOT files

Parameters:
  • paths (Sequence[str]) – List of ROOT files to consider

  • info (dict) – PET geometry information dictionary

  • tof_meta (PETTOFMeta, optional) – PET time of flight metadata for binning. If none, then TOF is not considered Defaults to None.

  • substr (str, optional) – Name of events to consider in the ROOT file. Defaults to ‘Coincidences’.

  • include_randoms (bool, optional) – Whether or not to include random events in the returned listmode events. Defaults to True.

  • include_scatters (bool, optional) – Whether or not to include scatter events in the returned listmode events. Defaults to True.

  • randoms_only (bool, optional) – Flag to return only random events. Defaults to False.

  • scatters_only (bool, optional) – Flag to return only scatter events. Defaults to False.

Returns:

Tensor of shape [N_events,2] (non-TOF) or [N_events,3] (TOF)

Return type:

torch.Tensor

pytomography.io.PET.gate.get_symmetry_histogram_from_ROOTfile(f, info, substr='Coincidences', include_randoms=True)[source]#

Obtains a histogram that exploits symmetries when computing normalization factors from calibration ROOT scans

Parameters:
  • f (object) – Opened ROOT file

  • info (dict) – PET geometry information dictionary

  • substr (str, optional) – Name of events to consider in ROOT file. Defaults to ‘Coincidences’.

  • include_randoms (bool, optional) – Whether or not to include random events from data. Defaults to True.

Returns:

Symmetry histogram

Return type:

torch.Tensor

pytomography.io.PET.gate.get_symmetry_histogram_all_combos(info)[source]#

Obtains the symmetry histogram for detector sensitivity corresponding to all possible detector pair combinations

Parameters:

info (dict) – PET geometry information dictionary

Returns:

Histogram corresponding to all possible detector pair combinations. This simply counts the number of detector pairs in each bin of the histogram.

Return type:

torch.Tensor

pytomography.io.PET.gate.get_normalization_weights_cylinder_calibration(paths, info, cylinder_radius, include_randoms=True)[source]#

Function to get sensitivty factor from a cylindrical calibration phantom

Parameters:
  • paths (Sequence[str]) – List of paths corresponding to calibration scan

  • info (dict) – PET geometry information dictionary

  • cylinder_radius (float) – Radius of cylindrical phantom used in scan

  • include_randoms (bool, optional) – Whether or not to include random events from the cylinder calibration. Defaults to True.

Returns:

Sensitivty factor for all possible detector combinations

Return type:

torch.tensor

pytomography.io.PET.gate.get_norm_sinogram_from_listmode_data(weights_sensitivity, info)[source]#

Obtains normalization “sensitivty” sinogram from listmode data

Parameters:
  • weights_sensitivity (torch.Tensor) – Sensitivty weight corresponding to all possible detector pairs

  • info (dict) – PET geometry information dictionary

Returns:

PET sinogram

Return type:

torch.Tensor

pytomography.io.PET.gate.get_norm_sinogram_from_root_data(normalization_paths, info, cylinder_radius, include_randoms=True)[source]#

Obtain normalization “sensitivity” sinogram directly from ROOT files

Parameters:
  • normalization_paths (Sequence[str]) – Paths to all ROOT files corresponding to calibration scan

  • info (dict) – PET geometry information dictionary

  • cylinder_radius (float) – Radius of cylinder used in calibration scan

  • include_randoms (bool, optional) – Whether or not to include randoms in loaded data. Defaults to True.

Returns:

PET sinogram

Return type:

torch.Tensor

pytomography.io.PET.gate.get_sinogram_from_root_data(paths, info, include_randoms=True, include_scatters=True, randoms_only=False, scatters_only=False)[source]#

Get PET sinogram directly from ROOT data

Parameters:
  • paths (Sequence[str]) – GATE generated ROOT files

  • info (dict) – PET geometry information dictionary

  • include_randoms (bool, optional) – Whether or not to include random events in the sinogram. Defaults to True.

  • include_scatters (bool, optional) – Whether or not to include scatter events in the sinogram. Defaults to True.

  • randoms_only (bool, optional) – Flag for only binning randoms. Defaults to False.

  • scatters_only (bool, optional) – Flag for only binning scatters. Defaults to False.

Returns:

PET sinogram

Return type:

torch.Tensor

pytomography.io.PET.gate.get_radius(detector_ids, scanner_LUT)[source]#

Gets the radial position of all LORs

Parameters:
  • detector_ids (torch.tensor) – Detector ID pairs corresponding to LORs

  • scanner_LUT (torch.tensor) – scanner look up table

Returns:

radii of all detector ID pairs provided

Return type:

torch.tensor

pytomography.io.PET.gate.get_angle(detector_ids, scanner_LUT)[source]#

Gets the angular position of all LORs

Parameters:
  • detector_ids (torch.tensor) – Detector ID pairs corresponding to LORs

  • scanner_LUT (torch.tensor) – scanner look up table

Returns:

angle of all detector ID pairs provided

Return type:

torch.tensor

pytomography.io.PET.gate.remove_events_out_of_bounds(detector_ids, scanner_LUT, object_meta)[source]#

Removes all detected LORs outside of the reconstruced volume given by object_meta.

Parameters:
  • detector_ids (torch.tensor) – \(N \times 2\) (non-TOF) or \(N \times 3\) (TOF) tensor that provides detector ID pairs (and TOF bin) for coincidence events.

  • scanner_LUT (torch.tensor) – scanner lookup table that provides spatial coordinates for all detector ID pairs

  • object_meta (ObjectMeta) – object metadata providing the region of reconstruction

Returns:

all detector ID pairs corresponding to coincidence events

Return type:

torch.tensor

pytomography.io.PET.gate.get_attenuation_map_nifti(path, object_meta)[source]#