if (nSlices<2) exit("This macro requires a stack.");
makeModalZProject();
function makeModalZProject() {
setBatchMode(true);
run("Set Measurements...", " modal redirect=None decimal=3");
run("Reslice [/]...", "input=1.000 output=1.000 start=Top");
depth = nSlices;
width=getWidth();
for (z=0; z<depth; z++) { // loop through slices
setSlice(z+1);
for (x=0; x<width; x++) { // loop through rows in a slice
makeRectangle(x, 0, 1, depth); // select each column
run("Measure");
zmodal = getResult("Mode",nResults-1);
// be careful if multiple modes are returned this will take the last one.
setPixel(x, 0, zmodal);
}
}
run("Select None");
run("Reslice [/]...", "input=1.000 output=1.000 start=Top");
setBatchMode(false); // display
}