Headless CellProfiler 2.1.0 mac command line

I’m having difficulty invoking CellProfiler from the command line on Mac OS X 10.8.5. I’m working with the ExampleTumorImages data set, and I’ve slightly modified the supplied pipeline to use LoadImages. The pipeline works fine when invoked from the GUI, but when I try to invoke it from the command line

I get several errors (below).

What’s the proper way to invoke CP headless from the command line on Mac OS X?

Here are the errors:

[code]
/Applications/CellProfiler.app/Contents/MacOS/CellProfiler -p pwd/ModifiedTumorPipeline.cppipe -c -r
Version: 2014-01-24T14:51:22 0c7fb94 / 20140124145122
Plugin directory doesn’t point to valid folder: /Applications/CellProfiler.app/Contents/Resources/plugins
Times reported are CPU times for each module, not wall-clock time
2014-06-06 15:40:31.370 CellProfiler[81939:707] Apple AWT Java VM was loaded on first thread – can’t start AWT.
Exception in thread “Thread-2” java.lang.InternalError: Can’t start the AWT because Java was started on the first thread. Make sure StartOnFirstThread is not specified in your application’s Info.plist or on the command line
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1833)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1730)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1044)
at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.loadLibraries(Toolkit.java:1605)
at java.awt.Toolkit.(Toolkit.java:1627)
at sun.awt.AppContext$2.run(AppContext.java:240)
at sun.awt.AppContext$2.run(AppContext.java:226)
at java.security.AccessController.doPrivileged(Native Method)
at sun.awt.AppContext.initMainAppContext(AppContext.java:226)
at sun.awt.AppContext.access$200(AppContext.java:112)
at sun.awt.AppContext$3.run(AppContext.java:306)
at java.security.AccessController.doPrivileged(Native Method)
at sun.awt.AppContext.getAppContext(AppContext.java:287)
at javax.imageio.spi.IIORegistry.getDefaultInstance(IIORegistry.java:137)
at javax.imageio.ImageIO.(ImageIO.java:48)
at loci.formats.in.ImageIOReader.initFile(ImageIOReader.java:120)
at loci.formats.FormatReader.setId(FormatReader.java:1333)
at loci.formats.DelegateReader.setId(DelegateReader.java:267)
at loci.formats.in.JPEGReader.setId(JPEGReader.java:85)
Can’t start the AWT because Java was started on the first thread. Make sure StartOnFirstThread is not specified in your application’s Info.plist or on the command line
Traceback (most recent call last):
File “/Applications/CellProfiler.app/Contents/Resources/lib/python2.7/bioformats/formatreader.py”, line 584, in load_using_bioformats
File “/Applications/CellProfiler.app/Contents/Resources/lib/python2.7/bioformats/formatreader.py”, line 643, in __load_using_bioformats
File “/Applications/CellProfiler.app/Contents/Resources/lib/python2.7/bioformats/formatreader.py”, line 180, in setId
File “/Applications/CellProfiler.app/Contents/Resources/lib/python2.7/cellprofiler/utilities/jutil.py”, line 885, in call
File “/Applications/CellProfiler.app/Contents/Resources/lib/python2.7/cellprofiler/utilities/jutil.py”, line 862, in fn
JavaException: Can’t start the AWT because Java was started on the first thread. Make sure StartOnFirstThread is not specified in your application’s Info.plist or on the command line

Error detected during run of module LoadImages
Traceback (most recent call last):
File “/Applications/CellProfiler.app/Contents/Resources/lib/python2.7/cellprofiler/pipeline.py”, line 1796, in run_with_yield
File “/Applications/CellProfiler.app/Contents/Resources/lib/python2.7/cellprofiler/modules/loadimages.py”, line 2173, in run
File “/Applications/CellProfiler.app/Contents/Resources/lib/python2.7/cellprofiler/modules/loadimages.py”, line 3159, in provide_image
File “/Applications/CellProfiler.app/Contents/Resources/lib/python2.7/bioformats/formatreader.py”, line 609, in load_using_bioformats
IOError: [Errno 22] Could not load the file as an image (see log for details): '/Users/christop/Desktop/test/30-2A1b.jpg’
Fri Jun 6 15:40:30 2014: Image # 1, module LoadImages # 1: 0.71 sec
Failed to stop Ilastik
Exiting RunnableQueue.
Exiting the JVM monitor thread[/code]

Hi,

Try adding this prepend to your command: "arch -i386 "
as noted here:
github.com/CellProfiler/CellPro … mmand_line

Cheers,
David

Thanks. Unfortunately, adding arch -i386 doesn’t seem to help. Running:

results in:

[code]
Version: 2014-01-24T14:51:22 0c7fb94 / 20140124145122
Plugin directory doesn’t point to valid folder: /Applications/CellProfiler.app/Contents/Resources/plugins
/Applications/CellProfiler.app/Contents/Resources/lib/python2.7/site-packages.zip/MySQLdb/cursors.py:459: Warning: Unknown table 'Plate_12901_Per_Experiment’
Times reported are CPU times for each module, not wall-clock time
2014-06-11 11:45:06.404 CellProfiler[77255:f07] Apple AWT Java VM was loaded on first thread – can’t start AWT.
Exception in thread “Thread-2” java.lang.InternalError: Can’t start the AWT because Java was started on the first thread. Make sure StartOnFirstThread is not specified in your application’s Info.plist or on the command line
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1833)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1730)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1044)
at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.loadLibraries(Toolkit.java:1605)
at java.awt.Toolkit.(Toolkit.java:1627)
at sun.awt.AppContext$2.run(AppContext.java:240)
at sun.awt.AppContext$2.run(AppContext.java:226)
at java.security.AccessController.doPrivileged(Native Method)
at sun.awt.AppContext.initMainAppContext(AppContext.java:226)
at sun.awt.AppContext.access$200(AppContext.java:112)
at sun.awt.AppContext$3.run(AppContext.java:306)
at java.security.AccessController.doPrivileged(Native Method)
at sun.awt.AppContext.getAppContext(AppContext.java:287)
at javax.imageio.spi.IIORegistry.getDefaultInstance(IIORegistry.java:137)
at javax.imageio.ImageIO.(ImageIO.java:48)
at loci.formats.in.ImageIOReader.initFile(ImageIOReader.java:120)
at loci.formats.FormatReader.setId(FormatReader.java:1333)
at loci.formats.DelegateReader.setId(DelegateReader.java:267)
at loci.formats.in.JPEGReader.setId(JPEGReader.java:85)
Can’t start the AWT because Java was started on the first thread. Make sure StartOnFirstThread is not specified in your application’s Info.plist or on the command line
Traceback (most recent call last):
File “/Applications/CellProfiler.app/Contents/Resources/lib/python2.7/bioformats/formatreader.py”, line 584, in load_using_bioformats
File “/Applications/CellProfiler.app/Contents/Resources/lib/python2.7/bioformats/formatreader.py”, line 643, in __load_using_bioformats
File “/Applications/CellProfiler.app/Contents/Resources/lib/python2.7/bioformats/formatreader.py”, line 180, in setId
File “/Applications/CellProfiler.app/Contents/Resources/lib/python2.7/cellprofiler/utilities/jutil.py”, line 885, in call
File “/Applications/CellProfiler.app/Contents/Resources/lib/python2.7/cellprofiler/utilities/jutil.py”, line 862, in fn
JavaException: Can’t start the AWT because Java was started on the first thread. Make sure StartOnFirstThread is not specified in your application’s Info.plist or on the command line

Error detected during run of module LoadImages
Traceback (most recent call last):
File “/Applications/CellProfiler.app/Contents/Resources/lib/python2.7/cellprofiler/pipeline.py”, line 1796, in run_with_yield
File “/Applications/CellProfiler.app/Contents/Resources/lib/python2.7/cellprofiler/modules/loadimages.py”, line 2173, in run
File “/Applications/CellProfiler.app/Contents/Resources/lib/python2.7/cellprofiler/modules/loadimages.py”, line 3159, in provide_image
File “/Applications/CellProfiler.app/Contents/Resources/lib/python2.7/bioformats/formatreader.py”, line 609, in load_using_bioformats
IOError: [Errno 22] Could not load the file as an image (see log for details): '/Users/christop/Desktop/test/30-2A1b.jpg’
Wed Jun 11 11:45:05 2014: Image # 1, module LoadImages # 1: 0.68 sec
Failed to stop Ilastik
Exiting RunnableQueue.
Exiting the JVM monitor thread[/code]

This is with the 2.1.0 pkg from cellprofiler.org/download.shtml.

-Jon

This seems to be a similar issue to https://github.com/CellProfiler/CellProfiler/issues/1034, however the --use-awt fix suggested there isn’t recognized in the production 2.1.0 CellProfiler. Also, using the CELLPROFILER_USE_XVFB=1 environment variable doesn’t seem to work either.

Using export CELLPROFILER_USE_XVFB=1 also doesn’t resolve the issue. There is a comment in that thread to the effect that jpg images are more problematic to use headless than tif files. Perhaps that is the problem here.

In any case, is there a solution?

I think you’re on the right track with that Github issue. The problem appears to be a threading issue that is not handled well by the Mac.

I would first see if the final bugfix on the Github issue you linked to fixes your issue. We have a release candidate here labeled 2.1.1: cellprofiler.org/cgi-bin/trunk_build.cgi, so it’s pretty close to “production” (as close as we get :smile: ).

Side note: We recommend you steer away from JPG because they are a (nearly always) lossy format. TIFs tend to be large files, but PNGs are small if you can convert.

Thanks,
David