BloodInputFunction#
- class petpal.input_function.blood_input.BloodInputFunction(time: numpy.ndarray, activity: numpy.ndarray, thresh_in_mins: float)#
Bases:
objectA general purpose class to deal with blood input function related data. The primary functionality is to be able to compute the blood input function at any time, given the raw time and activity data.
Using a manual threshold, we split the raw data into two parts: - Below the threshold, we have a simple linear interpolation. - Above the threshold, we fit a line to the data.
When the object is instantiated, we automatically find the interpolation and the fit. Then, we can simply call the calc_blood_input_function function to give us blood input function values at any time.
Lastly, note that this class can be used to deal with any type of (t,y) data where we wish to interpolate the first half, and fit a line to the second half.
Given the input time, activity, and threshold, we calculate the interpolating function for the first half (before the threshold) and the linear fit for the data in the second half (after the threshold). The threshold corresponds to the time, and not the activity.
Currently, there must be at least 3 data points beyond the threshold to fit a line; else, we raise an AssertionError
- Parameters:
time – Time, in minutes.
activity – Activity, assumed to be decay-corrected, corresponding to the times.
thresh_in_mins – The threshold time, in minutes, such that before thresh we use an interpolant, and after thresh we use a linear fit.
- calc_blood_input_function(t: numpy.ndarray) numpy.ndarray#
Given new time data, assumed to be in minutes, we calculate the blood input on those times.
- Parameters:
t
- Returns:
ndarray of blood input values at the provided times
- static _linear_function(x: numpy.ndarray, m: float, b: float) numpy.ndarray#
Simple equation for a line. y = m * x + b
- Parameters:
x – Independent variable
m – Slope of the line
b – Intercept of the line
- Returns:
m * x + b
- static linear_fitting_func(x_data: numpy.ndarray, y_data: numpy.ndarray)#
Given x-data and y-data, we return a function corresponding to the linear fit.
- Parameters:
x_data – Independent variable
y_data – Dependent variable corresponding to the x_data
- Returns:
A callable function that takes x-data as an input to compute the line values