Created
September 19, 2023 09:07
-
-
Save NicoKiaru/982f88376b531550fbbdc4ec4f7f3cbf to your computer and use it in GitHub Desktop.
A small demo of the Pile-up effect in FLIM imaging #BIOP #FIJI #FLIM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A small theory about pile-up effect in FLIM - unfortunately I lost the way I made these equations | |
* | |
* (I think the documentation below is wrong: what is n ? what is alpha ? why are they not the same ?) | |
* | |
* Here, we model a poisson process for the number of photon emitted per excitation pulse. (parameter alpha) | |
* In other words: alpha is the parameter of the poisson distribution ( = average number of photons emitted after an excitation pulse) | |
* | |
* And each photon has a mono-exponential lifetime tau | |
* | |
* The distribution intensity[i] = (pow(1+alpha*(exp(-t/tau)-1),n)-pow(1-alpha, n)) / (1-pow(1-alpha,n)); is the result | |
* of the distribution measured when the detector only measures the first photon which arrives. | |
* | |
* Then we do a mono-exponential fit of this theoretical distribution. And we see how it deviates from the real tau: | |
* it's shorter - that's the pile-up effect | |
* | |
* @author Nicolas Chiaruttini, EPFL BIOP | |
* | |
*/ | |
#@double tau | |
#@double alpha | |
nSteps = 1000; | |
repRate = newArray(nSteps); | |
fittedLifetime = newArray(nSteps); | |
for (i = 0; i < nSteps ; i++) { | |
print(i); | |
n = 1+ i * 0.1; | |
repRate[i] = (1-pow(1-alpha,n))*100; | |
fittedLifetime[i] = getFittedLifetime(tau, alpha, n); | |
} | |
Plot.create("Pile-up Theory", "Repetition Rate (%)", "Fitted Tau", repRate, fittedLifetime); | |
//Plot.setLogScaleX(true); | |
function getFittedLifetime(tau,alpha,n) { | |
timeStep = tau/50; | |
nTimepoints = 500; | |
intensity = newArray(nTimepoints); | |
time = newArray(nTimepoints); | |
for (i = 0 ; i < nTimepoints ; i = i + 1 ) { | |
t = i * timeStep; | |
time[i] = t ; | |
intensity[i] = (pow(1+alpha*(exp(-t/tau)-1),n)-pow(1-alpha, n)) / (1-pow(1-alpha,n)); | |
} | |
Fit.doFit("Exponential", time, intensity); | |
return -1/Fit.p(1); | |
} | |
/** | |
* | |
* Saved script | |
* | |
#@double tau | |
#@double alpha | |
//#@double n | |
#@boolean addPlot | |
timeStep = tau/50; | |
nTimepoints = 500; | |
intensity = newArray(nTimepoints); | |
time = newArray(nTimepoints); | |
for (i = 0 ; i < nTimepoints ; i = i + 1 ) { | |
t = i * timeStep; | |
time[i] = t ; | |
intensity[i] = (pow(1+alpha*(exp(-t/tau)-1),n)-pow(1-alpha, n)) / (1-pow(1-alpha,n)); | |
} | |
if (addPlot) { | |
Plot.add("line", time, intensity); | |
} else { | |
Plot.create("Lifetime", "Time", "Intensity", time, intensity); | |
} | |
Fit.doFit("Exponential", time, intensity); | |
tauFit = -1/Fit.p(1); | |
repetitionRate = 1-pow(1-alpha,n); | |
*/ | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment