Posted by
syntonicC on
URL: http://imagej.273.s1.nabble.com/Calling-an-ImageJ-macro-on-files-in-sets-of-3-tp5013674p5013696.html
Thanks for your help!
Here is what I have so far.
dir=getDirectory("Choose a Directory");
print(dir);
list = getFileList(dir);
Array.sort(list);
for (i=0; i<list.length; i+=3) {
open(list[i]);
original=getTitle;
blue=substring(original,0,lengthOf(original)-9)+"-blue.tif";
open(list[i+1]);
original=getTitle;
green=substring(original,0,lengthOf(original)-10)+"-green.tif";
open(list[i+2]);
original=getTitle;
red=substring(original,0,lengthOf(original)-8)+"-red.tif";
// print(blue);
// print(red);
// print(green);
run("JACoP ", "imga=&red imgb=&blue thra=648 thrb=517 pearson mm");
run("JACoP ", "imga=&red imgb=&green thra=648 thrb=517 pearson mm");
run("JACoP ", "imga=&blue imgb=&green thra=648 thrb=517 pearson mm");
}
The format of my images is a little different than how I had them in the original post. In any case, the print functions I included for testing correctly returns the full image names of the first three blue, green, and red images in that order. So far so good!
However, when I run the JACoP plugin it complains that the images were not found. Am I using string interpolation correctly? I thought I had to use square brackets to pass the variable into the string but apparently this is not the case anymore for the run function. According to <a href="
http://rsb.info.nih.gov/ij/developer/macro/macros.html">this page:
With ImageJ 1.43 and later, there is an easier method that only requires adding "&" to the variable name in the options string. String variables passed using this method do not have to be enclosed in brackets.
I am using ImageJ version 1.48v.