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 |
Hi Claire,
include an additional if-statement into your loop: list = getFileList(input); for (i = 0; i < list.length; i++){ if (indexOf(list[i], "ch01") >= 0){ action(input, output, list[i]); } } regards peter On 22.06.2020 13:04, c.mackaaij wrote: > 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 -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |