Hello.
I want to use AnalyzeSkeleton in a JavaScript. But it produces java.lang.NullPointerException. What happens here? How can I avoid that? Thank you Sarah A code sniplet looks like that (cp. http://fiji.sc/AnalyzeSkeleton#Using_silent_mode_from_scripts): importPackage(Packages.ij); importPackage(Packages.ij.plugin); importPackage(Packages.ij.process ); importPackage(Packages.ij.measure ); importPackage(Packages.sc.fiji.analyzeSkeleton); importClass(Packages.ij.plugin.frame.RoiManager); imp = IJ.getImage(); IJ.run(imp, "Skeletonize (2D/3D)", ""); //ROIs roi_manager = RoiManager.getInstance(); roi_list = roi_manager.getRoisAsArray(); for (var roi = 0; roi < roi_list.length; roi++) { ip = imp.getProcessor(); imp.setRoi(roi_list[roi]); // set current ROI // Initialize AnalyzeSkeleton_ var skel = new AnalyzeSkeleton_(); // works w/o error message // each of the following produces error messages var skelResult = skel.run(AnalyzeSkeleton_.NONE, false, true, null, true, false); skel.calculateShortestPath = true; skel.setup("", imp); } Error messages: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at javax.swing.JComponent._paintImmediately(JComponent.java:5087) at javax.swing.JComponent.paintImmediately(JComponent.java:4882) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:785) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713) at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693) at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:642) at java.awt.EventQueue.access$000(EventQueue.java:85) at java.awt.EventQueue$1.run(EventQueue.java:603) at java.awt.EventQueue$1.run(EventQueue.java:601) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) at java.awt.EventQueue.dispatchEvent(EventQueue.java:612) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at javax.swing.JComponent._paintImmediately(JComponent.java:5087) at javax.swing.JComponent.paintImmediately(JComponent.java:4882) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:785) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713) at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693) at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:642) at java.awt.EventQueue.access$000(EventQueue.java:85) at java.awt.EventQueue$1.run(EventQueue.java:603) at java.awt.EventQueue$1.run(EventQueue.java:601) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) at java.awt.EventQueue.dispatchEvent(EventQueue.java:612) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at javax.swing.JComponent._paintImmediately(JComponent.java:5087) at javax.swing.JComponent.paintImmediately(JComponent.java:4882) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:785) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713) at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693) at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:642) at java.awt.EventQueue.access$000(EventQueue.java:85) at java.awt.EventQueue$1.run(EventQueue.java:603) at java.awt.EventQueue$1.run(EventQueue.java:601) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) at java.awt.EventQueue.dispatchEvent(EventQueue.java:612) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at javax.swing.JComponent._paintImmediately(JComponent.java:5087) at javax.swing.JComponent.paintImmediately(JComponent.java:4882) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:785) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713) at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693) at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:642) at java.awt.EventQueue.access$000(EventQueue.java:85) at java.awt.EventQueue$1.run(EventQueue.java:603) at java.awt.EventQueue$1.run(EventQueue.java:601) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) at java.awt.EventQueue.dispatchEvent(EventQueue.java:612) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at javax.swing.JComponent._paintImmediately(JComponent.java:5087) at javax.swing.JComponent.paintImmediately(JComponent.java:4882) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:785) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713) at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693) at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:642) at java.awt.EventQueue.access$000(EventQueue.java:85) at java.awt.EventQueue$1.run(EventQueue.java:603) at java.awt.EventQueue$1.run(EventQueue.java:601) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) at java.awt.EventQueue.dispatchEvent(EventQueue.java:612) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException Exception in thread "Run$_AWT-EventQueue-0" java.lang.NullPointerException Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException Exception in thread "Run$_AWT-EventQueue-0" java.lang.NullPointerException Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException Exception in thread "Run$_AWT-EventQueue-0" java.lang.NullPointerException Exception in thread "Run$_AWT-EventQueue-0" java.lang.NullPointerException Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException [WARNING] Ignoring unsupported output: result [java.lang.Integer] [WARNING] Ignoring unsupported output: result [java.lang.Integer] [WARNING] Ignoring unsupported output: result [java.lang.Integer] [WARNING] Ignoring unsupported output: result [java.lang.Double] [WARNING] Ignoring unsupported output: result [java.lang.Boolean] [WARNING] Ignoring unsupported output: result [java.lang.Boolean] [WARNING] Ignoring unsupported output: result [java.lang.Integer] Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException |
Hello Sarah,
In this line: var skelResult = skel.run(AnalyzeSkeleton_.NONE, false, true, null, true, false); You should replace the "null" parameter by the image (ImagePlus object) you want to analyze. Cheers! ignacio On Fri, Feb 12, 2016 at 7:35 PM, SarahBerlin <[hidden email]> wrote: > Hello. > > I want to use AnalyzeSkeleton in a JavaScript. But it produces > java.lang.NullPointerException. What happens here? How can I avoid that? > > Thank you > Sarah > > A code sniplet looks like that (cp. > http://fiji.sc/AnalyzeSkeleton#Using_silent_mode_from_scripts): > > importPackage(Packages.ij); > importPackage(Packages.ij.plugin); > importPackage(Packages.ij.process ); > importPackage(Packages.ij.measure ); > importPackage(Packages.sc.fiji.analyzeSkeleton); > importClass(Packages.ij.plugin.frame.RoiManager); > > imp = IJ.getImage(); > IJ.run(imp, "Skeletonize (2D/3D)", ""); > > //ROIs > roi_manager = RoiManager.getInstance(); > roi_list = roi_manager.getRoisAsArray(); > for (var roi = 0; roi < roi_list.length; roi++) { > ip = imp.getProcessor(); > imp.setRoi(roi_list[roi]); // set current ROI > > // Initialize AnalyzeSkeleton_ > var skel = new AnalyzeSkeleton_(); // works w/o error message > > // each of the following produces error messages > var skelResult = skel.run(AnalyzeSkeleton_.NONE, false, true, null, > true, false); > skel.calculateShortestPath = true; > skel.setup("", imp); > } > > Error messages: > > Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException > at javax.swing.JComponent._paintImmediately(JComponent.java:5087) > at javax.swing.JComponent.paintImmediately(JComponent.java:4882) > at > javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:785) > at > javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713) > at > javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693) > at > > javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125) > at > java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) > at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:642) > at java.awt.EventQueue.access$000(EventQueue.java:85) > at java.awt.EventQueue$1.run(EventQueue.java:603) > at java.awt.EventQueue$1.run(EventQueue.java:601) > at java.security.AccessController.doPrivileged(Native Method) > at > > java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) > at java.awt.EventQueue.dispatchEvent(EventQueue.java:612) > at > > java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) > at > > java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) > at > > java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) > at > java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) > at > java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) > at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) > Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException > at javax.swing.JComponent._paintImmediately(JComponent.java:5087) > at javax.swing.JComponent.paintImmediately(JComponent.java:4882) > at > javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:785) > at > javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713) > at > javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693) > at > > javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125) > at > java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) > at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:642) > at java.awt.EventQueue.access$000(EventQueue.java:85) > at java.awt.EventQueue$1.run(EventQueue.java:603) > at java.awt.EventQueue$1.run(EventQueue.java:601) > at java.security.AccessController.doPrivileged(Native Method) > at > > java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) > at java.awt.EventQueue.dispatchEvent(EventQueue.java:612) > at > > java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) > at > > java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) > at > > java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) > at > java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) > at > java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) > at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) > Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException > at javax.swing.JComponent._paintImmediately(JComponent.java:5087) > at javax.swing.JComponent.paintImmediately(JComponent.java:4882) > at > javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:785) > at > javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713) > at > javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693) > at > > javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125) > at > java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) > at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:642) > at java.awt.EventQueue.access$000(EventQueue.java:85) > at java.awt.EventQueue$1.run(EventQueue.java:603) > at java.awt.EventQueue$1.run(EventQueue.java:601) > at java.security.AccessController.doPrivileged(Native Method) > at > > java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) > at java.awt.EventQueue.dispatchEvent(EventQueue.java:612) > at > > java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) > at > > java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) > at > > java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) > at > java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) > at > java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) > at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) > Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException > at javax.swing.JComponent._paintImmediately(JComponent.java:5087) > at javax.swing.JComponent.paintImmediately(JComponent.java:4882) > at > javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:785) > at > javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713) > at > javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693) > at > > javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125) > at > java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) > at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:642) > at java.awt.EventQueue.access$000(EventQueue.java:85) > at java.awt.EventQueue$1.run(EventQueue.java:603) > at java.awt.EventQueue$1.run(EventQueue.java:601) > at java.security.AccessController.doPrivileged(Native Method) > at > > java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) > at java.awt.EventQueue.dispatchEvent(EventQueue.java:612) > at > > java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) > at > > java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) > at > > java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) > at > java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) > at > java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) > at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) > Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException > at javax.swing.JComponent._paintImmediately(JComponent.java:5087) > at javax.swing.JComponent.paintImmediately(JComponent.java:4882) > at > javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:785) > at > javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713) > at > javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693) > at > > javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125) > at > java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) > at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:642) > at java.awt.EventQueue.access$000(EventQueue.java:85) > at java.awt.EventQueue$1.run(EventQueue.java:603) > at java.awt.EventQueue$1.run(EventQueue.java:601) > at java.security.AccessController.doPrivileged(Native Method) > at > > java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) > at java.awt.EventQueue.dispatchEvent(EventQueue.java:612) > at > > java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) > at > > java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) > at > > java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) > at > java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) > at > java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) > at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) > Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException > Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException > Exception in thread "Run$_AWT-EventQueue-0" java.lang.NullPointerException > Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException > Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException > Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException > Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException > Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException > Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException > Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException > Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException > Exception in thread "Run$_AWT-EventQueue-0" java.lang.NullPointerException > Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException > Exception in thread "Run$_AWT-EventQueue-0" java.lang.NullPointerException > Exception in thread "Run$_AWT-EventQueue-0" java.lang.NullPointerException > Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException > [WARNING] Ignoring unsupported output: result [java.lang.Integer] > [WARNING] Ignoring unsupported output: result [java.lang.Integer] > [WARNING] Ignoring unsupported output: result [java.lang.Integer] > [WARNING] Ignoring unsupported output: result [java.lang.Double] > [WARNING] Ignoring unsupported output: result [java.lang.Boolean] > [WARNING] Ignoring unsupported output: result [java.lang.Boolean] > [WARNING] Ignoring unsupported output: result [java.lang.Integer] > Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException > Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException > > > > > -- > View this message in context: > http://imagej.1557.x6.nabble.com/AnalyzeSkeleton-in-JavaScript-Exception-in-thread-AWT-EventQueue-0-java-lang-NullPointerException-tp5015617.html > Sent from the ImageJ mailing list archive at Nabble.com. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- Ignacio Arganda-Carreras, Ph.D. Ikerbasque Research Fellow Departamento de Ciencias de la Computacion e Inteligencia Artificial Facultad de Informatica, Universidad del Pais Vasco Paseo de Manuel Lardizabal, 1 20018 Donostia-San Sebastian Guipuzcoa, Spain Phone : +34 943 01 73 25 Website: http://sites.google.com/site/iargandacarreras/ <http://biocomp.cnb.csic.es/~iarganda/index_EN.html> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Sorry, Sarah. I was wrong on my remark. As nicely pointed out by Richard
Domander, the fourth parameter of that run method is not input skeleton image but the original grayscale image (for lowest pixel intensity pruning mode). So setting to null is fine. What you need to do is to call setup with the input image before calling run, or the plugin will crash with a NullPointerException. Best, ignacio On Sun, Feb 14, 2016 at 9:35 PM, Ignacio Arganda-Carreras < [hidden email]> wrote: > Hello Sarah, > > In this line: > > var skelResult = skel.run(AnalyzeSkeleton_.NONE, false, true, null, true, > false); > > You should replace the "null" parameter by the image (ImagePlus object) > you want to analyze. > > Cheers! > > ignacio > > On Fri, Feb 12, 2016 at 7:35 PM, SarahBerlin <[hidden email]> wrote: > >> Hello. >> >> I want to use AnalyzeSkeleton in a JavaScript. But it produces >> java.lang.NullPointerException. What happens here? How can I avoid that? >> >> Thank you >> Sarah >> >> A code sniplet looks like that (cp. >> http://fiji.sc/AnalyzeSkeleton#Using_silent_mode_from_scripts): >> >> importPackage(Packages.ij); >> importPackage(Packages.ij.plugin); >> importPackage(Packages.ij.process ); >> importPackage(Packages.ij.measure ); >> importPackage(Packages.sc.fiji.analyzeSkeleton); >> importClass(Packages.ij.plugin.frame.RoiManager); >> >> imp = IJ.getImage(); >> IJ.run(imp, "Skeletonize (2D/3D)", ""); >> >> //ROIs >> roi_manager = RoiManager.getInstance(); >> roi_list = roi_manager.getRoisAsArray(); >> for (var roi = 0; roi < roi_list.length; roi++) { >> ip = imp.getProcessor(); >> imp.setRoi(roi_list[roi]); // set current ROI >> >> // Initialize AnalyzeSkeleton_ >> var skel = new AnalyzeSkeleton_(); // works w/o error message >> >> // each of the following produces error messages >> var skelResult = skel.run(AnalyzeSkeleton_.NONE, false, true, >> null, >> true, false); >> skel.calculateShortestPath = true; >> skel.setup("", imp); >> } >> >> Error messages: >> >> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException >> at javax.swing.JComponent._paintImmediately(JComponent.java:5087) >> at javax.swing.JComponent.paintImmediately(JComponent.java:4882) >> at >> javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:785) >> at >> javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713) >> at >> javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693) >> at >> >> javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125) >> at >> java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) >> at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:642) >> at java.awt.EventQueue.access$000(EventQueue.java:85) >> at java.awt.EventQueue$1.run(EventQueue.java:603) >> at java.awt.EventQueue$1.run(EventQueue.java:601) >> at java.security.AccessController.doPrivileged(Native Method) >> at >> >> java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) >> at java.awt.EventQueue.dispatchEvent(EventQueue.java:612) >> at >> >> java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) >> at >> >> java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) >> at >> >> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) >> at >> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) >> at >> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) >> at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) >> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException >> at javax.swing.JComponent._paintImmediately(JComponent.java:5087) >> at javax.swing.JComponent.paintImmediately(JComponent.java:4882) >> at >> javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:785) >> at >> javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713) >> at >> javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693) >> at >> >> javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125) >> at >> java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) >> at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:642) >> at java.awt.EventQueue.access$000(EventQueue.java:85) >> at java.awt.EventQueue$1.run(EventQueue.java:603) >> at java.awt.EventQueue$1.run(EventQueue.java:601) >> at java.security.AccessController.doPrivileged(Native Method) >> at >> >> java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) >> at java.awt.EventQueue.dispatchEvent(EventQueue.java:612) >> at >> >> java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) >> at >> >> java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) >> at >> >> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) >> at >> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) >> at >> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) >> at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) >> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException >> at javax.swing.JComponent._paintImmediately(JComponent.java:5087) >> at javax.swing.JComponent.paintImmediately(JComponent.java:4882) >> at >> javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:785) >> at >> javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713) >> at >> javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693) >> at >> >> javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125) >> at >> java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) >> at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:642) >> at java.awt.EventQueue.access$000(EventQueue.java:85) >> at java.awt.EventQueue$1.run(EventQueue.java:603) >> at java.awt.EventQueue$1.run(EventQueue.java:601) >> at java.security.AccessController.doPrivileged(Native Method) >> at >> >> java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) >> at java.awt.EventQueue.dispatchEvent(EventQueue.java:612) >> at >> >> java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) >> at >> >> java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) >> at >> >> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) >> at >> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) >> at >> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) >> at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) >> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException >> at javax.swing.JComponent._paintImmediately(JComponent.java:5087) >> at javax.swing.JComponent.paintImmediately(JComponent.java:4882) >> at >> javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:785) >> at >> javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713) >> at >> javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693) >> at >> >> javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125) >> at >> java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) >> at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:642) >> at java.awt.EventQueue.access$000(EventQueue.java:85) >> at java.awt.EventQueue$1.run(EventQueue.java:603) >> at java.awt.EventQueue$1.run(EventQueue.java:601) >> at java.security.AccessController.doPrivileged(Native Method) >> at >> >> java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) >> at java.awt.EventQueue.dispatchEvent(EventQueue.java:612) >> at >> >> java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) >> at >> >> java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) >> at >> >> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) >> at >> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) >> at >> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) >> at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) >> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException >> at javax.swing.JComponent._paintImmediately(JComponent.java:5087) >> at javax.swing.JComponent.paintImmediately(JComponent.java:4882) >> at >> javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:785) >> at >> javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713) >> at >> javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693) >> at >> >> javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125) >> at >> java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) >> at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:642) >> at java.awt.EventQueue.access$000(EventQueue.java:85) >> at java.awt.EventQueue$1.run(EventQueue.java:603) >> at java.awt.EventQueue$1.run(EventQueue.java:601) >> at java.security.AccessController.doPrivileged(Native Method) >> at >> >> java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) >> at java.awt.EventQueue.dispatchEvent(EventQueue.java:612) >> at >> >> java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) >> at >> >> java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) >> at >> >> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) >> at >> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) >> at >> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) >> at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) >> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException >> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException >> Exception in thread "Run$_AWT-EventQueue-0" java.lang.NullPointerException >> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException >> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException >> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException >> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException >> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException >> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException >> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException >> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException >> Exception in thread "Run$_AWT-EventQueue-0" java.lang.NullPointerException >> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException >> Exception in thread "Run$_AWT-EventQueue-0" java.lang.NullPointerException >> Exception in thread "Run$_AWT-EventQueue-0" java.lang.NullPointerException >> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException >> [WARNING] Ignoring unsupported output: result [java.lang.Integer] >> [WARNING] Ignoring unsupported output: result [java.lang.Integer] >> [WARNING] Ignoring unsupported output: result [java.lang.Integer] >> [WARNING] Ignoring unsupported output: result [java.lang.Double] >> [WARNING] Ignoring unsupported output: result [java.lang.Boolean] >> [WARNING] Ignoring unsupported output: result [java.lang.Boolean] >> [WARNING] Ignoring unsupported output: result [java.lang.Integer] >> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException >> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException >> >> >> >> >> -- >> View this message in context: >> http://imagej.1557.x6.nabble.com/AnalyzeSkeleton-in-JavaScript-Exception-in-thread-AWT-EventQueue-0-java-lang-NullPointerException-tp5015617.html >> Sent from the ImageJ mailing list archive at Nabble.com. >> >> -- >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html >> > > > > -- > Ignacio Arganda-Carreras, Ph.D. > Ikerbasque Research Fellow > Departamento de Ciencias de la Computacion e Inteligencia Artificial > Facultad de Informatica, Universidad del Pais Vasco > Paseo de Manuel Lardizabal, 1 > 20018 Donostia-San Sebastian > Guipuzcoa, Spain > > Phone : +34 943 01 73 25 > Website: http://sites.google.com/site/iargandacarreras/ > <http://biocomp.cnb.csic.es/~iarganda/index_EN.html> > -- Ignacio Arganda-Carreras, Ph.D. Ikerbasque Research Fellow Departamento de Ciencias de la Computacion e Inteligencia Artificial Facultad de Informatica, Universidad del Pais Vasco Paseo de Manuel Lardizabal, 1 20018 Donostia-San Sebastian Guipuzcoa, Spain Phone : +34 943 01 73 25 Website: http://sites.google.com/site/iargandacarreras/ <http://biocomp.cnb.csic.es/~iarganda/index_EN.html> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Ignacio.
As you told me works. But unfortunately it does not fufill my needs. My ultimate goal is to read out the AnalyzeSkeleton results from each ROI seperately. When I initialize AnalyzeSkeleton with the whole image it gives only results for the whole image. So I now treat every ROI within a loop: first I duplicate the ROI into another imp and then I start AnalyzeSkeleton. But unfortunately again I recieve a nullPointer exception. Is there a work-around for that? Thank you in advance. Sarah code-snippet: importPackage(Packages.ij); importPackage(Packages.ij.plugin); importPackage(Packages.sc.fiji.analyzeSkeleton); importClass(Packages.ij.plugin.frame.RoiManager); var imp1 = IJ.getImage(); var roi_manager = RoiManager.getInstance(); var roi_list = roi_manager.getRoisAsArray(); for (var roi = 0; roi < 1; roi++) { // get current (open) image imp1 = IJ.getImage(); // set ROI with index roi imp1.setRoi(roi_list[roi]); // duplicate ROI = Image_Plus (image to work on) IJ.run("Duplicate...", "name"); imp = IJ.getImage(); // Initialize AnalyzeSkeleton_ with grayscale image var skel = new AnalyzeSkeleton_(); // works fine skel.calculateShortestPath = true; // causes nullPointer exception skel.setup("", imp); // causes nullPointer exception imp.changes = false; imp.close() }
|
Hello again Sara,
I made a small BeanShell script based on yours and it works for me: import sc.fiji.analyzeSkeleton.AnalyzeSkeleton_; import ij.plugin.frame.RoiManager; import ij.IJ; imp1 = IJ.getImage(); roi_manager = RoiManager.getInstance(); roi_list = roi_manager.getRoisAsArray(); for (roi = 0; roi < 1; roi++) { // get current (open) image imp1 = IJ.getImage(); // set ROI with index roi imp1.setRoi(roi_list[roi]); // duplicate ROI = Image_Plus (image to work on) imp = imp1.duplicate(); // Initialize AnalyzeSkeleton_ with grayscale image var skel = new AnalyzeSkeleton_(); skel.calculateShortestPath = true; skel.setup("", imp); results = skel.run(AnalyzeSkeleton_.NONE, false, true, null, true, false); IJ.log( "Number of skeletons of roi " + roi + " = " + results.getNumOfTrees() ); imp.changes = false; imp.close(); } Can you check it you on your side? On Mon, Feb 15, 2016 at 4:53 PM, SarahBerlin <[hidden email]> wrote: > Hi Ignacio. > > As you told me works. But unfortunately it does not fufill my needs. My > ultimate goal is to read out the AnalyzeSkeleton results from each ROI > seperately. When I initialize AnalyzeSkeleton with the whole image it > gives > only results for the whole image. > So I now treat every ROI within a loop: first I duplicate the ROI into > another imp and then I start AnalyzeSkeleton. But unfortunately again I > recieve a nullPointer exception. > > Is there a work-around for that? > Thank you in advance. > Sarah > > code-snippet: > > importPackage(Packages.ij); > importPackage(Packages.ij.plugin); > importPackage(Packages.sc.fiji.analyzeSkeleton); > importClass(Packages.ij.plugin.frame.RoiManager); > > var imp1 = IJ.getImage(); > var roi_manager = RoiManager.getInstance(); > var roi_list = roi_manager.getRoisAsArray(); > > for (var roi = 0; roi < 1; roi++) { > // get current (open) image > imp1 = IJ.getImage(); > // set ROI with index roi > imp1.setRoi(roi_list[roi]); > > // duplicate ROI = Image_Plus (image to work on) > IJ.run("Duplicate...", "name"); > imp = IJ.getImage(); > > // Initialize AnalyzeSkeleton_ with grayscale image > var skel = new AnalyzeSkeleton_(); // works fine > skel.calculateShortestPath = true; // causes nullPointer > exception > skel.setup("", imp); // causes nullPointer > exception > > > imp.changes = false; > imp.close() > > } > > > Ignacio Arganda-Carreras-2 wrote > > Sorry, Sarah. I was wrong on my remark. As nicely pointed out by Richard > > Domander, the fourth parameter of that run method is not input skeleton > > image but the original grayscale image (for lowest pixel intensity > pruning > > mode). So setting to null is fine. What you need to do is to call setup > > with the input image before calling run, or the plugin will crash with a > > NullPointerException. > > > > Best, > > > > ignacio > > > > > > -- > View this message in context: > http://imagej.1557.x6.nabble.com/AnalyzeSkeleton-in-JavaScript-Exception-in-thread-AWT-EventQueue-0-java-lang-NullPointerException-tp5015617p5015637.html > Sent from the ImageJ mailing list archive at Nabble.com. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- Ignacio Arganda-Carreras, Ph.D. Ikerbasque Research Fellow Departamento de Ciencias de la Computacion e Inteligencia Artificial Facultad de Informatica, Universidad del Pais Vasco Paseo de Manuel Lardizabal, 1 20018 Donostia-San Sebastian Guipuzcoa, Spain Phone : +34 943 01 73 25 Website: http://sites.google.com/site/iargandacarreras/ <http://biocomp.cnb.csic.es/~iarganda/index_EN.html> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hello Ignacio.
> Can you check it you on your side? It works and spits out some meaningful numbers. Thank you very much. :) Sarah ps. As far as I see you mainly changed the following step: > // duplicate ROI = Image_Plus (image to work on) > imp = imp1.duplicate(); Any clue why it works with the method duplicate but not with the class Duplicator? |
Hello Sarah,
I'm glad it worked! On your script, you use the duplicate command from the GUI: IJ.run("Duplicate...", "name"); And then catch the image with the focus on: imp = IJ.getImage(); That's always risky because it depends on the focus of the GUI. Does it make sense? ignacio On Mon, Feb 15, 2016 at 6:16 PM, SarahBerlin <[hidden email]> wrote: > Hello Ignacio. > > > Can you check it you on your side? > > It works and spits out some meaningful numbers. Thank you very much. :) > > Sarah > > ps. > As far as I see you mainly changed the following step: > > > // duplicate ROI = Image_Plus (image to work on) > > imp = imp1.duplicate(); > > Any clue why it works with the method duplicate but not with the class > Duplicator? > > > > > > > -- > View this message in context: > http://imagej.1557.x6.nabble.com/AnalyzeSkeleton-in-JavaScript-Exception-in-thread-AWT-EventQueue-0-java-lang-NullPointerException-tp5015617p5015640.html > Sent from the ImageJ mailing list archive at Nabble.com. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- Ignacio Arganda-Carreras, Ph.D. Ikerbasque Research Fellow Departamento de Ciencias de la Computacion e Inteligencia Artificial Facultad de Informatica, Universidad del Pais Vasco Paseo de Manuel Lardizabal, 1 20018 Donostia-San Sebastian Guipuzcoa, Spain Phone : +34 943 01 73 25 Website: http://sites.google.com/site/iargandacarreras/ <http://biocomp.cnb.csic.es/~iarganda/index_EN.html> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hello Ignacio.
> Does it make sense? Yes, it does. Thank you very much for your help. Sarah |
Free forum by Nabble | Edit this page |