/* RatioToFourthChannel_1a.txt N. Vischer 08.08.19, 13:24 https://sils.fnwi.uva.nl/bcb/objectj/examples/Coli-Inspector/utils/ - Expects a 4-channel hyperstack containing Coli-Inspector markers - Channel 4 will be overwritten by ratio chn2/chn3 - Space outside cell contours will be set to zero - Channel 4 will be set LUT = 16 colors */ macro "Put Ratio chn2/chn3 to chn4"{ for(img = 1; img <= ojNImages(); img++){ ojShowImage(img); Stack.getDimensions(width, height, channels, slices, frames); if(slices > 1) exit("stacks with slices > 1 not suppoorted"); Stack.setDisplayMode("color"); for(frame = 1; frame <= frames; frame++){ run("Select None"); ojShowImage(img); run("Duplicate...", "title=CHN2 duplicate channels=2 frames="+frame); ojShowImage(img); run("Duplicate...", "title=CHN3 duplicate channels=3 frames="+frame); imageCalculator("Divide create 32-bit", "CHN2","CHN3"); rename("CHN4"); run("Multiply...", "value=1000"); setOption("ScaleConversions", false); run("16-bit"); run("Select All"); run("Copy"); ojShowImage(img); Stack.setPosition(4, 1, frame); run("16 Colors"); run("Paste"); close("CHN2"); close("CHN3"); close("CHN4"); Stack.setPosition(1, 1, frame); for (obj = ojFirstObject(img); obj <= ojLastObject(img); obj++){ ojSelectObject(obj); if (ojZPos(1) == getSliceNumber){ thr = ojResult("Thr", obj); setThreshold(0, thr); run("Create Selection"); Stack.setPosition(4, 1, frame); setBackgroundColor(0, 0, 0); run("Clear Outside", "slice"); resetThreshold(); run("Select None"); break; } } } } }