//Creates a square substack (size = 2 * rad) holding the //neighborhood of the click position in each slice. //The user has to click into each slice of the current stack; //N. Vischer // 29.11.16 17:44 macro "Make Substack Tool - C04fT1e12SCf08T8e12s" { rad = 150; srcNSlices = nSlices; Stack.getDimensions(ww, hh, channels, slices, frames); if(maxOf(slices, frames) != srcNSlices) exit ("Does not work for hyperstacks"); if(getTitle == "Substack") exit"Cannot click in SubStack"); srcID = getImageID; getCursorLoc(x, y, z, flags); makeRectangle(x - rad, y - rad, rad * 2, rad * 2); run("Copy"); wait(100); slc = getSliceNumber; if(!isOpen("SubStack")){ run("Duplicate...", "duplicate title=SubStack"); run("Set...", "value=0 stack"); } selectImage("SubStack"); if(nSlices != srcNSlices || getWidth != rad* 2 ) exit("SubStack has different dimensions - better delete it"); setSlice(slc); run("Paste"); if(slc < nSlices){ selectImage(srcID); setSlice(slc+1); } else{ name = getString("Rename SubStack", ""); rename(name); } }