Interpolation scripts#
- check_frametimes(frametimes, options)#
Guesses the timeunit from data and converts frametimes from minutes to seconds or vice versa.
- Parameters:
frametimes (
Nx2 double array
) – PET image frametimes.conv_timeunit (
{'sec', 'min'}, default : 'sec'
) – Convert frametimes to this timeunit.verbose (
logical, default : 0
) – Set to any positive number to print information.
- Returns:
timeunit ({‘sec’, ‘min}) – Guessed frametime unit.
frametimes (Nx2 double array) – Converted frametimes from original timeunit to conv_timeunit.
tmid (Nx1 double array) – Frame mid times.
- interpolate(x, y, newx)#
Linear interpolation and integration.
It is assumed that both original and new interpolated data represent the actual values at specified time points (not from framed data). The integration is calculated dot-by-dot. Original data and new x values must be sorted by ascending x. Subsequent x values can have equal values, enabling the use of step functions. Negative x (time) values can be processed. If necessary, the data is extrapolated assuming that:
y(inf)=y(length(y))
if x(1) > 0, y(1) > 0 and x(1) <=x (1) - x(1), then an imaginary line is drawn from (0,0) to (x(1), y(1)).
- Parameters:
x (
double array
) – Input data x (time) values.y (
double array
) – Input data y values.newx (
double array
) – Output data x (time) values.
- Returns:
newy (double array) – Interpolated (extrapolated) y values.
newyi (double array) – Integrals of y values.
newyii (double array) – Second integrals of y values.
Notes
This function is copied from http://www.turkupetcentre.net/tpcclib-doc/v1/integr_8c.html#ae301b2d90e57ac572742e71b02728b19
- interpolate4pet(x, y, newx1, newx2)#
Interpolate and integrate TAC to PET frames.
It is assumed, that original data is not from framed data, but that the values represent the actual value at specified time point, which allows the integration to be calculated dot-by-dot.
Original data and new x values must be sorted by ascending x. Subsequent x values can have equal values, enabling the use of step functions. PET frames can overlap, but interpolation may then be slower. If necessary, the data is extrapolated assuming that
y(inf) = y(nr-1)
if x(0) > 0 and y(0) > 0 and x(0) > x(1)-x(0), then an imaginary line is drawn from (0,0) to (x(0),y(0)).
- Parameters:
x (
double array
) – Input data x (time) values.y (
double array
) – Input data y values.newx1 (
double array
) – PET frames start times.newx2 (
double array
) – PET frames end times.
- Returns:
newy (double array) – Interpolated (extrapolated) y values.
newyi (double array) – Integrals of y values.
newyii (double array) – Second integrals of y values.
Notes
This function is copied from http://www.turkupetcentre.net/tpcclib-doc/v1/integr_8c.html#af5569ffb70b51083fb5f15de939f3f2d
- petintegral(x1, x2, y, varargin)#
Integrate PET TAC data to frame mid times.
Frames must be in ascending time order. Gaps and small overlap are allowed. If x1(0) > 0 and x1(0) <= x2(0) - x1(0), then an imaginary line is drawn from (0, 0) to (x(0), y(0)).
- Parameters:
x1 (
double array
) – PET frames start times.x2 (
double array
) – PET frames end times.y (
double array
) – Input data y values.varargin{1} (
int
) –0, do not calculate second integral
1, calculate second integral
- Returns:
int1 (double array) – First integral.
varargout{1} (double array) – Second integral.
Notes
This function is copied from http://www.turkupetcentre.net/tpcclib-doc/v1/integr_8c.html#a2b1a454df5ff636b784c6131259da6a7