Macro recording fails to save parameters

Hello,
the recording of macro parameters fails under certain configurations. For instance the command run(“Close All”) prevents from recording the macro parameters. In fact it seems to be the case for any macro with a run command in it. It was not like this in the past.

#@ String (label="Hello world") tmp
print(tmp);

is recorded correctly as as run("script:C:\Users\apoliti\Downloads\record_example.ijm", "tmp=[you are welcome]");

whereas adding a “Close All” command fails

#@ String (label="Hello world") tmp
print(tmp);
run("Close All");

gives run("script:C:\Users\apoliti\Downloads\record_example.ijm");

Greetings

Antonio

3 Likes

I wonder is this is a reappearance of an old problem mentioned in past posts. I am pretty sure that the recording was working fine a few weeks/months ago.

2 Likes

Hi @apoliti, thanks for reporting this.

I can reproduce the issue, both when running via Run button from the script editor, or when running the command from the menu after saving the macro in a subfolder of Fiji.app/scripts/

All I can say is that it’s not related to the issue you linked. When @ctrueden fixed the recording logic, he also added a regression test in a follow-up commit.

I tried to adapt the regression test with your example script, @apoliti, but it seems the recorded arguments at that stage are all correct, no matter if the run("Close All"); command is present or absent.

I rather suspect a case of “premature” recording, i.e. the recorder being triggered before the MacroRecorderPostprocessor was called. I observed similar behavior in the past (with pure ImageJ1 functionality) when my Javascript scripts contained calls to IJ.run() in preview code of the script, which was then preventing the correct appending of macro parameters to the command in the recorder.

For those who want to dig deeper (and for my future self), see also this javadoc comment in the source:


The issue also doesn’t seem specific to ImageJ1 (i.e. ij.jar) alone, as downgrading to 1.52 of 1.51 didn’t fix the problem in my tests. So we’ll have to look somewhere in imagej-legacy or ij1-patcher.


For the record: @apoliti also filed a GitHub issue, so I let imagesc-bot do its job.

Dear @imagejan,
I just want to note that the issue is not related to run("Close All") but to nearly all commands you execute.

For instance this

#@ String (label = "astring") tmp
print(tmp)

records

run("script:C:\Users\apoliti\Desktop\example_macro_record.ijm", "tmp=[you are welcome]");

whereas

#@ String (label = "astring") tmp
print(tmp)
run("T1 Head (16-bits)");
run("Z Project...", "projection=[Max Intensity]");

does not record the parameters.

I also get the same type of behavior on a OSX system.
Greetings

Antonio

Yes, thanks for clarifying. I observed the same: any run(...) command will trigger the behavior of what I think could be “premature recording”, before the MacroRecorderPostprocessor had a chance to collect the parameters. Maybe @hinerm or @ctrueden can help digging for the cause?