TACsFromSegmentationStep#
- class petpal.pipelines.preproc_steps.TACsFromSegmentationStep(input_image_path: str, segmentation_image_path: str, segmentation_label_map_path: str, out_tacs_dir: str, out_tacs_prefix: str, verbose=False)#
Bases:
petpal.pipelines.steps_base.FunctionBasedStepA step in a processing pipeline for generating Time Activity Curves (TACs) from segmented images.
This class is specialized for handling the input and output paths related to TAC generation, extending the
FunctionBasedStepwith specific properties and methods for TACs. The class useswrite_tacswhich uses segmentation information to generate ROI TACs, and write them to disk.- Variables:
input_image_path (str) – Path to the input image.
segmentation_image_path (str) – Path to the segmentation image.
segmentation_label_map_path (str) – Path to the segmentation label map.
out_tacs_dir (str) – Directory where the output TACs will be saved.
out_tacs_prefix (str) – Prefix for the output TACs.
verbose (bool) – Verbosity flag, default is False.
Initializes a TACsFromSegmentationStep with specified parameters.
- Parameters:
input_image_path (str) – Path to the input image.
segmentation_image_path (str) – Path to the segmentation image.
segmentation_label_map_path (str) – Path to the segmentation label map.
out_tacs_dir (str) – Directory where the output TACs will be saved.
out_tacs_prefix (str) – Prefix for the output TACs.
verbose (bool) – Verbosity flag, default is False.
- __repr__()#
Provides an unambiguous string representation of the TACsFromSegmentationStep instance.
- Returns:
str – A string representation showing how the instance can be recreated.
- property segmentation_image_path#
Gets the path to the segmentation image.
- Returns:
str – The path to the segmentation image.
- property segmentation_label_map_path#
Gets the path to the segmentation label map.
- Returns:
str – The path to the segmentation label map.
- property out_tacs_dir#
Gets the directory where the output TACs will be saved.
- Returns:
str – The output directory path.
- property out_tacs_prefix#
Gets the prefix for the output TACs.
- Returns:
str – The prefix for the output TACs.
- property out_path_and_prefix#
Gets the output directory path and prefix as a tuple.
- Returns:
tuple – A tuple containing the output directory path and prefix.
- property input_image_path#
Gets the path to the input image.
- Returns:
str – The path to the input image.
- set_input_as_output_from(*sending_steps)#
Sets the input image path based on the output from a specified sending step.
- Parameters:
sending_step – The step from which to derive the input image path.
- infer_outputs_from_inputs(out_dir: str, der_type: str, suffix: str = None, ext: str = None, **extra_desc)#
Infers output directory and prefix for TACs based on the input image path.
- Parameters:
out_dir (str) – Directory where the outputs will be saved.
der_type (str) – Type of derivatives.
suffix (str, optional) – Suffix for the output files. Defaults to None.
ext (str, optional) – Extension for the output files. Defaults to None.
**extra_desc – Additional descriptive parameters.
- classmethod default_write_tacs_from_segmentation_rois(**overrides)#
Provides a class method to create an instance with default parameters. All paths are set to empty strings, and verbose=False.
- Returns:
TACsFromSegmentationStep – A new instance with default parameters.
- get_function_args_not_set_in_kwargs() ArgsDict#
Retrieves arguments of the function that are not set in the keyword arguments.
- Returns:
ArgsDict – A dictionary of function arguments that have not been set in the keyword arguments.
- get_empty_default_kwargs() list#
Identifies arguments that have not been provided and lack default values.
- Returns:
list – A list of argument names that have no default values and are not provided.
- validate_kwargs_for_non_default_have_been_set() None#
Validates that all mandatory arguments have been provided.
- Raises:
RuntimeError – If any mandatory arguments are missing.
- execute()#
Executes the function with the provided arguments and keyword arguments.
- Raises:
The function may raise any exceptions that its implementation can throw. –
- generate_kwargs_from_args() ArgsDict#
Converts positional arguments into keyword arguments.
- Returns:
ArgsDict – A dictionary where positional arguments are mapped to their corresponding parameter names.
- __str__()#
Returns a detailed string representation of the FunctionBasedStep instance.
- Returns:
str – A string describing the step, including its name, function, arguments, and keyword arguments.
- all_args_non_empty_strings()#
Checks if all positional arguments are non-empty strings.
- Returns:
bool – True if all positional arguments are non-empty strings, False otherwise.
- all_kwargs_non_empty_strings()#
Checks if all keyword arguments are non-empty strings.
- Returns:
bool – True if all 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 arguments and keyword arguments are non-empty strings.
- Returns:
bool – True if the step can potentially run, False otherwise.
- __call__(*args, **kwargs)#