Login  Register

selecting only specific files from folder batch macro

Posted by c.mackaaij on Jun 22, 2020; 11:04am
URL: http://imagej.273.s1.nabble.com/selecting-only-specific-files-from-folder-batch-macro-tp5023553.html

Dear all,

I have a working macro for my analysis (see code below). But I would like to
run the analysis only on specific images from a folder. I have images with
multiple channels and I'm only interested in 1 (suffix of the file name is
ch01) As there are more than 6000 files in the folder, I was wondering if I
could make Image J do the image selection for me. So i want to only run the
macro on the images with ch01 as a suffix)

Any tips would be helpful! Thanks in advance,

Claire

input = getDirectory("Choose Source Directory ");
output = getDirectory("Choose Destination Directory ");

setBatchMode(true);
list = getFileList(input);
for (i = 0; i < list.length; i++)
        action(input, output, list[i]);

setBatchMode(false);
function action(input, output, filename) {
open(input + filename);
filename=getTitle();
setAutoThreshold("Default");
setThreshold(30, 180); // treshhold
run("Measure");
run("Analyze Particles...", "pixel show=[Overlay Masks] display clear
summarize");
selectWindow("Results");
        // waitForUser(10);
        index = lastIndexOf(filename, ".");
        // print(index);
        if (index!=-1) name = substring(filename, 0, index);
        name = name + ".txt";
        saveAs("Results", output+name);

// print(dir+name);
        selectImage(filename);
        saveAs("jpeg", output + filename);
        close();

        }




--
Sent from: http://imagej.1557.x6.nabble.com/

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html