RTMFittingAnalysisStep#

class petpal.pipelines.kinetic_modeling_steps.RTMFittingAnalysisStep(ref_tac_path: str, roi_tacs_dir: str, output_directory: str, output_prefix: str, rtm_model: str, bounds=None, k2_prime=None, fit_threshold_in_mins: float = 30.0)#

Bases: petpal.pipelines.steps_base.ObjectBasedStep, TACAnalysisStepMixin

A step for fitting reference tissue models (RTMs) to TAC data using MultiTACRTMAnalysis.

This class sets up RTM fitting, initializes required paths and parameters.

Variables:
  • ref_tac_path (str) – Path to the reference TAC file.

  • roi_tacs_dir (str) – Directory containing the ROI TAC files.

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

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

  • rtm_model (str) – Reference tissue model to be used for fitting.

  • bounds – Bounds for the fitting parameters. Defaults to None.

  • k2_prime – K2’ value for the fitting. Defaults to None.

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

Initializes the RTMFittingAnalysisStep with specified parameters.

Parameters:
  • ref_tac_path (str) – Path to the reference TAC file.

  • roi_tacs_dir (str) – Directory containing the ROI TAC files.

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

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

  • rtm_model (str) – Reference tissue model to be used for fitting.

  • bounds (optional) – Bounds for the fitting parameters. Defaults to None.

  • k2_prime (optional) – \(k_{2}^\prime\) value for the fitting. Defaults to None.

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

__repr__()#

Provides an unambiguous string representation of the ResampleBloodTACStep instance.

Returns:

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

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 set_input_as_output_from(*sending_steps)#

Sets the input of the current step as the output from a list of steps.

Parameters:

*sending_steps – The previous steps from which the output will be used as input for the current step.

Raises:

NotImplementedError – This method should be implemented by subclasses.

Notes

For a concrete example, take a look at: TACsFromSegmentationStep

Important

If a step takes multiple input steps. the implementation will have a defined order for steps.

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’.