macro "Signal transfer properties (DIR)" { // Macro "DR_signal_transfer_properties_dir.txt" written by David Platten // Started on 13th September 2006 // Continued on 12th February 2009 // Version 0.5 // // Summary // Asks the user for a directory containing images to be analysed. // Opens each image in turn and calcs stats for one central ROI. requires("1.33n"); dir = getDirectory("Choose directory with uniformity images"); list = getFileList(dir); // Ask for the ROI size Dialog.create("Enter the ROI size (mm)"); Dialog.addNumber("Enter size of measurement ROI (mm):", 20); Dialog.addNumber("Enter pixel size if not contained in tag (mm):", 0.1); Dialog.show(); roi_size_mm = Dialog.getNumber(); default_pixel_size = Dialog.getNumber(); // comment out the line below to see the images come up // setBatchMode(true); run("Set Measurements...", "area mean standard display redirect=None decimal=9"); for(i=0; i=1) { central_square_roi(roi_size_mm); close(); } } function central_square_roi(side_length_mm) { width = getWidth; height = getHeight; getVoxelSize(pixel_width, pixel_height, pixel_depth, pixel_units); // If the pixel_units is "pixels" then assume image doesn't have size information // so use the value entered by the user instead if (pixel_units=="pixels") pixel_width = default_pixel_size; side_length_pixels = side_length_mm / pixel_width; // I'm assuming same pixel width and height x = (width / 2) - (side_length_pixels/2); y = (height / 2) - (side_length_pixels/2); // centre makeRectangle(x, y, side_length_pixels, side_length_pixels); setSelectionName("centre"); run("Measure"); //wait(200); } }