// This macro demonstrates how to use string concatenation to // pass variables to commands called using the run() function. // It creates an image, sets the scale to 150 pixels/mm, rotates // 25 degrees, and saves in Analyze format. Note that the file // path must be enclosed in brackets because of the space in // the image name. // // In ImageJ 1.43 and later variables can be passed by adding // "&" to the variable name. File paths passed using this // method do not have to be enclosed in brackets. name = "Test Image"; directory = getDirectory("home"); width = 400; height = 300; scale = 150; // 150 pixels/mm unit = "mm"; angle = 25; newImage(name, "8-bit ramp", width, height, 1); if (getVersion>"1.43k") { run("Set Scale...", "distance=&scale known=1 pixel=1 unit=&unit"); run("Arbitrarily...", "interpolate angle=&angle"); path = directory+name; run("Analyze 7.5...", "save=&path"); } else { run("Set Scale...", "distance="+scale+" known=1 pixel=1 unit="+unit); run("Arbitrarily...", "interpolate angle="+angle); path = "["+ directory+name+"]"; run("Analyze 7.5...", "save="+path); }