ParametricGraphicalAnalysisStep#

class petpal.pipelines.kinetic_modeling_steps.ParametricGraphicalAnalysisStep(input_tac_path: str, input_image_path: str, output_directory: str, output_prefix: str, method: str, fit_threshold_in_mins: float = 30.0, **run_kwargs)#

Bases: petpal.pipelines.steps_base.ObjectBasedStep, TACAnalysisStepMixin

A step for performing parametric graphical analysis on TACs using various methods using GraphicalAnalysisParametricImage

This class sets up parametric graphical analysis, initializes required paths and parameters, and provides class methods for creating default steps with common graphical analysis methods like Patlak, Logan, and Alternative Logan.

Variables:
  • input_tac_path (str) – Path to the input TAC file.

  • input_image_path (str) – Path to the input image file.

  • output_directory (str) – Directory where output files will be saved.

  • output_prefix (str) – Prefix for the output files.

  • method (str) – Graphical analysis method.

  • fit_threshold_in_mins (float) – Threshold in minutes for fitting. Defaults to 30.0.

Initializes the ParametricGraphicalAnalysisStep with specified parameters.

Parameters:
  • input_tac_path (str) – Path to the input TAC file.

  • input_image_path (str) – Path to the input image file.

  • output_directory (str) – Directory where output files will be saved.

  • output_prefix (str) – Prefix for the output files.

  • method (str) – Graphical analysis method.

  • fit_threshold_in_mins (float, optional) – Threshold in minutes for fitting. Defaults to 30.0

  • run_kwargs – Additional keyword arguments passed on to GraphicalAnalysisParametricImage.__call__().

__repr__()#

Provides an unambiguous string representation of the ResampleBloodTACStep instance.

Returns:

str – A string representation showing how the instance can be recreated.

property input_image_path: str#

Returns the path to the input image.

Returns:

str – Path to the input image.

set_input_as_output_from(*sending_steps: petpal.pipelines.preproc_steps.PreprocStepType) None#

Sets the input paths based on the outputs of a sending preprocessing step.

Parameters:

sending_step (PreprocStepType) – The preprocessing step which provides the input paths.

classmethod default_patlak()#

Creates a default instance for Patlak parametric graphical analysis using GraphicalAnalysisParametricImages. All non-method arguments are set to empty-strings.

Returns:

ParametricGraphicalAnalysisStep – A new instance for Patlak parametric graphical analysis.

classmethod default_logan()#

Creates a default instance for Logan parametric graphical analysis using GraphicalAnalysisParametricImages. All non-method arguments are set to empty-strings.

Returns:

ParametricGraphicalAnalysisStep – A new instance for Logan parametric graphical analysis.

classmethod default_alt_logan()#

Creates a default instance for Alt-Logan parametric graphical analysis using GraphicalAnalysisParametricImages. All non-method arguments are set to empty-strings.

Returns:

ParametricGraphicalAnalysisStep – A new instance for Alt-Logan parametric graphical analysis.

classmethod default_logan_ref()#

Creates a default instance for Logan parametric graphical analysis with reference region using GraphicalAnalysisParametricImages. All non-method arguments are set to empty-strings.

Returns:

ParametricGraphicalAnalysisStep

A new instance for Logan parametric graphical analysis

with reference region.

validate_kwargs()#

Validates that all mandatory initialization and call arguments have been provided.

Raises:

RuntimeError – If any mandatory arguments are missing.

static get_args_not_set_in_kwargs(sig: inspect.Signature, kwargs: dict) dict#

Retrieves arguments of the signature that are not set in the keyword arguments.

Parameters:
  • sig (inspect.Signature) – The signature of the function or method.

  • kwargs (dict) – The keyword arguments provided.

Returns:

dict – A dictionary of arguments that are not set in the keyword arguments.

get_empty_default_kwargs(sig: inspect.Signature, set_kwargs: dict) list#

Identifies arguments that have not been provided and lack default values.

Parameters:
  • sig (inspect.Signature) – The signature of the function or method.

  • set_kwargs (dict) – The keyword arguments provided.

Returns:

list – A list of argument names that have no default values and are not provided.

execute() None#

Instantiates the class and invokes it with the provided arguments.

Raises:

The function may raise any exceptions that its implementation can throw.

__str__()#

Returns a detailed string representation of the ObjectBasedStep instance.

Returns:

str – A string describing the step, including its name, class, initialization, and call arguments.

all_init_kwargs_non_empty_strings()#

Checks if all initialization keyword arguments are non-empty strings.

Returns:

bool – True if all initialization keyword arguments are non-empty strings, False otherwise.

all_call_kwargs_non_empty_strings()#

Checks if all call keyword arguments are non-empty strings.

Returns:

bool – True if all call keyword arguments are non-empty strings, False otherwise.

can_potentially_run()#

Determines if the step can potentially be executed based on argument validation. Very simply checks if all __init__ and __call__ keyword arguments for the object are non-empty strings.

Returns:

bool – True if the step can potentially run, False otherwise.

abstractmethod infer_outputs_from_inputs(out_dir: str, der_type: str, suffix: str = None, ext: str = None, **extra_desc)#

Infers output files from input data based on the specified output directory, derivative type, optional suffix and extension, plus any extra descriptions.

Parameters:
  • out_dir (str) – The directory where the output files will be saved.

  • der_type (str) – The type of derivative being produced.

  • suffix (str, optional) – An optional suffix for the output files.

  • ext (str, optional) – An optional extension for the output files.

  • **extra_desc – Additional keyword arguments for extra descriptions to be included.

Raises:

NotImplementedError – This method should be implemented by subclasses.

Notes

For a concrete example, take a look at: TACsFromSegmentationStep

__call__(*args, **kwargs)#
property input_tac_path: str#

Gets the path to the input TAC file.

Returns:

str – Path to the input TAC file.

property reference_tac_path: str#

Gets the path to the reference TAC file.

Returns:

str – Path to the reference TAC file.

property tacs_dir: str#

Gets the directory containing the TAC files to be analyzed.

Returns:

str – Directory containing the TAC files to be analyzed.

property roi_tacs_dir: str#

Gets the directory containing the ROI TAC files to be analyzed.

Returns:

str – Directory containing the ROI TAC files to be analyzed.

property output_directory: str#

Gets the directory where output files will be saved.

Returns:

str – Directory where output files will be saved.

property output_prefix: str#

Gets the prefix for the output files. Usually something like sub-XXXX_ses-XX if BIDS compliant output.

Returns:

str – Prefix for the output files.

property out_path_and_prefix#

Gets the tuple of output directory and prefix.

Returns:

tuple – A tuple containing output directory and prefix.

infer_prefix_from_input_tac_path()#

Infers the output prefix based on the input/reference TAC file path. Gets the subject and session from the path if possible.

infer_output_directory_from_input_tac_path(out_dir: str, der_type: str = 'km')#

Infers the output directory based on the input/reference TAC file path. Gets the subject and session from the path is possible.

Parameters:
  • out_dir (str) – Root output directory.

  • der_type (str) – Type of derivatives. Defaults to ‘km’.