Page MenuHomec4science

Assess_Bleaching.ijm

File Metadata

Author
oburri
Created
Mar 7 2019, 13:01

Assess_Bleaching.ijm

macro "Assess Bleaching [F2]" {
// Measure Half time and relate it to number of frames
run("Close All");
// Get the contents of the clipboard as text
text = String.paste;
// Split the lines and then the rows so as to get the X and Y coordinates
line = split(text, "\n");
n = line.length;
// Create the arrays for x (time) and y (values).
// the (n-1) is because we are skipping the first row that contains the headers
time = newArray( n-1 );
values = newArray( n-1 );
frames = Array.getSequence( n-1 );
for( i=0; i<n-1; i++ ) { // skip first row
cols = split(line[i+1], "\t");
time[i] = cols[0];
values[i] = cols[1];
}
// Do curve fitting to get it with time (not so useful but valid)
Fit.doFit("Exponential with Offset", time, values);
// get the half time in seconds
b_s = Fit.p(1);
tau_s = log(2) / b_s;
// do curve fitting to get the result in number of frames
Fit.doFit("Exponential with Offset", frames, values);
Fit.plot();
rename("Exponential Fit (frames)");
// get teh half time in frames
b_f = Fit.p(1);
tau_f = log(2) / b_f; // See https://en.wikipedia.org/wiki/Exponential_decay
// Save the results as a table
if( isOpen("Bleach Assessment") ) { selectWindow("Bleach Assessment"); } else {Table.create("Bleach Assessment"); }
n = Table.size;
// Keep the date for one of the columns, in case the user wants to run it multiple times to compare different values
getDateAndTime(year, month, dayOfWeek, dayOfMonth, hour, minute, second, msec);
dateString = ""+year+"-"+month+"-"+dayOfMonth+" "+hour+":"+minute+":"+second;
Table.set("Date", n, dateString);
Table.set("Half Intensity Reached In (s)", n, d2s(tau_s,1));
Table.set("Half Intensity Reached In (frames)", n, d2s(tau_f,0));
Table.update;
// Show a message to the user
showMessage("You have "+d2s(tau_f,0)+" frames before you lose 50% of your overall intensity");
}

Event Timeline

oburri changed the visibility from "oburri (Olivier Burri)" to "Public (No Login Required)".Mar 8 2019, 15:15