Running macros

So, now we have recorded every step needed for the analysis and stored in it a text file. What if we want to run it again? This is done by navigating to the Plugins | Macros | Run... menu option. A file chooser dialog will pop up and we will have to select the file that contains the commands we want to execute. With the tuberculosis image open, choose that menu option, and then the text file we just saved. All the commands will be run one by one and we will end up with exactly the same result as before. Try running the macro for the tuberculosis_full.tif measurements and see if you get the same result we got at the end of the previous chapter. In our tests, it takes about two seconds to compute all the calculations! Now you can compare that to the manual way and grasp the power of ImageJ for image processing.

It is also possible to run a macro while we are writing it. This is normally done during the coding process, so we can be sure that it does what it is supposed to do before saving it definitely. From the macro editing window (not the recorder), we can navigate to the Macros | Run Macro (Ctrl + R) menu option to run all of the commands (or the lines currently selected), or navigate to Macros | Evaluate Line (Ctrl + Y) to execute only the line under the cursor. This is also useful for trying the different code examples that we will present throughout this chapter. Just create a new macro and copy and paste or type the code and run it from the window.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset