/* Michael Cammer mcammer@gmail.com cammem01@nyumc.org or mcammer@gmail.com Radial reslicing modified from macros written for Dustin lab 2010-11. If used for publication, please credit the DART Microscopy Core at NYU Health. ImageJ 1.52 Java 1.8.0 last updated 20180617 */ var diameter = 120; // To change the diameter of the sweep, change this number; should be even integer var number_of_radii = 2 * PI * diameter / 2 + 1; // number of pixels on circumference-- (don't know if +n really needed) var tab = " \t"; // for ease writing tab delimited output //===================================================================================== // After I wrote this, somebody posted a similar plugin version at http://rsbweb.nih.gov/ij/plugins/radial-reslice/ // This macro produces radial reslices from the center out. The original version of this reslicing went from the // periphery such that the alignment was along the traced outer edge and could be used for the annuluar // intensity and spatial distribution in relation to the outer edge of spreading cells instead of in relation to the center // and some slices never even went to the very center. //===================================================================================== macro"Radial Sweep [q]"{ requires("1.52a"); maxradius = diameter/2; // this variable name is holdover from original code which got the Ferets diameter of an uneven shape for the maximum radius run("Set Scale...", "distance=1 known=1 pixel=1 unit=px"); // spatial scale removed. If you want to keep it, add code to get it and apply it to the results run("Set Measurements...", " centroid redirect=None decimal=0"); run("Measure"); xc = getResult("X", nResults-1); yc = getResult("Y", nResults-1); selectWindow("Results"); run("Close"); step = 2 * PI / number_of_radii; extrasteps = 0; // allows for overshooting to adjust for when slices are projected together for wedges original = getImageID(); originaltitle = getTitle(); bits = bitDepth(); newtitle = "reslice_" + getTitleStripExtension(); newslices = 1 + number_of_radii + extrasteps; newbits = "" + bits + "-bit Black"; newImage(newtitle, newbits, diameter, 2, 1); stream = getImageID(); setBatchMode(true); selectImage(original); run("Add Slice"); setSlice(1); setPasteMode("Copy"); s=1; for (i=0; i<2*PI+(step*extrasteps); i=i+step) { edgex = xc + maxradius * sin(i); edgey = yc + maxradius * cos(i); edgex2 = xc + maxradius * sin(i+PI); edgey2 = yc + maxradius * cos(i+PI); selectImage(original); makeLine(edgex, edgey,edgex2, edgey2); run("Reslice [/]...", "input=1.000 output=1.000 start=Top"); run("Select All"); run("Copy"); run("Close"); selectImage(stream); run("Paste"); run("Add Slice"); } //for i run("Delete Slice"); setBatchMode(false); run("Canvas Size...", "width="+diameter+" height=1 position=Top-Center zero"); run("Reslice [/]...", "output=1.000 start=Top"); resetMinAndMax(); run("Select All"); run("Plot Profile"); selectImage(original); setSlice(2); run("Delete Slice"); selectImage(stream); close(); } //macro("Radial Sweep") //=================================== macro "Save ROI Manager [F7]" { if ( getInfo("window.type") != "Image" ) exit("Make sure running macro from image window."); dir = getDirectory("image"); // where to save results if (lengthOf(dir) < 1) exit("Make sure the image was opened from disk."); title = getTitleStripExtension(); newName =dir + title + ".zip"; // add command to select none in ROIManager to mae sure all saved? roiManager("Save", newName); roiManager("reset"); } // end Save ROI Manager [F7] /==================================== // Use this function to strip any number of extensions // off images. // Returns the title without the extension. //==================================== function getTitleStripExtension() { t = getTitle(); extensions = newArray(".tif", ".tiff", ".lif", ".lsm", ".czi", ".nd2", ".ND2", ".jpg"); for(i=0; i