macro "Uniformity" { // Ask for the ROI size and a default pixel size Dialog.create("Enter the square ROI edge info"); Dialog.addNumber("Enter side length of square ROI (mm):", 20); Dialog.addNumber("Enter distance from edge of image to place ROIs (mm):", 30); Dialog.addNumber("Enter pixel size if not contained in tag (mm):", 0.1); Dialog.show(); side_in_mm = Dialog.getNumber(); distance_from_edge = Dialog.getNumber(); default_pixel_size = Dialog.getNumber(); width = getWidth; height = getHeight; // Try and obtain the pixel dimensions tag = getTag("0018,1164"); if (tag=="") { tag = getTag("0028,0030"); } if (tag!="") { pixel_size = split(tag, "\\"); pixel_size = pixel_size[0]; } else { pixel_size = default_pixel_size; } // Work out the distance of ROI centre from edge in pixels x = distance_from_edge / pixel_size; y = distance_from_edge / pixel_size; // Work out the ROI size in pixels side = side_in_mm / pixel_size; offset = side / 2; // top left makeRectangle(x-offset, y-offset, side, side); setSelectionName("top left"); run("Measure"); wait(200); // top right makeRectangle(width - x - offset, y - offset, side, side); setSelectionName("top right"); run("Measure"); wait(200); // centre makeRectangle(width/2 - offset, height/2 - offset, side, side); setSelectionName("centre"); run("Measure"); wait(200); // bottom left makeRectangle(x - offset, height - y - offset, side, side); setSelectionName("bottom left"); run("Measure"); wait(200); // bottom right makeRectangle(width - x - offset, height - y - offset, side, side); setSelectionName("bottom right"); run("Measure"); wait(200); } //----------------------------------------------------------- // This function returns the value of the specified // tag (e.g., "0010,0010") as a string. Returns "" // if the tag is not found. function getTag(tag) { info = getImageInfo(); index1 = indexOf(info, tag); if (index1==-1) return ""; index1 = indexOf(info, ":", index1); if (index1==-1) return ""; index2 = indexOf(info, "\n", index1); value = substring(info, index1+1, index2); return value; } //-----------------------------------------------------------