Created
November 23, 2020 16:54
-
-
Save NicoKiaru/5df8c91bc296ad52526b8db6b3548dea to your computer and use it in GitHub Desktop.
[Simple Life Time Measurement in ImageJ] Estimate lifetime of ROIs based on single exponential fits ( ImageJ / FIJI ) #Fiji #ROI #FLIM #BIOP
This file contains hidden or 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
/** | |
* Allows to compute in a simple manner different regions of a lifetime stack image | |
* | |
* REQUIREMENT : For Picoquant file reading, install PTU-Reader (https://github.com/ekatrukha/PTU_Reader) | |
* | |
* How to use the script: | |
* 0 open a PTU file | |
* 1 make regions of interest and store them into the ROI Manager | |
* 2 select the lifetime stack | |
* 3 execute the script and provide the necessary parameters | |
* | |
* For lifetime fitting, a single exponential decay with no offset is fitted on a certain time window | |
* Basic but robust | |
* OUTPUT : a graph per ROI and a line (tidy data) | |
* | |
* TODO : assign ROI names to data and better numbering | |
* | |
* @author : [email protected], BIOP, EPFL, 2020 | |
*/ | |
#@double(label = "time bin size in ps (default 8)") binSizeInPs | |
#@double(label = "start timepoint for exponential fit in ns") timeWindowStart | |
#@double(label = "end timepoint for exponentila fit in ns") timeWindowEnd | |
#@boolean(label = "show fit") showFit | |
binSizeInNs = binSizeInPs/1000.0 | |
sliceMin = timeWindowStart/binSizeInNs | |
sliceMax = timeWindowEnd/binSizeInNs | |
//setBatchMode(true); | |
imgLifeTimeStack = getTitle(); | |
run("Properties...", "channels=1 slices=1 frames="+nSlices+" unit=µm frame=["+binSizeInNs+" nsec]"); | |
run("Z Project...", "projection=[Sum Slices]"); | |
imgSum = getTitle(); | |
selectWindow(imgLifeTimeStack); | |
run("Select None"); | |
run("Duplicate...", "duplicate range="+sliceMin+"-"+sliceMax); | |
imgCropped = getTitle(); | |
for (indexRoi = 0;indexRoi<roiManager("count");indexRoi++) { | |
selectWindow(imgCropped); | |
roiManager("Select", indexRoi); | |
run("Plot Z-axis Profile"); | |
Plot.getValues(xpoints, ypoints); | |
close(); | |
Fit.doFit("Exponential", xpoints, ypoints); | |
if (showFit) { | |
Fit.plot; | |
} | |
selectWindow(imgSum); | |
roiManager("Select", indexRoi); | |
getStatistics(area, mean, min, max, std, histogram); | |
print("Image \t"+imgLifeTimeStack+"\t [ \t"+sliceMin+"\t - \t"+sliceMax+"\t ] roi \t"+indexRoi+" \t fitted lifetime (ns) \t"+(-1/Fit.p(1))+"\t R^2 = "+Fit.rSquared+"\t meanValue = \t"+mean+"\t area = \t"+area); | |
} | |
selectWindow(imgCropped); | |
close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment