I'm trying to automate a selection of tasks in a Java program, but I can't
let it run in the background because after I run("Convert to Mask") I get prompted with "Convert all images in stack to binary?" Is there something I can set, or argument I can pass that will avoid this dialog? I poked around in the Thresholder.java and didn't see any trivial ways around it. -- William Day |
On Jul 18, 2007, at 4:12 PM, William Day wrote:
> I'm trying to automate a selection of tasks in a Java program, but > I can't > let it run in the background because after I run("Convert to Mask") > I get > prompted with "Convert all images in stack to binary?" > Hi, This is a great time to use the macro recorder (Plugins>Macros>Record...) to see ImageJ expects for arguments to commands. You can usually avoid the dialogs by populating the argument list. For example... Do these to converts the gray scale images in the stack to masks without prompting for a dialog. run("MRI Stack (528K)"); run("Convert to Mask", "calculate black"); In the following the "calculate" argument is missing, but still no dialog. run("MRI Stack (528K)"); run("Convert to Mask", " black"); And finally, an empty string of arguments. Still no dialog. run("MRI Stack (528K)"); run("Convert to Mask", " "); Pretty good stuff! Cheers, Ben > Is there something I can set, or argument I can pass that will > avoid this > dialog? I poked around in the Thresholder.java and didn't see any > trivial > ways around it. > > -- > William Day Ben Tupper Bigelow Laboratory for Ocean Science 180 McKown Point Road POB 475 West Boothbay Harbor, ME 04575 |
Hmm, didn't work. However I am not running the macro inside ImageJ. I am
externally automating ImageJ from a java program, could this be the problem? -- START CODE -- import ij.*; public class TrackerAnalyzeParticles { public static void main(String[] argv) { // ... IJ.selectWindow(filebase); IJ.setThreshold(8, 255); IJ.run("Convert to Mask", " "); IJ.run("Analyze Particles...", "size=4-Infinity circularity=0.00-1.00 show=Nothing display clear stack"); IJ.run("Measurements...", "path='" + file + ".pts'"); //... mainFrame.quit(); } } -- END CODE -- On 7/18/07, Ben Tupper <[hidden email]> wrote: > > On Jul 18, 2007, at 4:12 PM, William Day wrote: > > > I'm trying to automate a selection of tasks in a Java program, but > > I can't > > let it run in the background because after I run("Convert to Mask") > > I get > > prompted with "Convert all images in stack to binary?" > > > > Hi, > > This is a great time to use the macro recorder > (Plugins>Macros>Record...) to see ImageJ expects for arguments to > commands. You can usually avoid the dialogs by populating the > argument list. For example... > > Do these to converts the gray scale images in the stack to masks > without prompting for a dialog. > > run("MRI Stack (528K)"); > run("Convert to Mask", "calculate black"); > > In the following the "calculate" argument is missing, but still no > dialog. > run("MRI Stack (528K)"); > run("Convert to Mask", " black"); > > And finally, an empty string of arguments. Still no dialog. > run("MRI Stack (528K)"); > run("Convert to Mask", " "); > > Pretty good stuff! > > Cheers, > Ben > > > > Is there something I can set, or argument I can pass that will > > avoid this > > dialog? I poked around in the Thresholder.java and didn't see any > > trivial > > ways around it. > > > > -- > > William Day > > Ben Tupper > Bigelow Laboratory for Ocean Science > 180 McKown Point Road > POB 475 > West Boothbay Harbor, ME 04575 > -- William Day |
Hi William,
pretty strange where your problem comes from. There is no such problem (unwanted dialog) in a plugin that I run with "Compile&Run..." (see below). I am using ImageJ 1.38x - if you have an old version, upgrading could possibly help. If you can't solve the problem otherwise, maybe doing the relevant steps in a plugin would be a workaround? import ij.*; import ij.plugin.*; public class TestAnalyzeParticles implements PlugIn { public void run(String arg) { IJ.selectWindow("Stack"); IJ.setThreshold(8, 255); IJ.run("Convert to Mask", " "); IJ.run("Analyze Particles...", "size=4-Infinity circularity=0.00-1.00 show=Nothing display clear stack"); } } Michael ________________________________________________________________ On 18 Jul 2007, at 22:53, William Day wrote: > Hmm, didn't work. However I am not running the macro inside ImageJ. > I am > externally automating ImageJ from a java program, could this be the > problem? > > -- START CODE -- > > import ij.*; > > public class TrackerAnalyzeParticles { > public static void main(String[] argv) { > // ... > > IJ.selectWindow(filebase); > IJ.setThreshold(8, 255); > > IJ.run("Convert to Mask", " "); > > IJ.run("Analyze Particles...", > "size=4-Infinity circularity=0.00-1.00 show=Nothing > display > clear stack"); > > IJ.run("Measurements...", "path='" + file + ".pts'"); > > //... > mainFrame.quit(); > } > } > > -- END CODE -- > > On 7/18/07, Ben Tupper <[hidden email]> wrote: >> >> On Jul 18, 2007, at 4:12 PM, William Day wrote: >> >> > I'm trying to automate a selection of tasks in a Java program, but >> > I can't >> > let it run in the background because after I run("Convert to Mask") >> > I get >> > prompted with "Convert all images in stack to binary?" >> > >> >> Hi, >> >> This is a great time to use the macro recorder >> (Plugins>Macros>Record...) to see ImageJ expects for arguments to >> commands. You can usually avoid the dialogs by populating the >> argument list. For example... >> >> Do these to converts the gray scale images in the stack to masks >> without prompting for a dialog. >> >> run("MRI Stack (528K)"); >> run("Convert to Mask", "calculate black"); >> >> In the following the "calculate" argument is missing, but still no >> dialog. >> run("MRI Stack (528K)"); >> run("Convert to Mask", " black"); >> >> And finally, an empty string of arguments. Still no dialog. >> run("MRI Stack (528K)"); >> run("Convert to Mask", " "); >> >> Pretty good stuff! >> >> Cheers, >> Ben >> >> >> > Is there something I can set, or argument I can pass that will >> > avoid this >> > dialog? I poked around in the Thresholder.java and didn't see any >> > trivial >> > ways around it. >> > >> > -- >> > William Day >> >> Ben Tupper >> Bigelow Laboratory for Ocean Science >> 180 McKown Point Road >> POB 475 >> West Boothbay Harbor, ME 04575 >> > > > > -- > William Day |
Free forum by Nabble | Edit this page |