DecayFix#

class petpal.preproc.decay_correction.DecayFix(image_loader: petpal.io.image.ImageLoader | None = None)#

Bases: DecayCorrect

Special case for decay correction where the dynamic PET image was scaled with the wrong isotope but JSON metadata retains accurate decay correction factors.

fix_factor(input_image_path: str, isotope_to_remove: str) numpy.ndarray[float]#

Get ratio of the expected decay correction factor to the factor that was incorrectly applied to PET image.

Parameters:
  • input_image_path (str) – Path to dynamic PET image.

  • isotope_to_remove (str) – Name of the isotope that was incorrectly used to scale dynamic PET image, such as ‘o15’ or ‘c11’.

Returns:

fix_factor (np.ndarray[float])

Scalar array with the correction factor to apply to

each frame in dynamic PET.

__call__(input_image_path: str, output_image_path: str, isotope_to_remove: str)#

Calculate correction factor based on the accurate metadata and name of the isotope incorrectly used to scale image data.

Parameters:
  • input_image_path (str) – Path to dynamic PET image.

  • output_image_path (str) – Path to where corrected image is saved.

  • isotope_to_remove (str) – Name of the isotope that was incorrectly used to scale dynamic PET image, such as ‘o15’ or ‘c11’.

apply_factor(input_image_path: str, correction_factor: numpy.ndarray[float])#

Apply fix factor to image and write output.

Parameters:
  • input_image_path (str) – Path to dynamic PET image.

  • correction_factor_path (str) – Path to file with correction factors, one per frame. File must have exactly one column, with a header followed by one scalar per line.

save_modified_pet(input_image_path: str, output_image_path: str)#

Save the modified PET image

Parameters:
  • input_image_path (str) – Path to dynamic PET image.

  • output_image_path (str) – Path to where corrected image is saved.

decay_correct_factor_from_file(input_image_path: str, output_image_path: str, correction_factor_path: str)#

Apply a set of correction factors to each frame in a PET image.

Provide path to dynamic PET image, path to where corrected image is saved, and path to a file containing factors for each frame. File containing correction factors must have exactly one column, with a header followed by one scalar per line to apply to the corresponding frame in the PET. Reads image and correction factors, applies them, and saves result.

Parameters:
  • input_image_path (str) – Path to dynamic PET image.

  • output_image_path (str) – Path to where corrected image is saved.

  • correction_factor_path (str) – Path to file with correction factors, one per frame. File must have exactly one column, with a header followed by one scalar per line.