Macro question on MultiAperture

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Macro question on MultiAperture

johnthelast
This post was updated on .
When I execute the following lines in a macro:

// Run Multi-Aperture
        // AIJ uses the "MultiAperture " command (note trailing space in command name).
        print("Starting MultiAperture Run");
        setKeyDown("Enter");
        run("MultiAperture ", "use_previous_apertures=true pause_at_each_image=false centroid_apertures=true save_measurements_file=true");
        print("MultiApertureRun Finished");

I get the message "No Measurements table found after Multi-Aperture".

Why aren't the measurements being run. If I manually use the last 3 apertures and run it I get measurements on the files.

Running 6.0.3

More information. When I step through the macro, it does add the apertures correctly and applies them to the image set. But, it does not actually execute the measurement and build the measurements table. Is there an optional parameter that I need to pass to MultiAperture to actually run the measurement process?
Reply | Threaded
Open this post in threaded view
|

Re: Macro question on MultiAperture

keastrid
You need to set multiaperture.automode to true to run MA via a macro. You'll also want to wait for MA to finish by watching multiaperture.finished to be true. If you cancel the MA run, you'll want to make sure to reset automode to false so you can run MA manually.

This should work:
call("ij.Prefs.set","multiaperture.automode","true");

run("MultiAperture ", "use_previous_apertures=true pause_at_each_image=false centroid_apertures=true save_measurements_file=true");

waiting = true;

while (waiting) {
	wait(1000);
	finished = call("ij.Prefs.get","multiaperture.finished","false");
	if(finished == "true") {
		waiting = false;
		call("ij.Prefs.set","multiaperture.automode","false");
		call("ij.Prefs.set","multiaperture.finished","false");
		print ("Multi Aperture analysis finished");
	}
}
Reply | Threaded
Open this post in threaded view
|

Re: Macro question on MultiAperture

johnthelast
Thank you very much. That did the trick.

Just out of curiosity, is there a reference manual for all run processes and their optional parameters?
Reply | Threaded
Open this post in threaded view
|

Re: Macro question on MultiAperture

keastrid
We currently don't have any documentation for the options. Macro recording mode should capture all of them for you. Plugins > Macros > Record
Reply | Threaded
Open this post in threaded view
|

Re: Macro question on MultiAperture

johnthelast
That's what I thought, but when I tried to macro record the MultiAperture, oftentimes, it would not show anything at all. More often than not, it didn't record anything. Would you like me to try a record and do a screenshot of the results? I can duplicate this tomorrow.
Reply | Threaded
Open this post in threaded view
|

Re: Macro question on MultiAperture

karenacollins
Administrator
Yes, please do if the screenshot might give us some useful debugging info.
Reply | Threaded
Open this post in threaded view
|

Re: Macro question on MultiAperture

johnthelast
I tried to create a macro. I recorded the following commands:
1) importing an image sequence
2) opening an image
3) opening an aperture
4) running multi aperture
5) placeing the imported apertures
6) closing the image

The macro that was generated had the following commands:

run("Image Sequence...", "dir= dir=[D:/2026-02-15/LIGHT/AD Leo/Splits/] dir=[D:/2026-02-15/LIGHT/AD Leo/Splits/] filter=TR count=--- rbg1=AND sort use");
open("D:/2026-02-15/LIGHT/AD Leo/AD Leo_2026-02-15_00-00-14__0.00_12.00s_13803_cal.fits");
selectImage("AD Leo_2026-02-15_00-00-14__0.00_12.00s_13803_cal.fits");
selectImage("AD Leo_2026-02-15_00-00-14__0.00_12.00s_13803_cal.fits");
close;
Reply | Threaded
Open this post in threaded view
|

Re: Macro question on MultiAperture

keastrid
Hi John,

This issue is fixed in 6.0.4, which is now available. If you notice any other plugins not working with the recorder, please let us know.

Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: Macro question on MultiAperture macro recording

johnthelast
I think there still is a problem. I tried to import a sequence, open an aperture, and run the multi aperture while recording. This was all that I got.

File.openSequence("D:/Done/2026-02-14/LIGHT/AD Leo/Phoranso Bayer Binning/", "virtual filter=TR");
selectImage("Phoranso Bayer Binning");
selectImage("Phoranso Bayer Binning");

Also, there seems to be a JAVA exception as well. Here is the log:

AIJ 6.0.4.00; ImageJ 1.54m1; Java 25.0.2 [64-bit]; Windows 11 10.0; 173MB of 98240MB (<1%)
java.lang.NullPointerException: Cannot invoke "java.lang.Enum.name()" because the return value of "java.util.concurrent.atomic.AtomicReference.get()" is null
        at ij.astro.gui.GenericSwingDialog.lambda$addRadioOptions$2(GenericSwingDialog.java:1126)
        at ij.astro.gui.GenericSwingDialog.lambda$dispose$0(GenericSwingDialog.java:1729)
        at java.base/java.util.LinkedHashMap.forEach(Unknown Source)
        at ij.astro.gui.GenericSwingDialog.dispose(GenericSwingDialog.java:1729)
        at ij.astro.gui.GenericSwingDialog.lambda$displayDialog$2(GenericSwingDialog.java:1315)
        at java.desktop/javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        at java.desktop/javax.swing.DefaultButtonModel.setPressed(Unknown Source)
        at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
        at java.desktop/java.awt.Component.processMouseEvent(Unknown Source)
        at java.desktop/javax.swing.JComponent.processMouseEvent(Unknown Source)
        at java.desktop/java.awt.Component.processEvent(Unknown Source)
        at java.desktop/java.awt.Container.processEvent(Unknown Source)
        at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
        at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
        at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.desktop/java.awt.WaitDispatchSupport$2.run(Unknown Source)
        at java.desktop/java.awt.WaitDispatchSupport.enter(Unknown Source)
        at java.desktop/java.awt.Dialog.show(Unknown Source)
        at java.desktop/java.awt.Component.show(Unknown Source)
        at java.desktop/java.awt.Component.setVisible(Unknown Source)
        at java.desktop/java.awt.Window.setVisible(Unknown Source)
        at java.desktop/java.awt.Dialog.setVisible(Unknown Source)
        at ij.astro.gui.GenericSwingDialog.displayDialog(GenericSwingDialog.java:1400)
        at ij.astro.gui.GenericSwingDialog.showDialog(GenericSwingDialog.java:1259)
        at Astronomy.MultiAperture_.setUpApertures(MultiAperture_.java:4325)
        at Astronomy.MultiAperture_.run(MultiAperture_.java:833)
        at ij.plugin.filter.PlugInFilterRunner.processOneImage(PlugInFilterRunner.java:266)
        at ij.plugin.filter.PlugInFilterRunner.<init>(PlugInFilterRunner.java:114)
        at ij.IJ.runUserPlugIn(IJ.java:247)
        at ij.IJ.runPlugIn(IJ.java:210)
        at ij.IJ.runPlugIn(IJ.java:199)
        at astroj.AstroStackWindow.lambda$actionPerformed$4(AstroStackWindow.java:4128)
        at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)
 
Reply | Threaded
Open this post in threaded view
|

Re: Macro question on MultiAperture macro recording

karenacollins
Administrator
Thank you for the report. We have published a fix in 6.0.4.01. You will not be notified that an update is available when you start AIJ. You will need to manually go to Toolbar > Help > Update AstroImageJ, make sure to enable "Show Daily Build" . Then select 6.0.4.1 and update to that version.

Let us know if you see additional problems.

Karen
Reply | Threaded
Open this post in threaded view
|

Re: Macro question on MultiAperture macro recording

johnthelast
That did seem to fix the macro recording. I now get the full set of parameters. Only glitch is that the recorded text shows a run Astronomy.MultiAperture__  and it seems to only work if I change that to "Multiaperture "

Also, can you look at the other issue I posted regarding the "No stored aperture" message. I can't seem to figure that one out. The macro was working. I do have valid apertures.
Reply | Threaded
Open this post in threaded view
|

Re: Macro question on MultiAperture macro recording

karenacollins
Administrator
File name fixed in 6.0.4.03 and later.