0
votes

i have a problem getting the filename from an image stack in ImageJ. I wrote a plugin that can be used on image stacks and gives an output result for every image in the stack with:

if (mfpc == true) {
            IJ.log(fileName+": Good");
        } else {
            IJ.log(fileName+": Bad");
        }

getTitle() works for single images, but only shows the Stack-Name for stacks, not the name of the actual slice.

i also tried to get the slice name with the following code

fileName = imp.getImageStack().getShortSliceLabel(imp.getCurrentSlice());

but it only shows the currently chosen picture, not the picture which is handled by the plugin. My wishful thinking is the following output (while the filename is Imagex.png):

  • Image1.png: Good
  • Image2.png: Bad
  • Image3.png: Good

Is that possible and if so, how? :)

2

2 Answers

0
votes

A dirty way to tackle the problem : run Stack to Images, stock all names in an array, close all images, open your stack again.

Here is a code snippet in the ImageJ macro language :

setBatchMode(true);

open("your_stack.tif")

n=nSlices;
titles=newArray(n);

run("Stack to Images");

// for every image (slice of the stack)
for(cpt=0;cpt<n;cpt++){
    titles[cpt]=getTitle(); //get its title
    close(); //then close it so focus goes to the next image
}

Array.print(titles);
0
votes

You can get the slice name by using the command getInfo("slice.label");