Selective batch processing within a folder using macro

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Selective batch processing within a folder using macro

rituroych
Dear All,

I have written a macro to process all the files in a folder.
The folder contains around 100 images, but I would like to choose a certain number of files at a time for batch processing using the macro and not the entire folder. Please suggest a method to do so.

Thanks!

Best,
Ritu.

Reply | Threaded
Open this post in threaded view
|

Re: Selective batch processing within a folder using macro

Krs5
Dear Ritu



You could use something like:



dir1 = getDirectory("Select Directory with files");

list = getFileList(dir1);

Dialog.create("Select files")

                Dialog.addNumber("Select the first image to analyse:", 1);

                Dialog.addNumber("Select the last image to analyse", list.length);

Dialog.show()

start = Dialog.getNumber();

end = Dialog.getNumber();

for (i=(start - 1); i<end; i++){

                Here goes your analysis code

}



This works only when there are only image files in the directory and there are no subdirectories. Otherwise you have somehow correct for those...



Best wishes



Kees



Dr Ir K.R. Straatman

Senior Experimental Officer

Advanced Imaging Facility

Centre for Core Biotechnology Services

University of Leicester

http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/lite/aif





ImageJ workshops 12 and 13 December : http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/lite/aif/workshops/imagej-workshops-December-2016





-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of rituroych
Sent: 13 October 2016 13:46
To: [hidden email]
Subject: Selective batch processing within a folder using macro



Dear All,



I have written a macro to process all the files in a folder.

The folder contains around 100 images, but I would like to choose a certain number of files at a time for batch processing using the macro and not the entire folder. Please suggest a method to do so.



Thanks!



Best,

Ritu.











--

View this message in context: http://imagej.1557.x6.nabble.com/Selective-batch-processing-within-a-folder-using-macro-tp5017364.html

Sent from the ImageJ mailing list archive at Nabble.com.



--

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

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Selective batch processing within a folder using macro

ved sharma
In reply to this post by rituroych
Dear Ritu,

You can try something like this:
//
start = 11; end = 20;

for(i=0, count=0; i<filenames.length; i++, count++) {
        if(count >= start &&amp; count <= end) {

                process file... (your macro code)

        }
}
//

An alternative might be to use the regular expressions (regex) matching, with an if statement: if(matches(filename, regex)). But this will require you to see (and construct) a pattern to the files you want to select.  BTW, you can use regex based selection of files in the ImageJ's in-built batch processor (Process > Batch > Macro...), using "File name contains" option.

Hope this helps,

Ved

_________________________________
Ved Sharma, PhD
Department of Anatomy and Structural Biology
Albert Einstein College of Medicine
Bronx, New York

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