Re: Stack Aligner does not work in a macro with AstroImageJ V5
Posted by GeorgeF on Mar 30, 2023; 11:02am
URL: http://astroimagej.170.s1.nabble.com/Stack-Aligner-does-not-work-in-a-macro-with-AstroImageJ-V5-tp2180p2198.html
Hi Kevin
No at this point I am opening the FlatImage to read some fo the stats from the file.
I then close it - in fact my latest test shows astroimagej hanging at this point now - if run the macro installed it sometimes works other time not.
my simplest test macro looks like this
CalEntry = "path to a folder with wcs images 32 bit";
print ("Calibration directory " + CalEntry);
MasterFlats = "path to a single 32 bit fits image no wcs";
open(MasterFlatImage);
close("*");
file = CalEntry;
list = getFileList(CalEntry);
i = list.length;
// these are just to we are got to this point!
print ("Loading Sequence");
print ("Sequence File " + file);
run("Image Sequence...", "open=&file number=i starting=1 increment=1 scale=100 file=[] or=[] sort");
// I have preset that stack aligning will be done by WCS
call("ij.Prefs.set","stackAligner.useWCSOnly","true");
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");
end of test macro
Key question is where does it fail?
I have had failures in my latest tests astroimagej hanging at the close("*"); statement and at the stack aligner statement
BUT if I remove the open and close of that file it works - Stack Aligner does its thing.
Checking the macro functions on ImageJ site for open and close
open(path)
Opens and displays a tiff, dicom, fits, pgm, jpeg, bmp, gif, lut, roi, or text file. Displays an error message and aborts the macro if the specified file is not in one of the supported formats, or if the file is not found. Displays a file open dialog box if path is an empty string or if there is no argument. Use the File>Open command with the command recorder running to generate calls to this function. With 1.41k or later, opens images specified by a URL, for example open("../../images/clown.gif"). With 1.49v or later, opens a folder of images as a stack. Use open("path/to/folder","virtual") to open a folder of images as a virtual stack.
Another difference between V3.4 and V5.2 is the version of ImageJ - is the single file in a stack not just an image window and does this make a difference to the close("*") function?
Interestingly this is the only time in the full macro where I use this open command to open an image file!
Time for some research on the imagej forum as well?
However I think Stack Aligner needs to check for a NULL imp pointer to catch this exception and work out a recovery or present a clear failure message?
Regards
George