//Umis Array Designer //Open an image and set scale [b] //Draw and rotate a rectangular ROI //Create array [u]: //Enter parameters (spacing, force) //Print array file to log window //Draw array on image //Umis Array Designer v0.3 //ImageJ macro for designing UMIS nanoindentation arrays //Copyright (C) 2007 Michael Doube //m.doube at qmul.ac.uk //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License //as published by the Free Software Foundation (version 2). //http://www.gnu.org/copyleft/gpl.html //This program is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. //Declare some global variables var xspacing = 20; var yspacing = 20; var force = 20; var scale = 1; var radius = 3; var thetax; var pos; var marker_offset = 50; var marker_force = 50; macro "Open Image...[b]"{ open(); run("Set Scale...", "distance=1 known=1 pixel=1 unit=pixel"); //default colour setColor(255); scale = abs(scale); Dialog.create("Set Pixel Size"); Dialog.addNumber("microns / pixel", scale); Dialog.show(); scale = Dialog.getNumber(); if (scale != 1) run("Set Scale...", "distance=1 known="+scale+" pixel=1 unit=micron"); } macro "Generate Array... [u]" { scale = abs(scale); type = selectionType(); if (type < 0) exit("Please draw a rectangular ROI"); if (type != 0 && type != 2) exit("I can only handle rectangular arrays!"); Dialog.create("Adjust Indent Parameters"); Dialog.addNumber("X Spacing", xspacing); Dialog.addNumber("Y Spacing", yspacing); Dialog.addNumber("Force", force); Dialog.addNumber("Marker Y Offset", marker_offset); Dialog.addNumber("Marker Force", marker_force); Dialog.addCheckbox("Show Outline", false); Dialog.addCheckbox("Include Marker Indents", true); Dialog.show(); xspacing = Dialog.getNumber(); yspacing = Dialog.getNumber(); force = Dialog.getNumber(); marker_offset = Dialog.getNumber(); marker_force = Dialog.getNumber(); outline = Dialog.getCheckbox(); include_marker = Dialog.getCheckbox(); getSelectionCoordinates(x, y); yrefx = x[0]; yrefy = y[0]; xrefx = x[2]; xrefy = y[2]; startx = x[3]; starty = y[3]; //work out the baseline angle thetax = atan((starty-xrefy)/(xrefx-startx)); //work out the mast angle thetay = atan((starty-yrefy)/(yrefx-startx)); lengthx = sqrt((xrefx-startx)*(xrefx-startx)+(xrefy-starty)*(xrefy-starty)); lengthy = sqrt((yrefx-startx)*(yrefx-startx)+(yrefy-starty)*(yrefy-starty)); width = lengthx * scale; length = lengthy * scale; xcount = floor(width / xspacing)+2; ycount = floor(length / yspacing)+2; //handle top-right start positions if (starty < yrefy) scale = -1*scale; //handle reflected axes if ((starty > yrefy && startx > xrefx)||(starty < yrefy && startx < xrefx)){ scale = -1*scale; } if (include_marker == true) marker_count = 2 + floor(sqrt(xcount)); else marker_count = 0; //extra 2*marker_count is for marker rows npos = xcount * ycount + 2 * marker_count; xpos = newArray(npos); ypos = newArray(npos); //clear the log file print("\\Clear"); k=0; if (include_marker == true){ //calculate first marker row for (h = k; h < marker_count-1; h++){ // marker_tally = marker_tally + xspacing; ypos[h] = 0; if (h*h*xspacing < (xcount-1) * xspacing){ xpos[h] = h*h*xspacing; print(xpos[h]+"\,"+ypos[h]+"\,"+marker_force); k++; } } //calculate the bottom right corner xpos[k] = (xcount-1) * xspacing; ypos[k] = 0; print(xpos[k]+"\,"+ypos[k]+"\,"+marker_force); k++; } //calculate body of array ytally = marker_offset; for (i = 0; i < ycount; i++){ xtally =0; for (j = 0; j < xcount; j++){ xpos[k] = xtally; xtally = xtally + xspacing; ypos[k] = ytally; print(xpos[k]+"\,"+ypos[k]+"\,"+force); k++; } ytally = ytally + yspacing; } if (include_marker == true){ //calculate top marker row for (h = 0; h < marker_count-1; h++){ ypos[k] = (ycount-1)*yspacing + 2*marker_offset; if (h*h*xspacing < (xcount-1) * xspacing){ xpos[k] = h*h*xspacing; print(xpos[k]+"\,"+ypos[k]+"\,"+marker_force); k++; } } //calculate the top right corner xpos[k] = (xcount-1) * xspacing; ypos[k] = (ycount-1)*yspacing + 2*marker_offset; print(xpos[k]+"\,"+ypos[k]+"\,"+marker_force); } //print the selection outline if (outline == true) run("Draw"); //print the array for (pos=0; pos