Re: Macro fails to open stack when launched from the commandline
Posted by
Wayne Rasband-2 on
URL: http://imagej.273.s1.nabble.com/Macro-fails-to-open-stack-when-launched-from-the-commandline-tp5019638p5019700.html
> On Nov 6, 2017, at 6:18 AM, Stein Rørvik <
[hidden email]> wrote:
>
> Hello,
>
> I have encountered a strange bug:
> If a macro is launched from the commandline (Windows 7 64-bit, Java 1.6), any stack import silently fails UNLESS ImageJ is already running.
This problem is fixed in the latest ImageJ daily build (1.51s23). It fixes bugs that caused the RunAtStartup, AutoRun and command line macros to interfere with each other, causing &variable expansion in run() macro calls to not work. To avoid this interference, the RunAtStartup macro (created by the Edit>Options>Startup command), the AutoRun macro (in StartupMacros) and command line macros now all run on the same thread.
-wayne
> To reproduce the problem:
>
> Demo macro to create a stack to be opened:
>
> MacroMakeVirtualStack.ijm
> ----------------------------------------------------------------------
> run("T1 Head (2.4M, 16-bits)");
> dir = getDirectory("temp")+"T1-Head\\";
> File.makeDirectory(dir);
> run("Image Sequence... ", "format=TIFF save="+dir);
> ----------------------------------------------------------------------
>
> Demo macro to open this stack:
>
> MacroOpenVirtualStack.ijm
> ----------------------------------------------------------------------
> dir = getDirectory("temp")+"T1-Head\\";
> print("Dir to import: '" + dir + "'");
> run("Image Sequence...", "open=&dir sort use"); print("Opened title: " + getTitle());
> ----------------------------------------------------------------------
>
> Put the above in the ImageJ/macros folder and run this on the commandline (without ImageJ running)
>
> ImageJ.exe -macro MacroOpenVirtualStack.ijm
>
> The macro fails to open the stack.
> Now go back to the command line and repeat the command, without closing ImageJ.
> The macro now works as it should.
>
> The problem occurs with both real and virtual stacks.
> The problem occurs on three out of five computers I have tested it on; all running Windows 7 64-bit.
> It occurs on both old and new versions of ImageJ (I tried 1.49 and 1.51r).
> The computers it works on are the slowest ones, so I suspect it might be a timing issue.
>
> Stein
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html