Using Process > Batch > Virtual Stack... in a Macro

Tags: #<Tag:0x00007fd6a1636e90>


Due to a combination of circumstances, I need to convert from a single-file 32-bit gray-scale virtual stack to a multiple-file 8-bit gray-scale rotated-and-cropped stack. I want to do this using ImageJ’s macro language and already have an idea of how to do this by iterating through the slices with a for loop. However, I was hoping to take advantage of ImageJ’s batch processor instead. Right now, the only thing holding me back from doing this is I cannot figure out how to specify the output folder. The output in Plugins > Macros > Record… is not correct. It gives run(“Virtual Stack…”, “output=/path/to/output/folder output=TIFF text1=[macro]”). From trial and error, I have determined the output is for the output format, not the output folder.

Does anyone know how to specify the output folder?


Actually, I am having trouble getting the macro call for the format-specific open function. So I can’t actually use a macro to to iterate through the different stacks. It would still be good to know for future reference though.


This bug is fixed in the latest ImageJ daily build (1.51u9). The recorded keyword used for the format is now ‘output_format’. Note that all double quotes in the macro code must be converted to single quotes, as in the following example.

run("Virtual Stack...", "output=/Users/wayne/stack output_format=TIFF text1=[run('8-bit'); run('Rotate 90 Degrees Right'); makeRectangle(400, 400, 600, 500); run('Crop'); ]");


Thanks for the information. That is good to know for future reference. Unfortunately, in my immediate situation, this doesn’t help as I am not permitted to update the version from 1.46a. This is related to the situation in this other thread. I have to use their server’s installation because transferring the files (so I can use my local ImageJ installation) would take to long to meet the end-of-the-week deadline my advisor gave me. The files transfer at 1 MB/s (I tested it) and I would need to transfer 14x 56.6 GB files. By the way, when was “exit and display” added to setBatchMode? Was it in 1.48h, the same as “hide” and “show”?


I don’t know if it will still work since I haven’t installed the latest daily build. However, it seems you can also just escape the double quotes.


Except for a 1.48m bug fix, “exit and display” is missing from the release notes, so there is no easy way to find out when this option was added.