TcmModelConfig#

class petpal.kinetic_modeling.tac_fitting.TcmModelConfig(func: Callable, param_names: list[str], default_bounds: numpy.ndarray, pretty_param_names: list[str] | None = None)#

Base configuration class for Tissue Compartment Model (TCM) specifications.

This class encapsulates the essential properties of a TCM including the model function, parameter names, default bounds, and pretty-printed parameter names for visualization. It provides utilities for normalizing model names and resolving model names to their corresponding functions.

Variables:
  • func (Callable) – The TCM function implementation.

  • param_names (list[str]) – List of parameter names (e.g., [‘k1’, ‘k2’, ‘vb’]).

  • pretty_param_names (list[str]) – List of formatted parameter names for display (e.g., [r’$K_1$’, r’$k_2$’]).

  • default_bounds (np.ndarray) – Default bounds for parameters with shape (num_params, 3) where each row contains [initial_guess, lower_bound, upper_bound].

  • num_params (int) – Number of parameters in the model.

Initialize a TCM model configuration.

Parameters:
  • func (Callable) – The tissue compartment model function.

  • param_names (list[str]) – List of parameter names.

  • default_bounds (np.ndarray) – Default parameter bounds array with shape (num_params, 3).

  • pretty_param_names (list[str] or None, optional) – Pretty-printed parameter names for display. If None, uses param_names. Defaults to None.

static normalize_name(name: str) str#

Normalize a model name to a standard format.

Converts the name to lowercase and replaces spaces and underscores with hyphens for consistent model name lookup.

Parameters:

name (str) – The model name to normalize.

Returns:

str – The normalized model name.

Example

from petpal.kinetic_modeling.tac_fitting import TcmModelConfig
TcmModelConfig.normalize_name("Serial 2TCM")  # Returns "serial-2tcm"
TcmModelConfig.normalize_name("1TCM")  # Returns "1tcm"
classmethod valid_model_names() list[str]#

Get a sorted list of all valid model names.

Returns:

list[str] – Sorted list of valid model name strings.

classmethod resolve_model_name(model_name: str) Callable#

Resolve a model name string to its corresponding TCM function.

Parameters:

model_name (str) – The name of the compartment model.

Returns:

Callable – The TCM function corresponding to the model name.

Raises:

ValueError – If the model_name does not correspond to a known model.

Example

from petpal.kinetic_modeling.tac_fitting import TcmModelConfig
func = TcmModelConfig.resolve_model_name("2tcm")
# Returns the 2TCM function