Re: Stack Aligner does not work in a macro with AstroImageJ V5
Posted by GeorgeF on Mar 28, 2023; 6:55pm
URL: http://astroimagej.170.s1.nabble.com/Stack-Aligner-does-not-work-in-a-macro-with-AstroImageJ-V5-tp2180p2195.html
Hi Kevin
Sorry about time taken to reply - I have been setting up part of the main macro to test - yes run as a simple statement it works - however I kept adding code back up the macro and reached a point which caused it to fail.
MasterFlats = "X\:\\Master\\Flats\\" + Fdate + "\\" + Filter + "\\";
MasterFlatImage = MasterFlats + "\\mflat.fits"; // need to get stats from this file
open(MasterFlatImage);
// get max values
//other work on master flat
// ... but removed for this test
close("*");
file = CalEntry;
list = getFileList(CalEntry);
i = list.length;
print ("Loading Sequence");
// file = "X:\\Images\\Variable Stars\\R Mon (VSX18829)\\2023-03-07\\B\\gain_300\\Calibrated";
// file = "X:\\Images\\R Mon (VSX18829)\\2023-03-07\\B\\gain_300\\Calibrated";
print ("Sequence File " + file);
// I have preset that stack aligning will be done by WCS
call("ij.Prefs.set","stackAligner.useWCSOnly","true");
run("Image Sequence...", "open=&file number=i starting=1 increment=1 scale=100 file=[] or=[] sort");
print("Images loaded..");
selectWindow("Calibrated");
run("Stack Aligner", "first=1 last=i radius=8 inner=14 outer=21 use=false use_0=false use_1=false allow=false use_2=true remove=false align=false show=false");
print("Waiting for Align stack to complete");
Alignwait = 0;
while ((isOpen("Aligned_") == false) && (Alignwait < 20)){ // again we have an asynchronous process we have to wait for
wait(5000);
print("waiting...");
Alignwait = Alignwait + 1;
}
THIS PART OF THE MACRO FAILS
aij.log
Exception in thread "pool-1-thread-1" java.lang.NullPointerException: Cannot invoke "ij.ImagePlus.getProcessor()" because "this.imp" is null
at astroj.AstroStackWindow.setAstroProcessor(AstroStackWindow.java:5425)
at astroj.AstroStackWindow.setAstroProcessor(AstroStackWindow.java:5421)
at Astronomy.Astronomy_Listener.lambda$imageUpdated$0(Astronomy_Listener.java:72)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Exception in thread "pool-1-thread-2" java.lang.NullPointerException: Cannot invoke "ij.ImagePlus.setRoi(ij.gui.Roi)" because "this.imp" is null
at astroj.AstroStackWindow.getBiSliderStatistics(AstroStackWindow.java:5363)
at astroj.AstroStackWindow.updatePanelValues(AstroStackWindow.java:5505)
at astroj.AstroStackWindow.setAstroProcessor(AstroStackWindow.java:5465)
at astroj.AstroStackWindow.setAstroProcessor(AstroStackWindow.java:5421)
at Astronomy.Astronomy_Listener.lambda$imageUpdated$0(Astronomy_Listener.java:72)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Reason appears to be the
open(MasterFlatImage);
close("*");
remove this and it appears to work???
Regards
George