Hi everybody,
I'm working on measuring areas of water droplets upon a surface, and to do so I've created a pretty simple macro: run("8-bit"); setAutoThreshold("Default dark"); //run("Threshold..."); setThreshold(200, 255); run("Convert to Mask"); setThreshold(255, 255); run("Watershed"); run("Analyze Particles...", "size=5000-Infinity circularity=0.60-1.00 show=[Bare Outlines] display clear"); selectWindow("Results"); Is it possible for me to apply this macro to a large batch of images all at once? I'm not entirely familiar with macros and macro language so forgive me if its fairly simple. Thanks Thomas Huang |
If they are all in the same folder:
path=getDirectory("image"); list=getFileList(path); will get you a list of the files in a folder. Then put your current macro in the following loop: for(i=0;i<list.length;i++){ open(path+list[i]); } You will also have to save the results on each loop so they are not over written. Also close the image once used or they could all end up opened! :) Kenton Kenton Arkill GB U23 Ladies' Underwater Hockey Coach GB Masters Underwater Hockey Manager On 22 Aug 2012, at 16:17, Broncosbeatall wrote: > Hi everybody, > > I'm working on measuring areas of water droplets upon a surface, and to do > so I've created a pretty simple macro: > run("8-bit"); > setAutoThreshold("Default dark"); > //run("Threshold..."); > setThreshold(200, 255); > run("Convert to Mask"); > setThreshold(255, 255); > run("Watershed"); > run("Analyze Particles...", "size=5000-Infinity circularity=0.60-1.00 > show=[Bare Outlines] display clear"); > selectWindow("Results"); > > Is it possible for me to apply this macro to a large batch of images all at > once? > I'm not entirely familiar with macros and macro language so forgive me if > its fairly simple. > Thanks > > Thomas Huang > > > > -- > View this message in context: http://imagej.1557.n6.nabble.com/Apply-a-macro-to-a-batch-of-images-tp4999833.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 |
I'd also like to note that the method described above is probably the
easiest/most intuitive way to batch process. The batch commands are stored in the macro itself and are written in native ImageJ syntax (which is java). I wanted to point out that because macros are standalone files, they can be executed through your operating system's terminal. Therefore, it is possible to write scripts in other programming languages like Bash or Python (and others) which call the macros through references to the command line. This is useful in some instances, for example, when your image analysis is only a part of the workflow in an otherwise different programming environment, or when you prefer not to run all of the ancillary analysis from within the macro environment. Right now, I'm doing image analysis in python. My scripts automatically walk through my filesystem, taking in only folders and subfolders of interest, and then generate and executes macros based on parameters that I adjust at runtime. The output is also subsequently analyzed in python. This program uses python to interactively generate and run imageJ macros based on use-set parameters and filenames. Here is an example of calling image J from Python that I followed closely. http://fzu.cz/~dominecf/misc/imagej_particles.html This may be overkill for your intents and purposes, but I think it is important to know that this option exists, and also it may be informative to other users on the mailing list. PS Broncos going down on opening day. On Wed, Aug 22, 2012 at 11:25 AM, Kenton Arkill <[hidden email]>wrote: > If they are all in the same folder: > > path=getDirectory("image"); > list=getFileList(path); > > will get you a list of the files in a folder. Then put your current macro > in the following loop: > > for(i=0;i<list.length;i++){ > open(path+list[i]); > } > You will also have to save the results on each loop so they are not over > written. Also close the image once used or they could all end up opened! :) > Kenton > > Kenton Arkill > GB U23 Ladies' > Underwater Hockey Coach > GB Masters > Underwater Hockey Manager > > > > > On 22 Aug 2012, at 16:17, Broncosbeatall wrote: > > > Hi everybody, > > > > I'm working on measuring areas of water droplets upon a surface, and to > do > > so I've created a pretty simple macro: > > run("8-bit"); > > setAutoThreshold("Default dark"); > > //run("Threshold..."); > > setThreshold(200, 255); > > run("Convert to Mask"); > > setThreshold(255, 255); > > run("Watershed"); > > run("Analyze Particles...", "size=5000-Infinity circularity=0.60-1.00 > > show=[Bare Outlines] display clear"); > > selectWindow("Results"); > > > > Is it possible for me to apply this macro to a large batch of images all > at > > once? > > I'm not entirely familiar with macros and macro language so forgive me if > > its fairly simple. > > Thanks > > > > Thomas Huang > > > > > > > > -- > > View this message in context: > http://imagej.1557.n6.nabble.com/Apply-a-macro-to-a-batch-of-images-tp4999833.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 > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Kenton Arkill
Kenton it worked exactly as I wanted it to, thank you very much!
I have yet to try the second method but definitely will in the near future. Thanks for the help everybody. Thomas Huang |
In reply to this post by Broncosbeatall
Thomas,
Such a simple code can be run on a dataset in one folder also using an imageJ menu process>batch>macro without filling the output path parameter. It does exactly the same job like a "filelist" code. Schebique Dne 22.8.2012 17:17 "Broncosbeatall" <[hidden email]> napsal(a): > Hi everybody, > > I'm working on measuring areas of water droplets upon a surface, and to do > so I've created a pretty simple macro: > run("8-bit"); > setAutoThreshold("Default dark"); > //run("Threshold..."); > setThreshold(200, 255); > run("Convert to Mask"); > setThreshold(255, 255); > run("Watershed"); > run("Analyze Particles...", "size=5000-Infinity circularity=0.60-1.00 > show=[Bare Outlines] display clear"); > selectWindow("Results"); > > Is it possible for me to apply this macro to a large batch of images all at > once? > I'm not entirely familiar with macros and macro language so forgive me if > its fairly simple. > Thanks > > Thomas Huang > > > > -- > View this message in context: > http://imagej.1557.n6.nabble.com/Apply-a-macro-to-a-batch-of-images-tp4999833.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 |
Free forum by Nabble | Edit this page |