I am writing a macro to batch process multiple files in a folder. When I run
this code, I'm getting the error message "No plot window in line 6". What is causing this and how can it be fixed? Thanks in advance. function action(output, filename) { open(input + filename); makeRectangle(75, 47, 40, 42); run("Plot Z-axis Profile", "profile=time"); Plot.showValues(); saveAs("Results", output + filename); close(); } input = "C:/Users/Admin/Desktop/Input/"; output = "C:/Users/Admin/Desktop/Output/"; setBatchMode(true); list = getFileList(input); for (i = 0; i < list.length; i++) { action(output, list[i]); } setBatchMode(false); -- Sent from: http://imagej.1557.x6.nabble.com/ -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi,
It seems like an issue with batch mode. It works for me when I comment out the setBatchMode(true). Also, as an aside, you may want to change: saveAs("Results", output + filename); To: saveAs("Results", output + filename + ".txt"); So that your results aren't saved into files that look like (but are not) images. Regards, Curtis -- Curtis Rueden LOCI software architect - https://loci.wisc.edu/software ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden Have you tried the Image.sc Forum? https://forum.image.sc/ On Fri, Jun 7, 2019 at 8:14 AM fieryice12 <[hidden email]> wrote: > I am writing a macro to batch process multiple files in a folder. When I > run > this code, I'm getting the error message "No plot window in line 6". What > is > causing this and how can it be fixed? Thanks in advance. > > function action(output, filename) > { > open(input + filename); > makeRectangle(75, 47, 40, 42); > run("Plot Z-axis Profile", "profile=time"); > Plot.showValues(); > saveAs("Results", output + filename); > close(); > } > > input = "C:/Users/Admin/Desktop/Input/"; > output = "C:/Users/Admin/Desktop/Output/"; > > setBatchMode(true); > list = getFileList(input); > for (i = 0; i < list.length; i++) > { > action(output, list[i]); > } > setBatchMode(false); > > > > -- > Sent from: http://imagej.1557.x6.nabble.com/ > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
That solution fixed the problem. The suggestion to append ".txt" is also
helpful to prevent the output from being generated as .tif files. -- Sent from: http://imagej.1557.x6.nabble.com/ -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by fieryice12
On Jun 7, 2019, at 9:03 AM, fieryice12 <[hidden email]> wrote:
> > I am writing a macro to batch process multiple files in a folder. When I run > this code, I'm getting the error message "No plot window in line 6". What is > causing this and how can it be fixed? This is a batch mode bug that is fixed in the latest daily build (1.52p45). You also need to change the statement that saves the table to saveAs("Results", output + filename + ".csv”); or you will not be able to open the table in ImageJ. -wayne > function action(output, filename) > { > open(input + filename); > makeRectangle(75, 47, 40, 42); > run("Plot Z-axis Profile", "profile=time"); > Plot.showValues(); > saveAs("Results", output + filename); > close(); > } > > input = "C:/Users/Admin/Desktop/Input/"; > output = "C:/Users/Admin/Desktop/Output/"; > > setBatchMode(true); > list = getFileList(input); > for (i = 0; i < list.length; i++) > { > action(output, list[i]); > } > setBatchMode(false); -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |