NOTICE! This is a static HTML version of a legacy Fiji BugZilla bug.

The Fiji project now uses GitHub Issues for issue tracking.

Please file all new issues there.

Bug 369 - headless: duplication of an image fails
headless: duplication of an image fails
Status: RESOLVED FIXED
Product: Fiji
Classification: Unclassified
Component: Plugins
unspecified
Macintosh Mac OS
: P4 normal
Assigned To: ImageJ Bugs Mailing List
Depends on:
Blocks:
 
Reported: 2011-10-12 19:33 CDT by aRnim Jenett
Modified: 2011-10-19 20:09 CDT
1 user (show)

See Also:

Description aRnim Jenett 2011-10-12 19:33:08 CDT
Hi,
I need to run a macro headless on our cluster which iterates many times over the 
same image stack. Because the image gets destroyed in that macro 
(by splitChannels) I keep the original image open and generate working copies 
via the Duplicate command. This works nicely when I run fiji in  normal, 
interactive (GUI) mode and in batch mode, but it fails when run headless.
How can I fix this?

in the test suite I put together I call fiji three times with the same task:
the first call is headless
the second call runs in batch mode 
the third call is in normal GUI mode
the different sections are marked as "headless", "batch" and "GUI" in the 
standard output below.

btw, this behavior is not Mac-specific. I get the same results (with slightly 
different line numbers) on a Linux node which I run in X-redirect 
(nxclient to our cluster). when run on the cluster without GUI (ssh) I get the 
same error in the batch-run as in the headless-run. the Gui-run of course 
complains about a missing GUI, which is fine.

The raw reader is not the problem either. I tested this also with tifs, leading to the 
same behavior/error messages.

Please help, thanks, 
aRnim

--------------- the call ---------------
jenetta$ sh callFijiWithImageAndMacro2.sh /Volumes/secondaryHD/secondary-cache/GMR_9E11_AE_01_10-fA01b_C111005_20111005101713843.reg.local.raw  /Volumes/rubinlab/aRnim/scripts/ij/macros/cluster/testDuplication.ijm 0

--------------- the shell wrapper: callFijiWithImageAndMacro2.sh ---------------
#!/bin/bash
# display start date of process
	date
# this script is a subversion of callFijiWithImageAndMacro designed to work with 
# raw files. due to its proprietary nature this file format is not recognized
# correctly by imageJ/fiji but a custom-made reader has to be called from inside
# the macro called by this script!!!
# macros called with this script can not expect to encounter an open image but 
# need to call the raw-reader first to open the image which is passed as 
# macro parameter. to recieve the parameter from within the macro called by this
# script use the macro function getArgument().
# due to this fact no parameters can be passed to the macro anymore.

# $1 = full (platform dependent) path to image 	
# $2 = full (platform dependent) path to macro	

# extract basename from image name in $1 
# "basename" gave strange results in test, therefore this was constructed from scratch.
	fn=$(echo $1 |awk -F "/" '{print $NF}')
	bn=$(echo $fn |awk -F "." '{print $1}')

# define local directory to store image files temporarily.	
	user=$(whoami)
# define OS-specific parameters.	
	case $(uname) in
		Linux)
			img=/tmp/$fn
			baseString=/groups/rubin/home/rubinlab/
			fiji=/groups/rubin/home/jenetta/Desktop/fiji/fiji/Fiji.app/fiji-linux64
			;;
		Darwin)
			img=/scratch/$user/$fn
			baseString=/Volumes/rubinlab/
			fiji=/Volumes/secondaryHD/localfiji/fiji${3}/Fiji.app/Contents/MacOS/fiji-macosx
			;;
		*)
			printf "ERROR: did not recognize platform.\n"
			;;
	esac
# tests showed, that fiji loads from a local drive significantly faster, 
# than over the network. This is why this script copies the image files 
# it works with to a temporary directory and opens them from there. When 
# done the script removes the current image from the local drive.
# make image local
	if [ ! -e $img ]; then
		cp -v $1 $img
	fi
		
# call fiji headlessly with Image and macro
# --headless	prevents fiji from rendering any GUI element: no main window, no dialogs, no error messages
#		--> http://fiji.sc/wiki/index.php/Scripting_Help
# 		disadvantage: if a macro produces dialogs ( maybe left-overs from development) fiji gonna crash, throwing an error message.
# -eval 'run("Refresh JRuby Scripts","");' 	I am not sure why, but this piece is really needed, without the call dies 
# -Dplugins.dir=${baseString}aRnim/scripts/ij/ 	this defines the plugins directory
#		by that location also the macro's dir is defined: macrosdir=$pluginsdir/../macros
# $img		an image passed to imagej/fiji as a first parameter is automatically opened
# -macro $2	this is a macro-call generic to fiji (I think imagej is handeling this the same way).
# -batch	Runs a macro or script in batch (no GUI) mode, passing it an optional argument.
#		ImageJ exits when the macro finishes.
#		--> http://rsbweb.nih.gov/ij/docs/install/linux.html#options
	
	if [ -d $baseString ]; then 
printf "=================\nheadless\n"
		$fiji  --headless  -eval 'run("Refresh JRuby Scripts","");' -Dplugins.dir=${baseString}aRnim/scripts/ij/  -macro $2 "$img" -batch;
printf "=================\nbatch\n"
		$fiji  -eval 'run("Refresh JRuby Scripts","");' -Dplugins.dir=${baseString}aRnim/scripts/ij/ -macro $2 "$img" -batch;
printf "=================\nGUI\n"
		$fiji  -eval 'run("Refresh JRuby Scripts","");' -Dplugins.dir=${baseString}aRnim/scripts/ij/ -macro $2 $img;
	else 
		printf "ERROR: $baseString is not mounted.\n\n"
	fi	
# remove local copy of the image	
	rm $img
# display date when process finished.
	date
	
--------------- the macro: testDuplication.ijm ---------------

	IID = "";
	image=getArgument();
	OPEN_FILE(image);
	orgID=getImageID();
	title=getTitle();
	fn=split(title, "/");
	fn=fn[lengthOf(fn)-1];

	if(isOpen(IID) == 0) {
		Stack.getDimensions(width, height, channels, slices, frames);
print("tick", nImages());
		run("Duplicate...", "title="+fn+" duplicate channels=1-"+channels+" slices=1-"+slices);
print("tack", nImages());
		IID=getImageID();
	}

function OPEN_FILE(fileName) {
print("open", fileName);
	if (endsWith(fileName, "lsm")) {
print("lsm recognized. Using bio-formats.");
//		run("Bio-Formats", "open="+fileName+" color_mode=Default view=Hyperstack stack_order=XYCZT");
		run("LSM...", "open="+fileName);
	} else if (endsWith(fileName, "v3draw") || endsWith(fileName, "raw")) {
print("raw recognized.Using raw reader.");
		run("raw reader", "open="+fileName);
		fn=split(fileName, "/");
		fn=fn[lengthOf(fn)-1];
		rename(fn);
	} else {
print("no special file format recognized. using standard opening mechanism.");
		open(fileName);
	}
	fn=split(fileName, "/");
	fn=fn[lengthOf(fn)-1];
	bn=split(fn, ".");
	bn=bn[0];
	if(endsWith(getTitle(), fn) == 0) {
		rename(fn);
	}
}

--------------- the standard out ---------------

=================
headless
open /scratch/jenetta/GMR_9E11_AE_01_10-fA01b_C111005_20111005101713843.reg.local.raw
raw recognized.Using raw reader.
tick 1
java.lang.ClassCastException: java.lang.String cannot be cast to java.awt.TextField
	at ij.plugin.Duplicator.showHSDialog(Duplicator.java:306)
	at ij.plugin.Duplicator.duplicateHyperstack(Duplicator.java:247)
	at ij.plugin.Duplicator.run(Duplicator.java:37)
	at ij.IJ.runPlugInUnchecked(IJ.java:175)
	at ij.IJ.runPlugIn(IJ.java:157)
	at ij.Executer.runCommand(Executer.java:150)
	at ij.Executer.run(Executer.java:81)
	at ij.IJ.run(IJ.java:269)
	at ij.macro.Functions.doRun(Functions.java:569)
	at ij.macro.Functions.doFunction(Functions.java:80)
	at ij.macro.Interpreter.doStatement(Interpreter.java:203)
	at ij.macro.Interpreter.doBlock(Interpreter.java:518)
	at ij.macro.Interpreter.doStatement(Interpreter.java:239)
	at ij.macro.Interpreter.doIf(Interpreter.java:852)
	at ij.macro.Interpreter.doStatement(Interpreter.java:215)
	at ij.macro.Interpreter.doStatements(Interpreter.java:191)
	at ij.macro.Interpreter.run(Interpreter.java:102)
	at ij.macro.Interpreter.run(Interpreter.java:72)
	at ij.macro.Interpreter.run(Interpreter.java:83)
	at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:102)
	at ij.plugin.Macro_Runner.runMacroFile(Macro_Runner.java:87)
	at ij.IJ.runMacroFile(IJ.java:121)
	at ij.ImageJ.main(ImageJ.java:647)
	at fiji.Main.main(Main.java:363)

=================
batch
open /scratch/jenetta/GMR_9E11_AE_01_10-fA01b_C111005_20111005101713843.reg.local.raw
raw recognized.Using raw reader.
tick 1
tack 2
=================
GUI
(this runs as expected. tick and tack can be found in the Log window.)

[end of sermon]

Information about your version of Java - this information is useful for the Fiji developers:

  os.arch => x86_64
  os.name => Mac OS X
  os.version => 10.6.8
  java.version => 1.6.0_26
  java.vendor => Apple Inc.
  java.runtime.name => Java(TM) SE Runtime Environment
  java.runtime.version => 1.6.0_26-b03-384-10M3425
  java.vm.name => Java HotSpot(TM) 64-Bit Server VM
  java.vm.version => 20.1-b02-384
  java.vm.vendor => Apple Inc.
  java.vm.info => mixed mode
  java.awt.graphicsenv => apple.awt.CGraphicsEnvironment
  java.specification.name => Java Platform API Specification
  java.specification.version => 1.6
  sun.cpu.endian => little
  sun.desktop => null
  file.separator => /

The up-to-date check says: You wanted never to be reminded.

Information relevant to JAVA_HOME related problems:

  JAVA_HOME is set to: null
  fiji.dir => /Volumes/secondaryHD/localfiji/fiji9/Fiji.app

Information about the version of each plugin:

  7d4fe4018e4eec8eef8d52d0a335ef9a5e076f94 20110307092649 fiji-macosx
  0daf9183a73311e50bf0152443cb662d3f74885a 20110307092649 fiji-tiger
  ca9bc7b44bf9b2b7b91f4aecabf1296634337e99 20110307090953 jars/Fiji.jar
  31fc72943db1de218eb827e7ea3becc16d76d851 20110307090953 jars/Jama-1.0.2.jar
  83496926787f5d4215cd6a4c54e816014b413f34 20110307091000 jars/VIB-lib.jar
  bd57338068f48b9ce4c5275544633ba172b0902a 20110307090955 jars/VectorString.jar
  68a9e41d2a7cec1ffedd5e38f4c064927b43b3c7 20110303144100 jars/ant-junit.jar
  4199e18036ba2020bdcbc733f603564f41cf9009 20110303144100 jars/ant-launcher.jar
  92b2335d3a97549b633dbcc3c41381a90f2b924b 20110303144100 jars/ant-nodeps.jar
  b1492f77c5c13e4f9dc05fe0ba9f95d6ec826660 20110303144100 jars/ant.jar
  5bab776822719667a604b8fb2eafc679161aeb0f 20110307090954 jars/autocomplete.jar
  dbab80ab5e11fb33328c7da88a849d0a19793ff5 20110307091004 jars/batik.jar
  d21bc3c19ebc5b3924caff5f859e6c50071590c9 20110303144100 jars/bsh-2.0b4.jar
  efd0b4a7eaf55c0716fde3243ac45cb49fdd2606 20110303144100 jars/clibwrapper_jiio.jar
  21c2d3f654c1c599751df995a1b183d02301c76d 20110307090954 jars/clojure.jar
  d760adf70f63d2f07fe00dc5f36b9bc32f11fc97 20110307091005 jars/commons-math.jar
  368901ce572a723c0ae0e68f0563b2712a69fd5d 20110307092642 jars/edu_mines_jtk.jar
  25d48038eae645618fd16923085ad2f2e804dd81 20110307090941 jars/fake.jar
  b5b1a692bbf0bac82c904dbbfeba3040144be964 20110307090953 jars/fiji-lib.jar
  37922f54ac020847467a9ace9bdf8cfa5c3b6db8 20110307090954 jars/fiji-scripting.jar
  561f139e28c58f72a4cd969b1c52a26cf6aa8362 20110307090952 jars/ij.jar
  04530e150af0702f6f963104facda5eaa6e866ae 20110307091008 jars/imagescience.jar
  780fae4087869e6c485796fd6df1e399e64fc44e 20110307091012 jars/imageware.jar
  85af6645584bd2339848a2a9c95db234ba0a68ea 20110307092642 jars/imglib-algorithms.jar
  2727a642fb63f329acd33f4b48bcc20e926c5f40 20110307090953 jars/imglib-ij.jar
  3913aeadf2f94efc7f9bc1a732a7e4cef2714e99 20110307091007 jars/imglib-io.jar
  4053be284a4fd91bfddc9e512ddc6366b2dc6f11 20110307092642 jars/imglib-scripting.jar
  785fd9ee2450a11697d7b60d88165f395639562f 20110307090953 jars/imglib.jar
  a88a4b46ddcdcf0312b0fe03b1900412bdb71873 20110303144100 jars/itext-1.3.jar
  1d98f5251cb21553b4907228cd281e6b84d3a216 20110307090955 jars/jacl.jar
  253316728c4012a86fae361e7b7fcb0fab0f5c38 20110307092642 jars/jai_codec.jar
  2a328b6b63ebec85d369427875739304dc1cf2cb 20110307092642 jars/jai_core.jar
  80b8e588bbdba61cf76f1f7b218a0387a6691ab3 20110307090952 jars/javac.jar
  5000664ee8b54ad75a72da627ab7665ca422f10b 20110307092642 jars/jcommon-1.0.12.jar
  166036abb16a0b57c7f7c0a0e0e610ef72b48746 20110307091015 jars/jep.jar
  ca45b966d92e07a3bcea6be98cbab05ea0d4e1ba 20110307092642 jars/jfreechart-1.0.13.jar
  925d65018db8d43d79f3e1236c0178805f68c488 20110303144100 jars/jna.jar
  63e9057128a2096b3787c4c784a5b6dab862264d 20110303144100 jars/jpedalSTD.jar
  b904075730a195dff53e602e836e6ced7b438257 20110303144100 jars/jruby.jar
  108412260f226609c8161f6e831119f47e6d9380 20110303144100 jars/js.jar
  bd25e435c97440c39a1edea79332016aad7f1091 20110303144100 jars/jsch-0.1.37.jar
  8e9a4bd810c0d4c6cc42df2e974373c24f3b4372 20110307090953 jars/junit-4.5.jar
  d6edc3bbc639248e808f4cc0e372cfa249320016 20110307090953 jars/jython.jar
  a21f73a79260a9098df7eabf10982ab9ff2d9efe 20110303144100 jars/jzlib-1.0.7.jar
  2b4610f09c5ed4164734d3238b27969d6bd14399 20110307091011 jars/mij.jar
  2534593d70ffd8b08b6969b78be423676e4ac9ba 20110307090953 jars/mpicbg.jar
  e008825954f9c01c5e3b3fa0004caa7535a45423 20110307090955 jars/pal-optimization.jar
  5cc5e4e537c2c5824beadcb03b7a1d6805e3a42f 20110307092642 jars/postgresql-8.2-506.jdbc3.jar
  b1bdf4b6b3e47ac5edb3d9ec8273401f6e8f64a3 20110307090954 jars/rsyntaxtextarea.jar
  7d5ba6c535ddd4557ca46698f08262348eeb072c 20110307091005 jars/wavelets.jar
  5dad0d14403c14be8273bf53efcfc3d75c07f361 20110307092642 jars/weave_jy2java.jar
  62509dafa2ad38e0e3c34c538f6d3da1e25971ce 20110307091008 jars/weka.jar
  c432f64b204f9657354de2010b24535670e3073b 20110303144100 luts/16_colors.lut
  89419f9999bc7d1dc09ad1a66e04e819396fe09f 20110303144100 luts/5_ramps.lut
  dc3a1bdd2b34edec84c29affaded489d0a22601d 20110303144100 luts/6_shades.lut
  0b3bbb6cf86adcb697c53c0277a12140966375dc 20110303144100 luts/Cyan Hot.lut
  655b55e6322c870632e5ff3156f002c0f5b893fe 20110303144100 luts/Green Fire Blue.lut
  2918f6d391ee38a4491163c30b4e75256a6633e7 20110303144100 luts/HiLo.lut
  a3312d3ff046120cccf5adcd400c512f78d18f93 20110303144100 luts/ICA.lut
  db5bf8a4e880d787d88f3273caf3db7ae6a5974f 20110303144100 luts/ICA2.lut
  9f7dd167f698970549ec20aa7d26b221ae7928f8 20110303144100 luts/ICA3.lut
  697dd3a4daf4abcd05cc4a79af3bcb3364fd0bb0 20110303144100 luts/Magenta Hot.lut
  524604de124b812940b02541a63516c84621237b 20110303144100 luts/Orange Hot.lut
  9c9a56c239e5d9c3262ace5124fff406cb3b831d 20110303144100 luts/Rainbow RGB.lut
  4e686ec669057c7de78497720bf52ebe00c3f8da 20110303144100 luts/Red Hot.lut
  2fdb7c96583f42348cd5cc789fba38dd6e349c89 20110303144100 luts/Thermal.lut
  321574916ccee56861ca6d581f6915cff5fe80e1 20110303144100 luts/Yellow Hot.lut
  a4cec22b96c306321ba4c7b3ff30df9fa7919616 20110303144100 luts/blue_orange_icb.lut
  c9e396a3f83ee8cebf1ed28d3e2d53296cc908e7 20110303144100 luts/brgbcmyw.lut
  60f85e63ba9a31fbb769ab32c75c22883df22883 20110303144100 luts/cool.lut
  ba88e5f3db79551a10b7bed5c2517b33cea57dda 20110303144100 luts/edges.lut
  0a4dce83c72986c06356ecbab98747c30c9366ad 20110303144100 luts/gem.lut
  c616e76585643c232c743e16358d68e4dfe24620 20110303144100 luts/glasbey.lut
  1f99f07ea5760dd8c044639b02da116112a2b985 20110303144100 luts/phase.lut
  52a3c3995ef92bc35eb4e691848af5351be589e4 20110303144100 luts/physics.lut
  49f5e48a355fe0646cd99bf7b371afb7c603def8 20110303144100 luts/royal.lut
  898954dd1342741de1cd48e7c581b6ec0f0cbff2 20110303144100 luts/sepia.lut
  ebd4ed6b0fd5375bd4d143134da5692253d4d44a 20110303144100 luts/smart.lut
  36e7ca9e01240243fb69ea5da21655608d6b5ef8 20110303144100 luts/thal.lut
  940b38f9db4fbe78ccd66222a08b28d1ae98ba04 20110303144100 luts/thallium.lut
  172436819bfde39bcf02fc8b41735f0c20db2ad1 20110303144100 luts/unionjack.lut
  a97e1da9c67b6764787b27473bbdb4a21d68292b 20110303144100 macros/listManagement.txt
  1785bbbf1033afe28da411beb5c2efea6bab1186 20110303144100 macros/toolsets/Clear Custom Tools.txt
  54200f47f8a6d5a131a7d9d65d7fcb75d53f97ae 20110303144100 macros/toolsets/Drawing Tools.txt
  f7efa1b3ca937510748f52b79ce283c1342d2012 20110307091005 misc/headless.jar
  17ec33c7680851d7d83b25c28c86663deb474359 20110307091014 plugins/3D_Blob_Segmentation.jar
  fa47c405e684e4a9fa699507c2f9605c17d6fc02 20110307090955 plugins/3D_Objects_Counter.jar
  72a5abf5f3842b5301c5f0d1f389c878add4d13b 20110307091001 plugins/3D_Viewer.jar
  68175df528f66e558b40d41867aa3539f55518bd 20110307091013 plugins/Algorithm_Launcher.jar
  9274f3373b27930ae5e6f3d1f88674f64110e970 20110303144100 plugins/Analyze/Dynamic_ROI_Profiler.clj
  7acae667f3873c3f47eb0fbf1d6b5f0718a5a1f9 20110303144100 plugins/Analyze/Measure_RGB.txt
  409919971c60b6cfc8ded41ba5999eb53eb595f3 20110307091006 plugins/AnalyzeSkeleton_.jar
  57e92445bb3feda9d1ffe6e6d4a682b70d2d0ed9 20110307091007 plugins/Analyze_Reader_Writer.jar
  ce0504b97f7820a918e9ff4cc62d590da32161d6 20110307091013 plugins/Anisotropic_Diffusion_2D.jar
  f1c1878b78908742c7f29e8e23f4ce0125aefeb4 20110307091011 plugins/Arrow_.jar
  0d2f57ac196ff70c91c9f5f9cb71cf65c78e2723 20110307090952 plugins/Auto_Threshold.jar
  269134edd05d40f1e326c8f351a969397ab261ea 20110307090954 plugins/BeanShell_Interpreter.jar
  d109763cccc66e8bf39603f25f28991d89e90d15 20110307091007 plugins/Bug_Submitter.jar
  8c7772f4b3e071c291f4c4361ff45adcd1957d19 20110919112140 plugins/ByteArray64.class
  e43ae2651743ca70a12b898b8bd7e084e2288943 20110307090954 plugins/CLI_.jar
  919ab06bdcbf59c28aeca3f340f7cd8285e29780 20110307091014 plugins/CPU_Meter.jar
  d888370a9a41fe87d542665027edc84eff31637e 20110307091005 plugins/Calculator_Plus.jar
  2dc5d027ef23416f31860dc0e158aa1b6ab9a11f 20110307090954 plugins/Clojure_Interpreter.jar
  db71677ea83bdec19cb32d6c708882b4a77b791b 20110307091005 plugins/Colocalisation_Analysis.jar
  f2f8c5c376c80df66cc1ccbcbf12babd366eda85 20110307091015 plugins/Color_Histogram.jar
  1cee26bc818eb02dafe9ad08dd437b10c412aa2b 20110307090952 plugins/Color_Inspector_3D.jar
  1a992dbc077ef84020d44a980c7992ba6c8edf3d 20110307091007 plugins/Daltonize_.jar
  b73a16189c15d0e5f59d0b9da7d9dafc19177379 20110307091013 plugins/Differentials_.jar
  9d756f88aa74cf6511a6890a3096eccf054da978 20110307092642 plugins/Directionality_.jar
  83caa3dfc56cba0ff2a4ec8a2532dd674784d356 20110303144100 plugins/Examples/Add_Popup_Split_Channels.bsh
  f6fcfac7beaaf48901cf57d1dd5a9232d6e43570 20110303144100 plugins/Examples/Anaglyph_for_Red_Cyan_glasses.rb
  5dcd79ab303b72dbd5540b604bd30ce0e2a5ddcb 20110303144100 plugins/Examples/Blobs_Demo_in_Ruby.rb
  73eff73688cbf8356485d4dac6fe2b26db598e93 20110303144100 plugins/Examples/Command_Launchers/Command_Launcher_BeanShell.bsh
  95549b2f2f2c42a8bf5bb5f6d18f58d25c4c06cc 20110303144100 plugins/Examples/Command_Launchers/Command_Launcher_Clojure.clj
  dceba709afa80f33ae5d0091f5811b32610e1fd0 20110303144100 plugins/Examples/Command_Launchers/Command_Launcher_Javascript.js
  e4954eacd4b1b679813c4227563996121f7e6d98 20110303144100 plugins/Examples/Command_Launchers/Command_Launcher_Python.py
  f51112123ed16a9ff9c0cf5002dea3804731a8cb 20110303144100 plugins/Examples/Command_Launchers/Command_Launcher_Ruby.rb
  77c7bef5e629a85ae8b037caf2377cb6772f59df 20110303144100 plugins/Examples/Delayed_Snapshot.py
  5536e038a497982f3e10d924849c4ffe6c4fdd3c 20110303144100 plugins/Examples/Delayed_Snapshot_Window.bsh
  4164c08c7ef62e27e731d45643a1cbe10098fce1 20110303144100 plugins/Examples/Edit_LUT_As_Text.py
  780e948e100ffc6bfcd5583146752eff86671b39 20110303144100 plugins/Examples/Extended_Profile_Plot.bsh
  b8881af27131bb518e2c8f45510811963f091e21 20110303144100 plugins/Examples/Fiji_Cube.ijm
  3687a018e780919fc238a411c0d76607060ae47f 20110303144100 plugins/Examples/Fiji_Logo_3D.js
  998cb71706d82992543115b6ad1b85f7d199d096 20110303144100 plugins/Examples/Find_Dimension_of_Raw_Image.py
  0e5cad6495d8ee4f07a5378740f6202a24eb2988 20110303144100 plugins/Examples/Image_To_Tool_Icon.bsh
  748153294412dc6fd4febc6c529e7620ba48ae1e 20110303144100 plugins/Examples/Multithreaded_Image_Processing.clj
  720c237bd586550b63e2d423d2e85759e045869c 20110303144100 plugins/Examples/Multithreaded_Image_Processing_in_Javascript.js
  ad263d9ec66f7421f8817b0a9f9e2549fd5883b7 20110303144100 plugins/Examples/Plasma_Cloud.rb
  9efb229268bb88ae20f4b2bca157e73c0c0afbdf 20110303144100 plugins/Examples/Same_Slice_in_Multiple_Images.rb
  940f6500947184db3dfbcad055aa98c11db41c24 20110303144100 plugins/Examples/TrakEM2_Example_Scripts/Measure_AreaLists.py
  3f4bba61fc90eb79a8ade2a6399cad72ede26fb9 20110303144100 plugins/Examples/TrakEM2_Example_Scripts/T2_Select_All.py
  72f0094941e8aae9c451161f05a67f6516d70a55 20110303144100 plugins/Examples/TrakEM2_Example_Scripts/T2_set_all_transforms_to_identity.py
  89ef030758e89f6a6767ab5e3513ee82a8e54127 20110303144100 plugins/Examples/TrakEM2_Example_Scripts/extract_stack_under_arealist.py
  6af490cdb6e2c42e87076b85796dc824203b6e8a 20110303144100 plugins/Examples/blend_two_images.clj
  0989cf7430916a9e0c9f004bc2d5bc6b276e2775 20110303144100 plugins/Examples/celsius_to_fahrenheit.clj
  ff3b990238ad1f85e4a8aa8135e2e3b1221b43a8 20110303144100 plugins/Examples/chess_.py
  4193ae7c8fbe191bff50f19367c5cfa5e0048fbe 20110303144100 plugins/Examples/downsample_.js
  66a204d61b3076d96797ca04671180ed83ebf866 20110303144100 plugins/Examples/list_all_threads.py
  6c86493c27f859bd52ad85581479e5f06655ce0d 20110303144100 plugins/Examples/random_noise_example.clj
  d08b0ee85679350fbd6b609d33f5acc2ad70775d 20110307091012 plugins/Extended_Depth_Field.jar
  650f19766157bdd8d35f67ea474a57ed1b4c24f7 20110307091008 plugins/FeatureJ_.jar
  bf462abc7897f13ab9e6ad7cccbdc28cd97f5e32 20110307092642 plugins/Feature_Detection.jar
  9248e7c9e5684badab20772f46f020ade733afc6 20110307092642 plugins/Fiji_Developer.jar
  3f5f1faad124a996bb28c72fa10cd50e06295934 20110307091007 plugins/Fiji_Plugins.jar
  c44fdea821229498f1aa2bf64c418f8f89939cc8 20110307091006 plugins/Fiji_Updater.jar
  d53247c86445afc29f991a39cb39b79f2f3fd4c1 20110307091008 plugins/FlowJ_.jar
  94559184bb4bf02414286cb9d20b95dd8806bd32 20110307090953 plugins/Graph_Cut.jar
  42556198e68860b4135544fe9e4687c9fbffbfe2 20110307091008 plugins/Gray_Morphology.jar
  e8f24a89734ea514ba6405423368a107f324fc5b 20110307091002 plugins/IJ_Robot.jar
  441d49d6b49c35df6e42768a061890a5054d0c63 20110307091005 plugins/IO_.jar
  0b192ea98d65b21fe6b89e16d99492f2bb749bf5 20110307090953 plugins/Image_5D.jar
  2500db76f284b2c729636bf2924cad33cd8ce8f9 20110307092642 plugins/Image_Expression_Parser.jar
  43bb3a7b79d1fc23958a7775f407fa9567c6f67f 20110307090952 plugins/Interactive_3D_Surface_Plot.jar
  3ea0d59d5878d1eeed2f7e1796b504b28ff1818a 20110307091013 plugins/IsoData_Classifier.jar
  28582f554fdbc4905b5ca4eb192a516202b2f334 20110303144100 plugins/JRuby/imagej.rb
  f1e7ff046afb5a2a4136449fbb16ccc78ce4e4cc 20110307090954 plugins/JRuby_Interpreter.jar
  0384fcf1924f7e512c15ceb5c38275f822b590a6 20110307090954 plugins/Javascript_.jar
  7c039e95cd514cf9bdf2e325122c4cdbf9fbd07d 20110307090954 plugins/Jython_Interpreter.jar
  aee7e97d8a959676872ecafaaaf37724e83b55e4 20110307091005 plugins/LSM_Reader.jar
  de0f4b6754561dc8a412f2d2c67ec10351f5d238 20110307091006 plugins/LSM_Toolbox.jar
  7dcbc0831ee6cec3b79e90e8b292d25b34174e54 20110307091010 plugins/Lasso_and_Blow_Tool.jar
  fe3c88710e380c7a741cbf676cf5d8144e7edb8a 20110307090955 plugins/Linear_Kuwahara.jar
  bcb926fe63b7637bd53e3602feda2166951acdec 20110307091004 plugins/LocalThickness_.jar
  1a6345a290ff4a28ac4215cbb47fc561dcc886be 20110307091006 plugins/MTrack2_.jar
  2e7c5f2d14a85c9a073074d5540aef234cb3cea5 20110307090955 plugins/M_I_P.jar
  65a2dd7816efceb28030dc0ea7cb4ad51c42e9a0 20110303144100 plugins/Macros/About_Plugin_Macros.txt
  dff5642dcb662c06fd8cd7dfce73f60a4b8b8244 20110303144100 plugins/Macros/Bulls_Eye.txt
  e7ffe8ba782ce90d3b80ad882c474ab1836b58a4 20110303144100 plugins/Macros/Polygon_.txt
  39f7ffcd9b21888b618524a811eb39c93625578d 20110303144100 plugins/Macros/RGB_Histogram.txt
  3ee0edfae7b40189254e38a6ed8108c52859bc33 20110303144100 plugins/Macros/batch_convert_any_to_tif.txt
  d0cd293b359b7bcdf390e560dc28f68fa8033677 20110307091012 plugins/Manual_Tracking.jar
  de3a020be174270600534345eb47fd76267d8080 20110307091014 plugins/MosaicJ_.jar
  a349b390595c90be2924a20a372aac99bad438e7 20110307091012 plugins/PIV_analyser.jar
  c0e6e54ff0ec7c62350f232af75c85ca7006b51f 20110307091010 plugins/PointPicker_.jar
  32d24a273fef021b079fc64f151c2436af700b30 20110307091009 plugins/QuickPALM_.jar
  174a4b19524f15ff22356cb08dbef7f4e1f550c1 20110307091005 plugins/RATS_.jar
  b1a406f658f5b62633275c8316849532a0d90797 20110307091012 plugins/RandomJ_.jar
  0ab9e3b0886ae1aab0651865d98473295f2cc715 20110307091013 plugins/Record_Screen.jar
  018c76c3fbfc41a7dd3f7c2ac5cd7cbbde8dc21b 20110307090954 plugins/Refresh_Javas.jar
  9631521c22c7406e80d627145f1323648cd4a588 20110307092642 plugins/SPIM_Registration.jar
  6e155e63de9510ee2fb990d9cc6ddf0c5f209cb5 20110307091009 plugins/Samples_.jar
  942f0e609a95728147c0ad1ca8ff8787e33afeaf 20110307092642 plugins/Script_Editor.jar
  c70b2e6f4dbfcd1183c3027c924069866095c940 20110303144100 plugins/Scripts/File/Open_Samples/Adelsons_Squares.ijm
  3a1bff814b818c22e37205e7722672d27f3eb90e 20110303144100 plugins/Scripts/File/Open_Samples/Spirals_.ijm
  a3edd6db28d98349de92ec85b28c015768f782a5 20110303144100 plugins/Scripts/Image/Adjust/Scale_to_DPI.js
  209aed5232d40e0b4bcd237750383865dd07b0d3 20110307080923 plugins/Scripts/Image/Color/Set_Color_By_Wavelength.ijm
  2c3c59a75761789e2b75d839b5f21fd2350a9327 20110303144100 plugins/Scripts/Image/Hyperstacks/Temporal-Color_Code.ijm
  d3841c4a5d74295cd73b547aaa85961682805c83 20110303144100 plugins/Scripts/Plugins/Registration/Correct_3D_drift.py
  eb8a84a1111ec35b85a444766fa37cd4a610a965 20110307091006 plugins/Series_Labeler.jar
  50ee8cf26b2e4bf1b9774a83d227fae873158ef8 20110307090952 plugins/SheppLogan_.jar
  6c6b298e9c055f147224ed889b2e74e0d6496c4d 20110307092642 plugins/Simple_Neurite_Tracer.jar
  265850b38137898969ca510b0cb1e5e2536f4226 20110307091007 plugins/Siox_Segmentation.jar
  1a5f4c622997d1d23f1d08c81c46b80b4da05d47 20110307091005 plugins/Skeletonize3D_.jar
  e71b5942e5343cbc3d591f249cc9f3dfc73c7e29 20110307091002 plugins/Snakuscule_.jar
  41d82921719c38520d5472a3608b79394db1b7b0 20110307091011 plugins/SplineDeformationGenerator_.jar
  b5a0eabcb770437c30575d4ea6f5dbd346b8bd89 20110307091012 plugins/StackReg_.jar
  e91eeedb968afe7b4af6c2404f278bb5fd568e92 20110307091008 plugins/Stack_Manipulation.jar
  23cae80cce99d71dc4669da51c6909c3a7ca68ca 20110307091007 plugins/Statistical_Region_Merging.jar
  0e0ee2ccceadc26f65f318d17971fa040f7a4fbd 20110307092642 plugins/Stitching_.jar
  f05089fa82aca755fea1268bff7f63793692e5c8 20110307090953 plugins/Sync_Win.jar
  b60eef5d020c0e881b4bb97d1579339e1cb2a60e 20110307091005 plugins/Thread_Killer.jar
  f5b2c18843647be28a96a3e7d163a7f2f970921b 20110307090952 plugins/Time_Stamper.jar
  22fd045b2a57d7ed84b5dcb7b6146484143e36fc 20110307090955 plugins/ToAST_.jar
  5e20cc0a6c833ebfdcd5fc6517eed89a44ae35dc 20110307091011 plugins/TopoJ_.jar
  963f0b325919991a8c31ef06a1c84ad499d52232 20110307092642 plugins/Trainable_Segmentation.jar
  e2d20ba7cb6a291bc7063a84f90b059b4e8125ab 20110307092642 plugins/TrakEM2_.jar
  39d4aaafb0c6bea4ef6cdf95bcaf2c4665d9bdc2 20110307091011 plugins/TransformJ_.jar
  09868b512410628e06c7dc25a6999c7dda8cf078 20110307091013 plugins/TurboReg_.jar
  9558400db089262849c33428a77645c323390145 20110307091013 plugins/UnwarpJ_.jar
  a32dfe463fa2c8814cb0caf9079478ff4e1c44bf 20110303144100 plugins/Utilities/Close_All_Without_Saving.txt
  dd9e7806031f8b85742e0e3121b301d1e129162d 20110307091002 plugins/VIB_.jar
  d6cf9638dc212f49fc3d2d4e99ca7aedc78956a2 20110307091006 plugins/Video_Editing.jar
  a43c9ad3f07dbfa56be075a9ebdcfa115f6675c8 20110307091005 plugins/View5D_.jar
  b8c3af50365b12b0beb010f1c35134cbd310341a 20110307091013 plugins/Volume_Viewer.jar
  e9a7358277abe3a90df974fc81d96be9c9a71a9e 20110307091010 plugins/bUnwarpJ_.jar
  659ad6a335b4947eef8758b1b0cf050779430b78 20110307091007 plugins/ij-ImageIO_.jar
  06097e6d24c69a9ca3e2c8a18971639419147dbf 20110307090955 plugins/level_sets.jar
  5951e73c2a4280d562535f8da8e39a8749010bd7 20110307091004 plugins/loci_tools.jar
  7666962cc18a0275b7198d6d64afba9033ca1604 20110307091014 plugins/mpicbg_.jar
  5e32d936ba53c22ba6b70e5eee3992a361bc2ff8 20110307091012 plugins/panorama_.jar
  7c856ee24f98f7d796109c54819c3af348bc1380 20110919112140 plugins/raw_reader.class
  243a5e663d887ee937ba01a1caff353d81a36030 20110919112111 plugins/raw_writer.class
  2adb45159e240b11b22e63b2922b0701e2c36b37 20110919112111 plugins/readme_how_to_build.txt
  91bf372e9c531a68d08cb158239df303c0a37fb1 20110307092642 plugins/register_virtual_stack_slices.jar
  4d7eaf239c033d305a464a06c3e64c68d096c7e1 20110307092642 plugins/registration_3d.jar
  e6e0879f5d50afa8d0dd213b4b66e396a39a47b7 20110303144101 retro/backport-util-concurrent-3.1.jar
  e250f0c40b768e90ed7d3910d9869075f3e438cd 20110303144101 retro/retrotranslator-runtime-1.2.7.jar
  eea1390da8fac38763ed4c03f1acb3342b942717 20110303144101 retro/retrotranslator-transformer-1.2.7.jar
  21e7b7ec24eff575a502e3ac5089de5b3745af15 20110303144101 scripts/Miji.m
  3daabf6b3c20f374cf42b672eb29035003dbc40e 20110303144101 scripts/Miji_Test.m
  d326018044a582f5106efc6fc90ad09f98a6a822 20110303144101 scripts/Record_Desktop.py
  0ea7f8fc6683e74065ae7fd82c1b92676e069526 20110303144101 scripts/Record_Window.py
  af954bdff6392779e47e43fb4063f255a8a5ec6b 20110303144101 scripts/bfopen.m
Comment 1 Johannes Schindelin 2011-10-13 07:04:04 CDT
Hi aRnim,

from reading the source, it is obvious why the duplicating fails (in my tests, it always worked because I never used hyperstacks...). That showHSDialog() method was written with the fast assumption that there is always one graphical desktop present with one user staring at it.

As I was rewriting the headless support in an ongoing effort to streamline Fiji/ImageJ2 development, I should be able to tackle this bug tomorrow.

If you're interested in details: I will basically have to rewrite the method showHSDialog() on the fly to prevent it from assuming that it can get TextField instances (in order to add TextListeners, which are not really useful in batch mode...).

Unfortunately, this will be piecemeal. Curtis and me discussed the issue, and basically there are four options:

1) fix things as they crop up, never really fixing the whole thing,
2) reimplementing all the AWT classes so as to run in headless mode,
3) bundle WeirdX (an X server written in Java: http://www.jcraft.com/weirdx/) and somehow connect to that,
4) wait for ImageJ2 (because it is relatively easy for plugins in ImageJ2 to separate between GUI and processing, so headless mode should work by just foregoing all UI stuff).

Obviously, we're going for 1) & 4), although if you feel adventurous, you could try to get 3) running.

As for 2), it would be way too much work, even if there exists a project implementing AWT in pure Java (http://www.eteks.com/pja/en/). However, I never got it to work (Java6 always ignored that AWT and insisted on using its own); but now we probably could get it to work by using Javassist for run-time patching, especially the plugins. But it still would be a lot of work.

Apart from taking too much time away from the Fiji/ImageJ2 project, and apart from the purely aesthetical point that we should not waste CPU cycles on emulating a desktop when nobody will ever be able to look at it, both 2) & 3) have the conceptual problem that the user-supplied code can call blocking dialogs. And nothing is more annoying than having code running on 512 nodes waiting for a user to click OK.
Comment 2 Johannes Schindelin 2011-10-13 07:28:18 CDT
I still need to do more tests, but I just pushed a fix to the source code repository. If things go according to plan, I will upload the fixes to the updater tomorrow.

FWIW. this was my commandline to reproduce quickly:

./fiji --headless -eval 'newImage("a1", "8-bit", 2, 2, 8);run("Stack to Hyperstack...", "channels=2 slices=2 frames=2");run("Duplicate...", "title=Untitled-1 channels=1-2 slices=1-2 frames=1-2");print(nImages);' -batch

and this is the commit with the fix:

http://fiji.sc/cgi-bin/gitweb.cgi?p=fiji.git;a=commitdiff;h=22dc3c8b19dd4d03058a6a4a5d880315a7d1fdf2
Comment 3 Johannes Schindelin 2011-10-19 20:09:39 CDT
Okay, I declare this bug squashed! The bug in Javassist which prevented this from working properly has been fixed: https://issues.jboss.org/browse/JASSIST-145 and I actually already uploaded the relevant files after verifying that the issue does not occur here anymore.

Please feel free to open new tickets for whatever issues with headless mode crop up, I intend to follow strategy number 1) in comment #1.