setTool("polyline"); waitForUser("Draw a line along the shaft of the dendrite. Change Line Width as needed to cover dendrite."); //get current positions and return later getDisplayedArea(x, y, dwidth, dheight); print(x,y,dwidth,dheight); getSelectionCoordinates(xp, yp);//save selected area Stack.getPosition(channel, slice, frame);// - Returns the current position. print(channel, slice, frame); zoom=getZoom(); // get mean in each channel for branch if (selectionType==-1) exit("Area selection required"); Stack.setChannel(1); getStatistics(area, ch1Mean, min, max, std, histogram); print(ch1Mean+"ch1Mean"); Stack.setChannel(2); getStatistics(area, ch2Mean, min, max, std, histogram); print(ch2Mean+"ch1Mean"); Stack.setChannel(3); getStatistics(area, ch3Mean, min, max, std, histogram); print(ch3Mean+"ch1Mean"); print(ch1Mean/ch2Mean+"ratio"); print(ch1Mean/ch3Mean+"ratio"); origTitle=getTitle(); //if exists delete the normalized channel Stack.getDimensions(width, height, channels, slices, frames) ; if (channels>3){ Stack.setChannel(5); run("Delete Slice", "delete=channel"); Stack.setChannel(4); run("Delete Slice", "delete=channel"); } //modify and create new synaptic channels run("Split Channels"); //16 bit cov here bc crashes in entire stack up there selectImage("C1-"+origTitle); run("16-bit"); selectImage("C2-"+origTitle); run("16-bit"); run("Duplicate...", "duplicate"); rename("C4-"+origTitle); run("Multiply...", "value="+ch1Mean/ch2Mean+" stack"); imageCalculator("Subtract stack", "C4-"+origTitle, "C1-"+origTitle); setMinAndMax(ch1Mean/ch2Mean*2,ch1Mean/ch2Mean*15); selectImage("C3-"+origTitle); run("16-bit"); run("Duplicate...", "duplicate"); rename("C5-"+origTitle); run("Multiply...", "value="+ch1Mean/ch3Mean+" stack"); imageCalculator("Subtract stack", "C5-"+origTitle, "C1-"+origTitle); run("Merge Channels...", "c1=[C1-"+origTitle+"] c2=[C2-"+origTitle+"] c3=[C3-"+origTitle+"] c4=[C4-"+origTitle+"] c5=[C5-"+origTitle+"] create"); //original position Stack.setPosition(channel, slice, frame); // Sets the position. run("Set... ", "zoom="+zoom*100+" x="+(x+dwidth/2)+" y="+(y+dheight/2));//xy abovE ARE top left pos. this gets center //redraw selected area out=toString(xp[0])+","; out=out+toString(yp[0]); for (i=1;i