batch process returns nullpointerexception after finishing macro on first image

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
VC
Reply | Threaded
Open this post in threaded view
|

batch process returns nullpointerexception after finishing macro on first image

VC
Hi all,

I'm a newbie concerning imageJ/FIJI, especially when it comes to batch runs and computers in general (i work with mac). I've written following macro (see below) and it works fine when running it individually.

setBatchMode(false);
run("Stack to Images");
var s = getTitle();
rename(s + "dapi");
        run("Put Behind [tab]");
run("Close");
run("Close");

selectWindow(s + "dapi");
        setForegroundColor(0, 0, 0);
        setBackgroundColor(0, 0, 0);
                setThreshold(10, 255);
                run("Create Selection");
                run("Enlarge...", "enlarge=50 pixel");

        run("Add to Manager");
        roiManager("Select", 0);
                roiManager("Rename", "dapi auto");
roiManager("Deselect");
roiManager("Save", "/Users/violettecoppensimac/Documents/130218 VD Tet VEGF/ROI Tet Vegf/ROI " + s + " dapi auto.zip");
roiManager("Delete");

selectWindow(s + "dapi");
run("Close");


However, when running a batch process I encounter 2 problems:
1) when running in batchmode true, the command is executed on the wrong image. this i can work around by processing in false mode
2) when running in false mode, the macro finishes the first image, but then returns following exception:

Fiji/ImageJ 1.47n; Java 1.6.0_43 [64-bit]; Mac OS X 10.8.3; 1936MB of 3269MB (59%)
 
java.lang.reflect.InvocationTargetException
        at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at ij.Command.runPlugIn(Command.java:148)
        at ij.Command.runCommand(Command.java:97)
        at ij.Executer.run(Executer.java:64)
        at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.NullPointerException
        at ij.gui.ImageWindow.close(ImageWindow.java:349)
        at ij.gui.StackWindow.close(StackWindow.java:169)
        at ij.ImagePlus.close(ImagePlus.java:338)
        at ij.plugin.BatchProcesser.processFolder(BatchProcesser.java:195)
        at ij.plugin.BatchProcesser.run(BatchProcesser.java:91)
        at ij.IJ.runPlugIn(IJ.java:166)
        ... 7 more


Can somebody please explain in very simple terms (I'm a computer dummy ;) ) how this happens and how I can solve this?

many thanks!