I have a folder containing many images. These are grouped into sets of three images where one filename ends in dsRed).tif
, another filename ends in FITC).tif
and the other filename ends in DAPI).tif
.
How can I tell ImageJ to do different stuff to each image dependent on which filename ending it has?
I have tried to set up macros to run different thresholds, e.g.:
//run("Brightness/Contrast...");
setMinAndMax(0, 20000);
close();
to the different filenames based on scripts found here: http://imagej.1557.x6.nabble.com/open-file-with-specific-partial-name-td5002910.html and here: http://rsb.info.nih.gov/ij/macros/Batch_RGB_Merge.txt but I am having trouble with formatting if else functions with my three filename endings.
You can check the file names with subsequent if ... else
statements:
if (endsWith(filename,"dsRed).tif") {
// do dsRed processing here
} else if (endsWith(filename,"FITC).tif") {
// do FITC processing here
} else if (endsWith(filename,"DAPI).tif") {
// do DAPI processing here
}
If you want to group files that contain the same base name, loop only over one of your channels (e.g. dsRed
) and use replace
:
replace(filename, "dsRed).tif", "FITC).tif");
to process the respective other channel within each loop iteration.