EvenlyInterpolateWithMax#

class petpal.kinetic_modeling.tac_interpolation.EvenlyInterpolateWithMax(tac_times: numpy.ndarray, tac_values: numpy.ndarray, samples_before_max: float = 10.0)#

Bases: EvenlyInterpolate

A class, extends EvenlyInterpolate, and modifies the \(\Delta t\) calculation such that the maximum value of the provided input TAC is explicitly sampled.

Variables:
  • interp_func (scipy.interpolate.interp1d) – Interpolation function given the provided TAC.

  • resample_times (np.ndarray) – Array containing evenly spaced TAC times.

  • resample_vals (np.ndarray) – Interpolated activities at the calculated resample times.

  • dt (float) – The \(\Delta t\) for the resampled times such that the maximum value is explicitly sampled.

See also

EvenlyInterpolate

Initializes an instance of the EvenlyInterpolateWithMax class for TAC interpolation.

This subclass of the :class:EvenlyInterpolate class strives to ensure the maximum value of the Time Activity Curve (TAC) is included in the resampled TAC. It achieves this by determining a dynamic delta time value based on the input TAC and the user-specified number of samples before the TAC’s max value.

The constructor takes the TAC times and values as input, alongside a parameter that defines the number of samples to take before the max value of the TAC. It computes the delta time using a static method of the class, feeding that along with the original times and values into the parent class initializer to perform the actual interpolation.

Parameters:
  • tac_times (np.ndarray) – The time-points at which the original TAC activities were sampled. It should be a 1D numpy array with increasing float values.

  • tac_values (np.ndarray) – The corresponding activity values of the provided TAC sampled at tac_times. It should be a 1D numpy array of float values.

  • samples_before_max (float) – The number of samples desired before the maximum TAC value is reached. It defaults to 10 if not specified and should be a positive float number.

static calculate_dt_for_even_spacing_with_max_sampled(tac_times: numpy.ndarray, tac_values: numpy.ndarray, samples_before_max: float) float#

Calculates the time-step or \(\Delta t\) for evenly sampling the Time-Activity Curve (TAC) while preserving the maximum value of the TAC in the sample.

This method determines the time-step so that when the TAC gets resampled, it is guaranteed that the maximum value of the TAC in the input is also sampled in the resample. The \(\Delta t\) is calculated based on the equation:

\[\Delta t = \frac{t_{\text{max}} - t_0}{N}\]

where \(t_{\text{max}}\) is the time at which the max value of the TAC is reached, \(t_0\) is the start time, and \(N\) is the number of samples desired before the max TAC value.

Parameters:
  • tac_times (np.ndarray) – A 1D numpy array of float values, representing times at which TAC activities are sampled.

  • tac_values (np.ndarray) – A 1D numpy array of float values, indicating the activities of the given TAC at corresponding times.

  • samples_before_max (float) – The number of samples that you want before the maximum TAC value is reached.

Returns:

(float) – The calculated time-step, \(\Delta t\), that ensures that the TAC is evenly sampled, and the maximum TAC value is included in the samples.

get_resampled_tac() numpy.ndarray#

Returns the resampled times and values of the Time-Activity Curve (TAC).

The function combines the resampled times and values into a single numpy array.

Returns:

(np.ndarray) – An array containing two numpy arrays. The first array corresponds to the resampled times and the second array corresponds to the resampled activity values of the TAC.