tttrlib
A library for time-tagged time resolved data
|
#include <cmath>
#include <numeric>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
Go to the source code of this file.
Functions | |
void | rescale (double *fit, double *decay, double *scale, int start, int stop) |
Scale model function to the data (old version) | |
void | rescale_w (double *fit, double *decay, double *w_sq, double *scale, int start, int stop) |
Scale model function to the data (with weights) | |
void | rescale_w_bg (double *fit, double *decay, double *w_sq, double bg, double *scale, int start, int stop) |
Scale the model function to the data considering weights and background. | |
void | fconv (double *fit, double *x, double *lamp, int numexp, int start, int stop, double dt=0.05) |
Convolve lifetime spectrum with instrument response (fast convolution, low repetition rate) | |
void | fconv_avx (double *fit, double *x, double *lamp, int numexp, int start, int stop, double dt=0.05) |
Convolve lifetime spectrum with instrument response (fast convolution, AVX optimized for large lifetime spectra) | |
void | fconv_per (double *fit, double *x, double *lamp, int numexp, int start, int stop, int n_points, double period, double dt=0.05) |
Convolve lifetime spectrum with instrument response (fast convolution, high repetition rate) | |
void | fconv_per_avx (double *fit, double *x, double *lamp, int numexp, int start, int stop, int n_points, double period, double dt=0.05) |
Convolve lifetime spectrum with instrument response (fast convolution, high repetition rate), AVX optimized version. | |
void | fconv_per_cs (double *fit, double *x, double *lamp, int numexp, int stop, int n_points, double period, int conv_stop, double dt) |
Convolve lifetime spectrum - fast convolution, high repetition rate, with convolution stop. | |
void | fconv_ref (double *fit, double *x, double *lamp, int numexp, int start, int stop, double tauref, double dt=0.05) |
Convolve lifetime spectrum - fast convolution with reference compound decay. | |
void | sconv (double *fit, double *p, double *lamp, int start, int stop) |
Convolve fluorescence decay curve with irf. | |
void | shift_lamp (double *lampsh, double *lamp, double ts, int n_points, double out_value=0.0) |
shift instrumnet response function | |
void | add_pile_up_to_model (double *model, int n_model, double *data, int n_data, double repetition_rate, double instrument_dead_time, double measurement_time, std::string pile_up_model="coates", int start=0, int stop=-1) |
Add a pile-up distortion to the model function. | |
void | discriminate_small_amplitudes (double *lifetime_spectrum, int n_lifetime_spectrum, double amplitude_threshold) |
Threshold the amplitudes in the interleaved lifetime spectrum. | |
void | fconv_per_cs_time_axis (double *model, int n_model, double *time_axis, int n_time_axis, double *irf, int n_irf, double *lifetime_spectrum, int n_lifetime_spectrum, int convolution_start=0, int convolution_stop=-1, double period=100.0) |
Compute the fluorescence decay for a lifetime spectrum and an instrument response function considering periodic excitation. | |
void | fconv_cs_time_axis (double *inplace_output, int n_output, double *time_axis, int n_time_axis, double *instrument_response_function, int n_instrument_response_function, double *lifetime_spectrum, int n_lifetime_spectrum, int convolution_start=0, int convolution_stop=-1) |
Compute the fluorescence decay for a lifetime spectrum and an instrument response function. | |
void add_pile_up_to_model | ( | double * | model, |
int | n_model, | ||
double * | data, | ||
int | n_data, | ||
double | repetition_rate, | ||
double | instrument_dead_time, | ||
double | measurement_time, | ||
std::string | pile_up_model = "coates", | ||
int | start = 0, | ||
int | stop = -1 ) |
Add a pile-up distortion to the model function.
This function adds a pile up distortion to a model fluorescence decay. The model used to compute the pile-up distortion follows the description of Coates (1968, eq. 2 and eq. 4)
Reference: Coates, P.: The correction for photonpile-up in the measurement of radiative lifetimes. J. Phys. E: Sci. Instrum. 1(8), 878–879 (1968)
model[in,out] | The array containing the model function |
n_model[in] | Number of elements in the model array |
data[in] | The array containing the experimental decay |
n_data[in] | number of elements in experimental decay |
repetition_rate[in] | The repetition-rate (excitation rate) in MHz |
instrument_dead_time[in] | The overall dead-time of the detection system in nanoseconds |
measurement_time[in] | The measurement time in seconds |
pile_up_model[in] | The model used to compute the pile up distortion. |
start | Start index for pile up |
stop | Stop index for pile up (default "coates") |
void discriminate_small_amplitudes | ( | double * | lifetime_spectrum, |
int | n_lifetime_spectrum, | ||
double | amplitude_threshold ) |
Threshold the amplitudes in the interleaved lifetime spectrum.
Amplitudes with absolute values smaller than the specified threshold are set to zero.
lifetime_spectrum | [in,out] Interleaved lifetime spectrum (amplitude, lifetime). |
n_lifetime_spectrum | [in] Number of elements in the lifetime spectrum. |
amplitude_threshold | [in] Threshold value for amplitude discrimination. |
void fconv | ( | double * | fit, |
double * | x, | ||
double * | lamp, | ||
int | numexp, | ||
int | start, | ||
int | stop, | ||
double | dt = 0.05 ) |
Convolve lifetime spectrum with instrument response (fast convolution, low repetition rate)
This function computes the convolution of a lifetime spectrum (a set of lifetimes with corresponding amplitudes) with a instrument response function (irf). This function does not consider periodic excitation and is suited for experiments at low repetition rate.
fit[out] | model function. The convoluted decay is written to this array |
x[in] | lifetime spectrum (amplitude1, lifetime1, amplitude2, lifetime2, ...) |
lamp[in] | instrument response function |
numexp[in] | number of fluorescence lifetimes |
start[in] | start micro time index for convolution (not used) |
stop[in] | stop micro time index for convolution. |
dt[in] | time difference between two micro time channels |
void fconv_avx | ( | double * | fit, |
double * | x, | ||
double * | lamp, | ||
int | numexp, | ||
int | start, | ||
int | stop, | ||
double | dt = 0.05 ) |
Convolve lifetime spectrum with instrument response (fast convolution, AVX optimized for large lifetime spectra)
This function is a modification of fconv for large lifetime spectra. The lifetime spectrum is processed by AVX intrinsics. Four lifetimes are convolved at once. Spectra with lifetimes that are not multiple of four are zero padded.
fit | |
x | |
lamp | |
numexp | |
start | |
stop | |
n_points | |
dt |
void fconv_cs_time_axis | ( | double * | inplace_output, |
int | n_output, | ||
double * | time_axis, | ||
int | n_time_axis, | ||
double * | instrument_response_function, | ||
int | n_instrument_response_function, | ||
double * | lifetime_spectrum, | ||
int | n_lifetime_spectrum, | ||
int | convolution_start = 0, | ||
int | convolution_stop = -1 ) |
Compute the fluorescence decay for a lifetime spectrum and an instrument response function.
Fills the pre-allocated output array inplace_output
with a fluorescence intensity decay defined by a set of fluorescence lifetimes specified in the lifetime_spectrum
parameter. The fluorescence decay is convolved (non-periodically) with an instrumental response function defined by instrument_response_function
.
This function calculates a fluorescence intensity decay model that is convolved with an instrument response function (IRF). The fluorescence intensity decay model is specified by its fluorescence lifetime spectrum, represented by an interleaved array containing fluorescence lifetimes with corresponding amplitudes.
The convolution supports unevenly spaced time axes.
inplace_output | [in,out] In-place output array that is filled with the values of the computed fluorescence intensity decay model. |
n_output | [in] Number of elements in the output array. |
time_axis | [in] Time-axis of the fluorescence intensity decay model. |
n_time_axis | [in] Length of the time axis. |
instrument_response_function | [in] Instrument response function array. |
n_instrument_response_function | [in] Length of the instrument response function array. |
lifetime_spectrum | [in] Interleaved array of amplitudes and fluorescence lifetimes in the form (amplitude, lifetime, amplitude, lifetime, ...). |
n_lifetime_spectrum | [in] Number of elements in the lifetime spectrum. |
convolution_start | [in] Start channel of convolution (position in array of IRF). |
convolution_stop | [in] Convolution stop channel (the index on the time-axis). |
void fconv_per | ( | double * | fit, |
double * | x, | ||
double * | lamp, | ||
int | numexp, | ||
int | start, | ||
int | stop, | ||
int | n_points, | ||
double | period, | ||
double | dt = 0.05 ) |
Convolve lifetime spectrum with instrument response (fast convolution, high repetition rate)
This function computes the convolution of a lifetime spectrum (a set of lifetimes with corresponding amplitudes) with a instrument response function (irf). This function does consider periodic excitation and is suited for experiments at high repetition rate.
fit[out] | model function. The convoluted decay is written to this array |
x[in] | lifetime spectrum (amplitude1, lifetime1, amplitude2, lifetime2, ...) |
lamp[in] | instrument response function |
numexp[in] | number of fluorescence lifetimes |
start[in] | start micro time index for convolution (not used) |
stop[in] | stop micro time index for convolution. |
n_points | number of points in the model function. |
period | excitation period in units of the fluorescence lifetimes (typically nanoseconds) |
dt[in] | time difference between two micro time channels |
void fconv_per_avx | ( | double * | fit, |
double * | x, | ||
double * | lamp, | ||
int | numexp, | ||
int | start, | ||
int | stop, | ||
int | n_points, | ||
double | period, | ||
double | dt = 0.05 ) |
Convolve lifetime spectrum with instrument response (fast convolution, high repetition rate), AVX optimized version.
This function computes the convolution of a lifetime spectrum (a set of lifetimes with corresponding amplitudes) with a instrument response function (irf). This function does consider periodic excitation and is suited for experiments at high repetition rate.
fit[out] | model function. The convoluted decay is written to this array |
x[in] | lifetime spectrum (amplitude1, lifetime1, amplitude2, lifetime2, ...) |
lamp[in] | instrument response function |
numexp[in] | number of fluorescence lifetimes |
start[in] | start micro time index for convolution (not used) |
stop[in] | stop micro time index for convolution. |
n_points | number of points in the model function. |
period | excitation period in units of the fluorescence lifetimes (typically nanoseconds) |
dt[in] | time difference between two micro time channels |
void fconv_per_cs | ( | double * | fit, |
double * | x, | ||
double * | lamp, | ||
int | numexp, | ||
int | stop, | ||
int | n_points, | ||
double | period, | ||
int | conv_stop, | ||
double | dt ) |
Convolve lifetime spectrum - fast convolution, high repetition rate, with convolution stop.
fast convolution, high repetition rate, with convolution stop for Paris
fit[out] | model function. The convoluted decay is written to this array |
x[in] | lifetime spectrum (amplitude1, lifetime1, amplitude2, lifetime2, ...) |
lamp[in] | instrument response function |
numexp[in] | number of fluorescence lifetimes |
stop[in] | stop micro time index for convolution. |
n_points | number of points in the model function. |
period | excitation period in units of the fluorescence lifetimes (typically nanoseconds) |
conv_stop | convolution stop micro channel number |
dt[in] | time difference between two micro time channels |
void fconv_per_cs_time_axis | ( | double * | model, |
int | n_model, | ||
double * | time_axis, | ||
int | n_time_axis, | ||
double * | irf, | ||
int | n_irf, | ||
double * | lifetime_spectrum, | ||
int | n_lifetime_spectrum, | ||
int | convolution_start = 0, | ||
int | convolution_stop = -1, | ||
double | period = 100.0 ) |
Compute the fluorescence decay for a lifetime spectrum and an instrument response function considering periodic excitation.
Fills the pre-allocated output array model
with a fluorescence intensity decay defined by a set of fluorescence lifetimes specified in the lifetime_spectrum
parameter. The fluorescence decay is convolved (non-periodically) with an instrumental response function defined by irf
.
This function calculates a fluorescence intensity model that is convolved with an instrument response function (IRF). The fluorescence intensity model is specified by its fluorescence lifetime spectrum, represented by an interleaved array containing fluorescence lifetimes with corresponding amplitudes.
This convolution only works with evenly linear spaced time axes.
model | [in,out] In-place output array that is filled with the values of the computed fluorescence intensity decay model. |
n_model | [in] Number of elements in the output array. |
time_axis | [in] Time-axis of the model. |
n_time_axis | [in] Length of the time axis. |
irf | [in] Instrument response function array. |
n_irf | [in] Length of the instrument response function array. |
lifetime_spectrum | [in] Interleaved array of amplitudes and fluorescence lifetimes in the form (amplitude, lifetime, amplitude, lifetime, ...). |
n_lifetime_spectrum | [in] Number of elements in the lifetime spectrum. |
convolution_start | [in] Start channel of convolution (position in array of IRF). |
convolution_stop | [in] Convolution stop channel (the index on the time-axis). |
period | [in] Period of repetition in units of the lifetime (usually, nano-seconds). Default value is 100.0. |
void fconv_ref | ( | double * | fit, |
double * | x, | ||
double * | lamp, | ||
int | numexp, | ||
int | start, | ||
int | stop, | ||
double | tauref, | ||
double | dt = 0.05 ) |
Convolve lifetime spectrum - fast convolution with reference compound decay.
This function convolves a set of fluorescence lifetimes and with associated amplitudes with an instrument response function. The provided amplitudes are scaled prior to the convolution by area using a reference fluorescence lifetime. The amplitudes are computed by
amplitude_corrected = a * ( 1 /tauref - 1 / tau)
where a and tau are provided amplitudes.
fit[out] | model function. The convoluted decay is written to this array |
x[in] | lifetime spectrum (amplitude1, lifetime1, amplitude2, lifetime2, ...) |
lamp[in] | instrument response function |
numexp[in] | number of fluorescence lifetimes |
start[in] | start micro time index for convolution (not used) |
stop[in] | stop micro time index for convolution. |
tauref | a reference lifetime used to rescale the amplitudes of the fluorescence lifetime spectrum |
dt[in] | time difference between two micro time channels |
void rescale | ( | double * | fit, |
double * | decay, | ||
double * | scale, | ||
int | start, | ||
int | stop ) |
Scale model function to the data (old version)
This function rescales the model function (fit) to the data by the number of photons between a start and a stop micro time counting channel. The number of photons between start and stop are counted and the model function is scaled to match the data by area.
This rescaling function does not consider the noise in the data when rescaling the model.
fit[in,out] | model function that is scaled (modified in-place) |
decay[in] | the experimental data to which the model function is scaled |
scale[out] | the scaling parameter (the factor) by which the model function is multiplied. |
start[in] | The start micro time channel |
stop[in] | The stop micro time channel |
void rescale_w | ( | double * | fit, |
double * | decay, | ||
double * | w_sq, | ||
double * | scale, | ||
int | start, | ||
int | stop ) |
Scale model function to the data (with weights)
This function rescales the model function (fit) to the data by the number of photons between a start and a stop micro time counting channel. The number of photons between start and stop are counted and the model function is scaled to match the data by area considering the noise of the data.
The scaling factor is computed by:
scale = sum(fit*decay/w^2)/sum(fit^2/w^2)
fit[in,out] | model function that is scaled (modified in-place) |
decay[in] | the experimental data to which the model function is scaled |
w_sq[in] | squared weights of the data. |
scale[out] | the scaling parameter (the factor) by which the model function is multiplied. |
start[in] | The start micro time channel |
stop[in] | The stop micro time channel |
void rescale_w_bg | ( | double * | fit, |
double * | decay, | ||
double * | w_sq, | ||
double | bg, | ||
double * | scale, | ||
int | start, | ||
int | stop ) |
Scale the model function to the data considering weights and background.
This function scales the model function (fit) to the data by counting the number of photons between a start and a stop micro time counting channel. The number of photons between start and stop is counted, and the model function is scaled to match the data by area, considering the noise of the data and a constant offset of the data.
The scaling parameter (scale) is calculated using the formula:
fit | [in,out] Model function that is scaled (modified in-place). |
decay | [in] Experimental data to which the model function is scaled. |
w_sq | [in] Squared weights of the data. |
bg | [in] Constant background of the data. |
scale | [out] The scaling parameter (the factor) by which the model function is multiplied. |
start | [in] The start micro time channel. |
stop | [in] The stop micro time channel. |
void sconv | ( | double * | fit, |
double * | p, | ||
double * | lamp, | ||
int | start, | ||
int | stop ) |
Convolve fluorescence decay curve with irf.
This function computes a convolved model function for a fluorescence decay curve.
fit | convolved model function |
p | model function before convolution - fluorescence decay curve |
lamp | instrument response function |
start | start index of the convolution |
stop | stop index of the convolution |
void shift_lamp | ( | double * | lampsh, |
double * | lamp, | ||
double | ts, | ||
int | n_points, | ||
double | out_value = 0.0 ) |
shift instrumnet response function
lampsh | |
lamp | |
ts | |
n_points | |
out_value | the value of the shifted response function outside of the valid indices |