Dear All,
I have a macro that I would like to run as a batch process. I expect it to open the file, let me draw a line and then do a few operations based on that line. The macro works well on individual files. however, when I try to run it as a batch process, instead of opening the file it seems to proceed straight to the selection step. I think this is happening because the macro isn't waiting until the image is open to proceed to next step. I tried "wait" command but had no luck. Also, when I googled about it, I found examples on opening image sequence but that is not what I'm looking for. I want it to work on all the image files in my directory, sequentially without me having to select my file through the open dialog box. Please, find the macro attached. Any help would be appreciated. Regards, Ram -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html split_calc.txt (4K) Download Attachment |
Hello,
if you add setBatchMode(false); as the first command in your macro, you might be able to run it with Process>Batch>Macro... Volker ram prasad: > Dear All, > > I have a macro that I would like to run as a batch process. I > expect it to open the file, let me draw a line and then do a few > operations based on that line. The macro works well on individual > files. however, when I try to run it as a batch process, instead of > opening the file it seems to proceed straight to the selection > step. > > I think this is happening because the macro isn't waiting until the > image is open to proceed to next step. I tried "wait" command but > had no luck. Also, when I googled about it, I found examples on > opening image sequence but that is not what I'm looking for. I want > it to work on all the image files in my directory, sequentially > without me having to select my file through the open dialog box. > > Please, find the macro attached. Any help would be appreciated. > > Regards, Ram > > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Thanks Volker! That seems to have solved my problem atleast partially. When
I include that line and run the macro as a batch process it opens the image for me to make a selection but then after processing the first image it throws the following message instead of opening the next one. ImageJ 1.48v; Java 1.6.0_24 [64-bit]; Linux 3.13.0-48-generic; 36MB of 2257MB (1%) java.lang.NullPointerException at ij.process.ColorProcessor.<init>(ColorProcessor.java:30) at ij.ImagePlus.setupProcessor(ImagePlus.java:715) at ij.ImagePlus.getFileInfo(ImagePlus.java:1780) at ij.io.FileSaver.<init>(FileSaver.java:34) at ij.IJ.saveAsTiff(IJ.java:1736) at ij.IJ.saveAs(IJ.java:1665) at ij.plugin.BatchProcessor.processFolder(BatchProcessor.java:200) at ij.plugin.BatchProcessor.run(BatchProcessor.java:91) at ij.IJ.runPlugIn(IJ.java:169) at ij.Executer.runCommand(Executer.java:131) at ij.Executer.run(Executer.java:64) at java.lang.Thread.run(Thread.java:662) How should I go about this? Cheers, Ram On Thu, Jan 21, 2016 at 11:37 AM, Volker Baecker <[hidden email] > wrote: > Hello, > if you add > > setBatchMode(false); > > as the first command in your macro, you might be able to run it with > Process>Batch>Macro... > > Volker > > ram prasad: > > Dear All, > > > > I have a macro that I would like to run as a batch process. I > > expect it to open the file, let me draw a line and then do a few > > operations based on that line. The macro works well on individual > > files. however, when I try to run it as a batch process, instead of > > opening the file it seems to proceed straight to the selection > > step. > > > > I think this is happening because the macro isn't waiting until the > > image is open to proceed to next step. I tried "wait" command but > > had no luck. Also, when I googled about it, I found examples on > > opening image sequence but that is not what I'm looking for. I want > > it to work on all the image files in my directory, sequentially > > without me having to select my file through the open dialog box. > > > > Please, find the macro attached. Any help would be appreciated. > > > > Regards, Ram > > > > -- 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 |
That is because Process>Batch>Macro will try to save an image as a
result and then close it. You can get around this by removing the last close command in your macro. However there are some more problems: 1. There is an error in line 82, there is a quote (") too much. It should be: run("Duplicate...", "title=[for mask]"); 2. Since you keep all rois in the roi manager it will select the wrong roi in subsequent iterations (always 0 and 1). Maybe you could reset the roi manager at the start of the macro to solve this. 3. After that it still does not work for me. It complains that it needs a stack for the command run("HSB Stack"). And the run("Convert to Mask"); does not have its input either. Maybe this will not happen in your version? I can work around it by putting in waitForUser() commands before the to commands. Volker ram prasad: > Thanks Volker! That seems to have solved my problem atleast partially. When > I include that line and run the macro as a batch process it opens the image > for me to make a selection but then after processing the first image it > throws the following message instead of opening the next one. > > ImageJ 1.48v; Java 1.6.0_24 [64-bit]; Linux 3.13.0-48-generic; 36MB of > 2257MB (1%) > > java.lang.NullPointerException > at ij.process.ColorProcessor.<init>(ColorProcessor.java:30) > at ij.ImagePlus.setupProcessor(ImagePlus.java:715) > at ij.ImagePlus.getFileInfo(ImagePlus.java:1780) > at ij.io.FileSaver.<init>(FileSaver.java:34) > at ij.IJ.saveAsTiff(IJ.java:1736) > at ij.IJ.saveAs(IJ.java:1665) > at ij.plugin.BatchProcessor.processFolder(BatchProcessor.java:200) > at ij.plugin.BatchProcessor.run(BatchProcessor.java:91) > at ij.IJ.runPlugIn(IJ.java:169) > at ij.Executer.runCommand(Executer.java:131) > at ij.Executer.run(Executer.java:64) > at java.lang.Thread.run(Thread.java:662) > > How should I go about this? > > Cheers, > Ram > > On Thu, Jan 21, 2016 at 11:37 AM, Volker Baecker <[hidden email] >> wrote: > >> Hello, >> if you add >> >> setBatchMode(false); >> >> as the first command in your macro, you might be able to run it with >> Process>Batch>Macro... >> >> Volker >> >> ram prasad: >>> Dear All, >>> >>> I have a macro that I would like to run as a batch process. I >>> expect it to open the file, let me draw a line and then do a few >>> operations based on that line. The macro works well on individual >>> files. however, when I try to run it as a batch process, instead of >>> opening the file it seems to proceed straight to the selection >>> step. >>> >>> I think this is happening because the macro isn't waiting until the >>> image is open to proceed to next step. I tried "wait" command but >>> had no luck. Also, when I googled about it, I found examples on >>> opening image sequence but that is not what I'm looking for. I want >>> it to work on all the image files in my directory, sequentially >>> without me having to select my file through the open dialog box. >>> >>> Please, find the macro attached. Any help would be appreciated. >>> >>> Regards, Ram >>> >>> -- 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 > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Thanks for pointing out the errors, Volker. After I submitted my original
script I noticed the extra double quote and I removed it in my local version. And for 3, I did get that error but not all the time. When I ran my macro as a batch process, it worked well on two images before it quit on the third one. It said that it needs a stack to "convert images to stack". But thanks for your tip. I used wait(1000) between those two commands and that seems to have worked. Many thanks again. Cheers, Ram On Thu, Jan 21, 2016 at 2:01 PM, Volker Baecker <[hidden email]> wrote: > That is because Process>Batch>Macro will try to save an image as a > result and then close it. You can get around this by removing the last > close command in your macro. > > However there are some more problems: > > 1. There is an error in line 82, there is a quote (") too much. It > should be: > run("Duplicate...", "title=[for mask]"); > > 2. Since you keep all rois in the roi manager it will select the wrong > roi in subsequent iterations (always 0 and 1). Maybe you could reset the > roi manager at the start of the macro to solve this. > > 3. After that it still does not work for me. It complains that it needs > a stack for the command run("HSB Stack"). And the run("Convert to > Mask"); does not have its input either. > Maybe this will not happen in your version? I can work around it by > putting in waitForUser() commands before the to commands. > > Volker > > ram prasad: > > Thanks Volker! That seems to have solved my problem atleast partially. > When > > I include that line and run the macro as a batch process it opens the > image > > for me to make a selection but then after processing the first image it > > throws the following message instead of opening the next one. > > > > ImageJ 1.48v; Java 1.6.0_24 [64-bit]; Linux 3.13.0-48-generic; 36MB of > > 2257MB (1%) > > > > java.lang.NullPointerException > > at ij.process.ColorProcessor.<init>(ColorProcessor.java:30) > > at ij.ImagePlus.setupProcessor(ImagePlus.java:715) > > at ij.ImagePlus.getFileInfo(ImagePlus.java:1780) > > at ij.io.FileSaver.<init>(FileSaver.java:34) > > at ij.IJ.saveAsTiff(IJ.java:1736) > > at ij.IJ.saveAs(IJ.java:1665) > > at ij.plugin.BatchProcessor.processFolder(BatchProcessor.java:200) > > at ij.plugin.BatchProcessor.run(BatchProcessor.java:91) > > at ij.IJ.runPlugIn(IJ.java:169) > > at ij.Executer.runCommand(Executer.java:131) > > at ij.Executer.run(Executer.java:64) > > at java.lang.Thread.run(Thread.java:662) > > > > How should I go about this? > > > > Cheers, > > Ram > > > > On Thu, Jan 21, 2016 at 11:37 AM, Volker Baecker < > [hidden email] > >> wrote: > > > >> Hello, > >> if you add > >> > >> setBatchMode(false); > >> > >> as the first command in your macro, you might be able to run it with > >> Process>Batch>Macro... > >> > >> Volker > >> > >> ram prasad: > >>> Dear All, > >>> > >>> I have a macro that I would like to run as a batch process. I > >>> expect it to open the file, let me draw a line and then do a few > >>> operations based on that line. The macro works well on individual > >>> files. however, when I try to run it as a batch process, instead of > >>> opening the file it seems to proceed straight to the selection > >>> step. > >>> > >>> I think this is happening because the macro isn't waiting until the > >>> image is open to proceed to next step. I tried "wait" command but > >>> had no luck. Also, when I googled about it, I found examples on > >>> opening image sequence but that is not what I'm looking for. I want > >>> it to work on all the image files in my directory, sequentially > >>> without me having to select my file through the open dialog box. > >>> > >>> Please, find the macro attached. Any help would be appreciated. > >>> > >>> Regards, Ram > >>> > >>> -- 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 > > > > -- > 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 |