Re: Live line profile plugin?
Posted by Sebastian Rhode-3 on Jun 29, 2011; 7:11am
URL: http://imagej.273.s1.nabble.com/jp2-files-LOCI-bioformats-Neurolucida-virtual-slice-tp3684085p3684087.html
Hi,
since I was not aware of the Dynamic Line Profile from ImageJ I wrote a macro, which does the same (not perfect). Feel free to use it.
Cheers, Sebi
// Author: Sebastian Rhode
// Version 1.1
// Date: 2011-06-21
// ------------ IMPORTANT ------------
//
// close "Log" window to end the macro
//
// ------------ IMPORTANT ------------
//
// - only works of one line profile
// - only works for timelapse OR z-stacks
// select window and get dimensions
title_orig = getTitle();
selectWindow(title_orig);
getDimensions(w,h,ch,sl,fr);
// get line coordinates and clear selection for checking overall min/max values
getSelectionCoordinates(xlc, ylc);
run("Select None");
// check dimensions
if (sl == 1 && fr >= 1)
dim = fr; // --> time lapse data
if (sl >= 1 && fr == 1)
dim = sl; // --> z-stack data
// check min & max of line profile for whole stack for scaling issues
minLine = 0;
maxLine = 0;
minLine_tmp = 0;
maxLine_tmp = 0;
for (i=1; i<=dim; i++) {
// set current slice
setSlice(i);
getStatistics(area, mean, min_tmp, max_tmp);
print(min_tmp,max_tmp);
if (min_tmp < minLine)
minLine = min_tmp;
if (max_tmp > maxLine)
maxLine = max_tmp;
}
// restore line selection
selectWindow(title_orig);
makeLine(xlc[0],ylc[0],xlc[1],ylc[1]);
// output for used keys and buttons
shift=1;
ctrl=2;
rightButton=4;
alt=8;
leftButton=16;
insideROI = 32; // requires 1.42i or later
x2=-1; y2=-1; z2=-1; flags2=-1;
logOpened = false;
while (!logOpened || isOpen("Log")) {
getCursorLoc(x, y, z, flags);
if (x!=x2 || y!=y2 || z!=z2 || flags!=flags2) {
s = " ";
if (flags&leftButton!=0) s = s + "<left>";
if (flags&rightButton!=0) s = s + "<right>";
if (flags&shift!=0) s = s + "<shift>";
if (flags&ctrl!=0) s = s + "<ctrl> ";
if (flags&alt!=0) s = s + "<alt>";
if (flags&insideROI!=0) s = s + "<inside>";
print(x+" "+y+" "+z+" "+flags + "" + s);
logOpened = true;
//startTime = getTime();
profile = getProfile();
//wait(10);
}
x2=x; y2=y; z2=z; flags2=flags;
//wait(10);
// get profile and do the plotting
profile = getProfile();
Plot.create("Profile", "Line Coordinate", "Value", profile);
Plot.setLimits(0, profile.length, minLine*0.98, maxLine*1.02);
Plot.addText("Frame / Slice : "+z+1, 0.05, 0.2);
Plot.setLineWidth(2);
Plot.update();
}
// determine minimum of array
function getMin(a) {
min=a[0];
for (i=0;i<a.length;i++) {min=minOf(min,a[i]);}
return min;
// determine maximum of array
function getMax(a) {
max=a[0];
for (i=0;i<a.length;i++) {max=maxOf(max,a[i]);}
return max;