|
I have been trying to write a macro for imageJ / FIJI that will do the following:
* look in the directory specified by the user
* identify the list of image files (.tif) in there ignoring any subdirectories
* identify pairs of images from the list of images
* open a pair of images, carry out my image analysis, save, close the images, and move to the next pair within the folder
The image files are named like this: "A - 44-vent-low-13-288 P5190777.TIF", "B - 44-vent-low-13-288 P5190778.TIF", "A - 44-vent-low-14-289 P5190779.TIF", "B - 44-vent-low-14-289 P5190780.TIF", etc
So a pair of images can be identified by the penultimate numbers (e.g. 288, or 289), with an A image and a B image for each.
I'm pretty new to macro writing and I'm struggling with it.
After a lot of trial and error I've got this far:
input = getDirectory("Choose Source Directory ");
output = input + "Analysed" + File.separator;
if (!File.exists(output)) File.makeDirectory(output);
arrayOfFiles = getFileList(input);
i = index(arrayOfFiles, "Analysed/"); // finds where in the array the sub-directory called "Analysed/" is
//print("index = "+i); // prints that value
function index(a, value) {
for (i=0; i<a.length; i++)
if (a[i]==value) return i;
return -1;
}
//Prints the array in a human-readable form
function printArray(array) {
string="";
for (i=0; i<lengthOf(array); i++) {
if (i==0) {
string=string+array[i];
} else {
string=string+", "+array[i];
}
}
print(string);
}
arrayofA = Array.slice(arrayOfFiles, 0, i);
Array.print(arrayofA);
arrayofB = Array.slice(arrayOfFiles, arrayOfFiles.length-i);
Array.print(arrayofB);
function action(input, output, filename) {
open(input + filename);
saveAs("Tif", output + filename);
close();
}
for (i = 0; i < arrayofA.length; i++)
action(input, output, arrayofA[i]);
</b>
My question is: how do I get my function 'action' to open files from both of my arrays (called "arrayofA" and "arrayofB")? Can the 'i' refer to two arrays at the same time? If so, how?
Many thanks in advance
|