PK JaEMŠ—AO²&²&&Appendix C. Macro by Dale Moulding.ijm // This macro calculates convexity (convex perimeter/perimeter), // sphericity (Maximum Inscribed Circle diameter / Smallest Enclosing circle diameter) and also records standard shape descriptors. // Uses arrays to store results, allowing new measurements to be processed and added to a new results. // It requires Maximum_Inscribed_Circle.jar developed by Olivier Burri and Romain Guiet at BIOP - available from Ïã¸ÛÁùºÏ²ÊÖÐÌØÍø GOS ICH Light Microscopy Facility // Uses smallest enclosing circle macro adapted from Version: 2009-06-12 by Michael Schmid // Written by Dale Moulding 15Jan2018 run("ROI Manager..."); //get image scale Dialog.create("Image scale:"); Dialog.addString("Pixel size in mm", "0.0575"); Dialog.show(); pixelsize = Dialog.getString(); distance = 1/pixelsize; dir1 = getDirectory("Choose Source Directory "); //select an input folder dir2 = getDirectory("Choose a folder to save to"); //select an output folder. list = getFileList(dir1); //make a list of the filenames setBatchMode(true); //turn on batch mode for (j=0; jxmax) {xmax=x[k]; fourIndices[1]=k;} if (y[k]ymax) {ymax=y[k]; fourIndices[3]=k;} } do { badIndex = circle4(x, y); //get circle through points listed in fourIndices newIndex = -1; largestRadius = -1; for (i=0; i largestRadius) { largestRadius = r; newIndex = i; } } //print(largestRadius); retry = (largestRadius > radius*1.0000000000001); fourIndices[badIndex] = newIndex; //add most distant point } while (retry); } //circle spanned by diameter between two points. function circle2(xa,ya,xb,yb) { xcenter = 0.5*(xa+xb); ycenter = 0.5*(ya+yb); radius = 0.5*vecLength(xa-xb, ya-yb); return; } //smallest circle enclosing 3 points. function circle3(xa,ya,xb,yb,xc,yc) { xab = xb-xa; yab = yb-ya; c = vecLength(xab, yab); xac = xc-xa; yac = yc-ya; b = vecLength(xac, yac); xbc = xc-xb; ybc = yc-yb; a = vecLength(xbc, ybc); if (b==0 || c==0 || a*a>=b*b+c*c) return circle2(xb,yb,xc,yc); if (b*b>=a*a+c*c) return circle2(xa,ya,xc,yc); if (c*c>=a*a+b*b) return circle2(xa,ya,xb,yb); d = 2*(xab*yac - yab*xac); xcenter = xa + (yac*c*c-yab*b*b)/d; ycenter = ya + (xab*b*b-xac*c*c)/d; radius = vecLength(xa-xcenter, ya-ycenter); return; } //Get enclosing circle for 4 points of the x, y array and return which //of the 4 points we may eliminate //Point indices of the 4 points are in global array fourIndices function circle4(x, y) { rxy = newArray(12); //0...3 is r, 4...7 is x, 8..11 is y circle3(x[fourIndices[1]], y[fourIndices[1]], x[fourIndices[2]], y[fourIndices[2]], x[fourIndices[3]], y[fourIndices[3]]); rxy[0] = radius; rxy[4] = xcenter; rxy[8] = ycenter; circle3(x[fourIndices[0]], y[fourIndices[0]], x[fourIndices[2]], y[fourIndices[2]], x[fourIndices[3]], y[fourIndices[3]]); rxy[1] = radius; rxy[5] = xcenter; rxy[9] = ycenter; circle3(x[fourIndices[0]], y[fourIndices[0]], x[fourIndices[1]], y[fourIndices[1]], x[fourIndices[3]], y[fourIndices[3]]); rxy[2] = radius; rxy[6] = xcenter; rxy[10] = ycenter; circle3(x[fourIndices[0]], y[fourIndices[0]], x[fourIndices[1]], y[fourIndices[1]], x[fourIndices[2]], y[fourIndices[2]]); rxy[3] = radius; rxy[7] = xcenter; rxy[11] = ycenter; radius = 0; for (k=0; k<4; k++) if (rxy[k]>radius) { badIndex = k; radius = rxy[badIndex]; } xcenter = rxy[badIndex + 4]; ycenter = rxy[badIndex + 8]; return badIndex; } function vecLength(dx, dy) { return sqrt(dx*dx+dy*dy); } //end small enc circle macro roiManager("Add"); number=roiManager("count"); roiManager("select", number-1); roiManager("Rename", i+1+"-SmEnCirc"); roiManager("Measure"); SmallEncCirc[i] = getResult('Feret', i); } // make a new results table run("Clear Results"); run("Select None"); for (i=0; i