//Macros to collect radiolarian morphometric measurements for acquisition
//to the RadData database, via its R interface.
//Written by Ben Kotrc, Mar 1st, 2011
//Declare global variables
//Measurement number (in reference to R interface image)
var counter = 0;
//Microscope magnification (e.g. 16x, 40x, etc)
var objective = “??x.”;
//Macro to write all measurements of type “Length” taken since the last
//file write operation, with the current image file name, to the pipe file
macro “Save linear measurements to file [1]” {
//Get name of currently open image file
curfname=getInfo(“image.filename”);
//Loop through each row in the Results table
for (i=counter; i<nResults; i++){
//Extract the ith row from the “Length” column of the Results table
measurement = getResult(“Length”, i);
//Concatenate row of data to be appended to pipe file (data + filename)
insertion = d2s(measurement,2) + “\t” + curfname;
//Append the ith measurement to the Results table
File.append(insertion, “/Users/Ben/Dropbox/Harvard/By-Lineage\ Rads/RadData\ Database/pipefilename.txt”);
//Increment the measurement counter
counter++;
}
//Display in log window how many measurements have been written to file
print(“\\Clear”);
print(“Scale set to ” + objective + “.”);
print(d2s(counter,0) + ” measurements recorded to file.”);
}
//Macro to calculate the pore area proportion from the measurements added
//to the results table since the last file write operation, then write the
//number to file with the current image file name
macro “Save area measurement to file [2]” {
//Get name of currently open image file
curfname=getInfo(“image.filename”);
//Find the sum of all but the first row in the Results table
sum=0;
for (i=counter+1; i<nResults; i++){
sum = sum + getResult(“Area”,i);
}
//Find the pore area proportion
measurement = sum/getResult(“Area”,counter);
//Concatenate row of data to be appended to pipe file (data + filename)
insertion = d2s(measurement,4) + “\t” + curfname;
//Append the result to file
File.append(insertion, “/Users/Ben/Dropbox/Harvard/By-Lineage\ Rads/RadData\ Database/pipefilename.txt”);
//Increment the measurement counter
counter++;
//Display in log window how many measurements have been written to file
print(“\\Clear”);
print(“Scale set to ” + objective + “.”);
print(d2s(counter,0) + ” measurements recorded to file.”);
//Tidy up the Results table
IJ.deleteRows(counter,nResults-1);
setResult(“Area”,counter-1,measurement);
}
//Macro to insert a zero-valued measurement to the pipe file, and update
//the ImageJ results table accordingly
macro “Add zero measurement to file [3]” {
measurement = 0;
curfname = “No file”;
//Concatenate row of data to be appended to pipe file (data + filename)
insertion = d2s(measurement,4) + “\t” + curfname;
//Append the result to file
File.append(insertion, “/Users/Ben/Dropbox/Harvard/By-Lineage\ Rads/RadData\ Database/pipefilename.txt”);
//Update Results table to reflect added zero “measurement”
setResult(“Area”, counter, 0);
//Increment the measurement counter
counter++;
//Display in log window how many measurements have been written to file
print(“\\Clear”);
print(“Scale set to ” + objective + “.”);
print(d2s(counter,0) + ” measurements recorded to file.”);
}
//Macro to reset the tally of the number of measurements written to file,
//as displayed in the log window, to zero (use each time a new individual
//is started)
macro “Reset measurement counter [4]” {
//Clear the Results table
selectWindow(“Results”);
run(“Close”);
//Reset counter
counter = 0;
//Display in log window
print(“\\Clear”);
print(“Scale set to ” + objective + “.”);
print(d2s(counter,0) + ” measurements recorded to file.”);
}
\\Macro to set the appropriate scale for different microscope objectives
macro “Set magnification… [5]” {
Dialog.create(“Set magnification”);
Dialog.addChoice(“Objective:”, newArray(“16x”, “40x”, “80x”, “100x”));
Dialog.show();
objective = Dialog.getChoice();
if (objective == “16x”) {
run(“Set Scale…”, “distance=1190 known=26.3 pixel=1 unit=µm”);
} else if (objective == “40x”){
run(“Set Scale…”, “distance=1190 known=26.3 pixel=1 unit=µm”);
} else if (objective == “80x”){
run(“Set Scale…”, “distance=1190 known=26.3 pixel=1 unit=µm”);
} else if (objective == “1000x”){
run(“Set Scale…”, “distance=1190 known=26.3 pixel=1 unit=µm”);
}
//Print new magnification in log window, along with # of measurements taken
print(“\\Clear”);
print(“Scale set to ” + objective + “.”);
print(d2s(counter,0) + ” measurements recorded to file.”);
}