MultiTACAnalysisMixin#

class petpal.utils.time_activity_curve.MultiTACAnalysisMixin(input_tac_path: str, tacs_dir: str)#

A mixin class providing utilities for handling multiple analysis of Time Activity Curves (TACs) in a directory.

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

  • tacs_dir (str) – Directory containing TAC files.

  • tacs_files_list (list[str]) – List of TAC file paths.

  • num_of_tacs (int) – Number of TACs found in the directory.

  • inferred_seg_labels (list[str]) – List of inferred segmentation labels for TACs.

Initializes the MultiTACAnalysisMixin with paths and initializes analysis properties.

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

  • tacs_dir (str) – Directory containing TAC files.

property input_tac_path#

Gets the input TAC file path.

property tacs_dir#

Gets the TAC directory path.

property reference_tac_path#

Gets the reference TAC file path.

is_valid_tacs_dir(tacs_dir: str)#

Validates the TAC directory by checking for TAC files.

Parameters:

tacs_dir (str) – Directory to validate.

Returns:

bool – True if valid, otherwise False.

static get_tacs_list_from_dir(tacs_dir: str) list[str]#

Retrieves a sorted list of TAC file paths from a directory.

Parameters:

tacs_dir (str) – Directory from which to retrieve TAC files.

Returns:

list[str] – Sorted list of TAC file paths.

static get_tacs_objects_dict_from_files_list(tacs_files_list: list[str])#

Creates a dict of TAC objects from a list of file paths.

Parameters:

tacs_files_list (list[str]) – List of TAC file paths.

Returns:

dict – Dictionary of region name-TAC object pairs.

static get_tacs_objects_dict_from_dir(tacs_dir: str) dict#

Creates a dict of TAC objects from a directory of TAC files.

Parameters:

tacs_dir (str) – A directory of TAC files.

Returns:

dict – Dictionary of region name-TAC object pairs.

static get_tacs_objects_list_from_files_list(tacs_files_list: list[str])#

Creates a list of TAC objects from a list of file paths.

Parameters:

tacs_files_list (list[str]) – List of TAC file paths.

Returns:

list[TimeActivityCurve] – List of TAC objects.

static get_tacs_vals_from_objs_list(tacs_objects_list: list[TimeActivityCurve])#

Extracts TAC values from a list of TAC objects.

Parameters:

tacs_objects_list (list[TimeActivityCurve]) – List of TAC objects.

Returns:

list – List of TAC values.

get_tacs_vals_from_dir(tacs_dir: str)#

Retrieves TAC values from files in a specified directory.

Parameters:

tacs_dir (str) – Directory containing TAC files.

Returns:

list – List of TAC values.

static capitalize_first_char_of_str(input_str: str)#

Capitalize only the first character of a string, leaving the remainder unchanged.

Parameters:

input_str (str) – The string to capitalize the first character of.

Returns:

output_str (str) – The string with only the first character capitalized.

static infer_segmentation_label_from_tac_path(tac_path: str, tac_id: int)#

Infers a segmentation label from a TAC file path by analyzing the filename.

This method extracts a segment label from the filename of a TAC file. It checks the presence of a seg- marker in the filename, which is followed by the segment name. This segment name is then formatted with each part capitalized. If no segment label is found, a default unknown label is generated using the TAC’s ID.

Parameters:
  • tac_path (str) – Path of the TAC file.

  • tac_id (int) – ID of the TAC.

Returns:

str – Inferred segmentation label.

infer_segmentation_labels_for_tacs()#

Infers segmentation labels for TACs.

Returns:

list[str] – List of inferred segmentation labels.