//11.10.17 20:57 // macro "Prepare [1]"{ run("Remove Overlay"); run("Select None"); roiManager("reset"); setSlice(1); } macro "Mark fiducial point Tool - C04fT1e12FCf00T8e12P" { roiManager("Associate", "true"); roiManager("Show All with labels"); Stack.getDimensions(width, height, channels, slices, frames); thisRoi = floor((getSliceNumber -1)/channels); thisSlice = getSliceNumber; while(roiManager("count") > thisRoi){ //debug; roiManager("select", thisRoi); roiManager("delete"); } setSlice(thisSlice); rad = 50; getCursorLoc(clickX, clickY, z, flags); Stack.setChannel(1); makeRectangle(clickX - rad, clickY - rad, rad * 2, rad * 2); wait(77); run("Gaussian Blur...", "sigma=10 slice"); run("Find Maxima...", "noise=10 output=[Point Selection] light"); run("Undo"); getSelectionCoordinates(xx, yy); makePoint(xx[0], yy[0]); roiManager("add"); //roiManager("update"); while(flags > 0){ getCursorLoc(clickX, clickY, z, flags); wait(9); } run("Select None"); //roiManager("Associate", "true"); next = getSliceNumber + channels; if(next > nSlices) exit("Last slice reached"); setSlice(next); } macro "Use RoiManager to Translate [2]"{ setTool(0); nRois = roiManager("count"); Stack.getDimensions(width, height, channels, slices, frames); if(nRois != nSlices/channels) exit("nRois = " + nRois + " expected = " + (nSlices/channels)); xx = newArray(nRois); yy = newArray(nRois); roiManager("select", 0); getSelectionCoordinates(xx1, yy1);//ref point dxLeft = 0; dxRight = 0; dyUp = 0; dyDown = 0; for(jj = 1; jj< nRois; jj++){ roiManager("select", jj); getSelectionCoordinates(xx2, yy2); dx = xx2[0] - xx1[0]; dy = yy2[0] - yy1[0]; dxLeft = maxOf(dxLeft, -dx); dxRight = maxOf(dxRight, dx); dyUp = maxOf(dyUp, -dy); dyDown = maxOf(dyDown, dy); run("Select None"); Stack.getPosition(channel, slice, frame); for(chn = 1; chn <= channels; chn++){ Stack.setChannel(chn); run("Translate...", " x=" + (-dx) + " y=" + (-dy) + " interpolation=Bilinear slice"); } } setSlice(1); makeRectangle(dxLeft, dyUp, getWidth - (dxLeft+dxRight), getHeight - (dyUp + dyDown)); }