Login  Register

Re: an odd image ID problem

Posted by Cardone, Giovanni on Oct 06, 2017; 8:00am
URL: http://imagej.273.s1.nabble.com/an-odd-image-ID-problem-tp5019502p5019507.html

Hi Jeremy,

I could reproduce the issue, and I pinpointed the problem to the "Stack to Images" command.
I simplified your example, to show that after the second call to "stack to Images" the active Image is the last one generated by the first call, which to me is an unwanted behavior.
Hopefully this will help to find the problem in the code.

Best,
Giovanni


run("Close All");
print("\\Clear");

newImage("OriginalStack", "32-bit ramp", 64, 32, 3);
origStackID=getImageID();
print("origStackID ",origStackID);
print(" - conveting stack to images");
run("Stack to Images");
afterStacktoIm3ID=getImageID();// current image
currentTitle=getTitle();
print("active image after first stack-to-images: Title: ",currentTitle," ID: ",afterStacktoIm3ID);

print(" ");
newImage("NewOriginalStack", "32-bit ramp", 64, 32, 4);
NeworigStackID=getImageID();
print("NeworigStackID ",NeworigStackID);
print(" - conveting new stack to images");
run("Stack to Images");
afterSecondStacktoIm3ID=getImageID();// current image
currentTitle=getTitle();
print("active image after second stack-to-images: Title: ",currentTitle," currentID ",afterSecondStacktoIm3ID);


-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Jeremy Adler
Sent: Donnerstag, 5. Oktober 2017 10:06
To: [hidden email]
Subject: an odd image ID problem


A small problem with the IDs of images or maybe my assumption that the last created image is the current image.

The macro code creates a stack of 3 images then splits the stack.
The IDs of the 3 daughter images are obtained by finding the ID of the top image (3rd and last image in the stack).
This is  as it should be.

But (second block of code) when I duplicate the stack before splitting the stack, the duplicate stack gets the expected ID.
But after splitting the stack the IDs of the daughter images are reported incorrectly.
The problem seems to be that although the final 3rd image in the stack is still the top image, when I check the current ID and title are those of the original stack.

What am I missing ?

run("Close All");
print("\\Clear");

newImage("OriginalStack", "32-bit ramp", 64, 32, 3); origStackID=getImageID();print("origStackID ",origStackID); run("Stack to Images");
print("   stack-images");
afterStacktoIm3ID=getImageID();// current image currentTitle=getTitle();print("after stack-images: current Title: ",currentTitle," ID ",afterStacktoIm3ID); after2ID=afterStacktoIm3ID+1;// 2nd image from stack after1ID=afterStacktoIm3ID+2;// 2nd image from stack/ print("IDs  orig ",origStackID," after stack-images ",afterStacktoIm3ID,after2ID,after1ID);
selectImage(after2ID);

print(" ");
print("      repeat but include image duplication");
newImage("NewOriginalStack", "32-bit ramp", 64, 32, 3); NeworigStackID=getImageID();print("NeworigStackID ",NeworigStackID); run("Duplicate...", "duplicate"); DupImageID=getImageID(); print("ID of  duplicate ",DupImageID); run("Stack to Images");
print("   stack-images");
afterStacktoIm3ID=getImageID();// current image currentTitle=getTitle();print("after stack-images: current Title: ",currentTitle," currentID ",afterStacktoIm3ID); after2ID=afterStacktoIm3ID+1;// 2nd image from stack after1ID=afterStacktoIm3ID+2;// 2nd image from stack/ print("IDs  orig ",origStackID," after stack-images ",afterStacktoIm3ID,after2ID,after1ID);
selectImage(after2ID);

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html