EvenlyInterpolateWithMax ================================================================== .. py:class:: petpal.kinetic_modeling.tac_interpolation.EvenlyInterpolateWithMax(tac_times: numpy.ndarray, tac_values: numpy.ndarray, samples_before_max: float = 10.0) Bases: :py:obj:`EvenlyInterpolate` A class, extends :class:`EvenlyInterpolate`, and modifies the :math:`\Delta t` calculation such that the maximum value of the provided input TAC is explicitly sampled. :ivar interp_func: Interpolation function given the provided TAC. :vartype interp_func: scipy.interpolate.interp1d :ivar resample_times: Array containing evenly spaced TAC times. :vartype resample_times: np.ndarray :ivar resample_vals: Interpolated activities at the calculated resample times. :vartype resample_vals: np.ndarray :ivar dt: The :math:`\Delta t` for the resampled times such that the maximum value is explicitly sampled. :vartype dt: float .. seealso:: :class:`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. :param tac_times: The time-points at which the original TAC activities were sampled. It should be a 1D numpy array with increasing float values. :type tac_times: np.ndarray :param tac_values: The corresponding activity values of the provided TAC sampled at tac_times. It should be a 1D numpy array of float values. :type tac_values: np.ndarray :param samples_before_max: 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. :type samples_before_max: float .. py:method:: calculate_dt_for_even_spacing_with_max_sampled(tac_times: numpy.ndarray, tac_values: numpy.ndarray, samples_before_max: float) -> float :staticmethod: Calculates the time-step or :math:`\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 :math:`\Delta t` is calculated based on the equation: .. math:: \Delta t = \frac{t_{\text{max}} - t_0}{N} where :math:`t_{\text{max}}` is the time at which the max value of the TAC is reached, :math:`t_0` is the start time, and :math:`N` is the number of samples desired before the max TAC value. :param tac_times: A 1D numpy array of float values, representing times at which TAC activities are sampled. :type tac_times: np.ndarray :param tac_values: A 1D numpy array of float values, indicating the activities of the given TAC at corresponding times. :type tac_values: np.ndarray :param samples_before_max: The number of samples that you want before the maximum TAC value is reached. :type samples_before_max: float :returns: *(float)* -- The calculated time-step, :math:`\Delta t`, that ensures that the TAC is evenly sampled, and the maximum TAC value is included in the samples. .. py:method:: 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.