Returning custom user input from a dialogue box from "Rotate..."

Hello. I’m trying like mad to figure out how to save the user input from the rotate command. I can run the run(“Rotate…”) command and the dialogue box opens up and lets you preview the rotation, change the angle, etc. What I want is to save the angle that I end up using. So far everything I’ve found only talks about inputing variables but not extracting them from the dialogue box supplied by a built in function in ImageJ.

How the heck can I use the user input to select an angle for rotation and then save what I typed in that dialogue box? The next time you open up the rotate command, the last values are set as the default, so it has to be saving them somehow and somewhere…

Welcome to the forum, @JoeM!

Use the Macro Recorder to learn the syntax.

  • Press L for the Command Finder.
  • Type Record... and hit enter.
  • Press Shift+B for Blobs.
  • Press L, type Rotate... and choose the Image > Transform one.
  • Enter desired rotation values.

Your Recorder window should show something like:

run("Blobs (25K)");
run("Rotate... ", "angle=15 grid=1 interpolation=Bilinear");

This is not what I need. This is about inputting to a rotate command. I need to extract user-selected inputs that came from the dialogue box that rotate opens.

It is not trivial. From a macro, it would require a rather insane hack (using eval to call a script of several lines).

How about instead, something like this macro:

// @double (label="Rotation angle", value=15) angle
run("Rotate... ", "angle=" + angle + " grid=1 interpolation=Bilinear");

This uses the SciJava script parameter mechanism to harvest the angle from the user.

And then you have the angle variable in the macro with which you can do additional things besides just applying the rotation.

It will also work in other contexts—e.g., headless from the command line, passing the angle as a command line argument.

1 Like

I’m trying this as well as a few variants but it doesn’t seem to work (I keep getting errors that the variable angle doesn’t exist). I tried changing the // to #/%/removing it etc. but it keeps giving me an error about the variable not existing.

I must note that I’m currently trying to use the run(…) command because I’m trying to eventually set it up to run in Matlab with MIJ.run(…). Either way, I can’t get it working in FIJI alone.

That is odd. You are using the Script Editor, right? Not the ImageJ 1.x text editor?

Just a heads up to check out the ImageJ-MATLAB page if you haven’t seen it already.