2Fluorescence decay convolution
3==============================
8In ``IMP.bff`` there are a set of different routines that can be used to compute
9fluorescence decays. Most fluorescence decays are linear combinations of exponential
10decays. Convolutions of such fluorescence decays with instrument response functions
11can be computed using the routines (fconv, fconv_per, fconv_per_cs, etc.). Here,
12fconv stands for fast convolution.
14``IMP.bff`` provides routines that make use of SIMD (Single Instruction Multiple Data).
15The SIMD routines use of the AVX extension (Advanced Vector Extension). The SIMD routines
16compute in parallel decays composed of more than a single fluorescence lifetime.
17The SIMD routines require CPUs with 'modern' instruction sets. Most x86 CPUs that were
18manufacture since 2012 are supported.
26 print(
"To run this example, please first install the 'scipy'")
27 print(
"Python module.")
37time_axis = np.linspace(0, period, n_channels)
38irf = scipy.stats.norm.pdf(time_axis, loc=irf_position, scale=irf_width)
40dt = time_axis[1]-time_axis[0]
41lifetime_spectrum = np.array([1., 4, 1., 0.4] * 64)
42model = np.zeros_like(irf)
51names = [
"fconv",
"fconv_per"]
52t_start = time.perf_counter()
53for _
in range(n_runs):
55ex = time.perf_counter() - t_start
60if IMP.bff.IMP_BFF_HAS_AVX:
61 t_start = time.perf_counter()
62 for _
in range(n_runs):
64 start=start, stop=stop, dt=dt)
65 ex = time.perf_counter() - t_start
68t_start = time.perf_counter()
69for _
in range(n_runs):
71ex = time.perf_counter() - t_start
74if IMP.bff.IMP_BFF_HAS_AVX:
75 t_start = time.perf_counter()
76 for _
in range(n_runs):
78 period=period, start=start, stop=stop,
80 ex = time.perf_counter() - t_start
83times = np.array(times) * 1000.0 / n_runs
84if IMP.bff.IMP_BFF_HAS_AVX:
85 times_avx = np.array(times_avx) * 1000.0 / n_runs
90fig, ax = p.subplots(nrows=1, ncols=2, sharex=
False)
92ax[0].set_title(
'Convolution routines')
93ax[0].set_ylabel(
'counts')
94ax[0].set_xlabel(
'channels')
96model = np.zeros_like(irf)
98ax[0].semilogy(model, label=
"fconv")
100if IMP.bff.IMP_BFF_HAS_AVX:
101 model_avx = np.zeros_like(irf)
103 start=start, stop=stop, dt=dt)
104 ax[0].semilogy(model, label=
"fconv_avx")
106model = np.zeros_like(irf)
108ax[0].semilogy(model, label=
"fconv_per")
110if IMP.bff.IMP_BFF_HAS_AVX:
111 model = np.zeros_like(irf)
113 period=period, start=start, stop=stop, dt=dt)
114 ax[0].semilogy(model, label=
"fconv_per_avx")
118ax[1].set_title(
'Benchmark')
119ax[1].set_ylabel(
'ms / evaluation')
121ind = np.arange(len(times))
122ax[1].set_title(
'Time per call')
124ax[1].set_xticklabels(names)
127ax[1].bar(ind, times, width, color=
'r', label=
'default')
128if IMP.bff.IMP_BFF_HAS_AVX:
129 ax[1].bar(ind + width, times_avx, width, color=
'y', label=
'AVX')
Bayesian Fluorescence Framework.
void decay_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 decay_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),...
void decay_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 lifeti...
void decay_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).