ImageJ feature request: Z-projection argmax/argmin

In ImageJ, I’ve found the need recently for determining the index (i.e., slice number) of the maximum value at each [x,y] position in a stack. The use case here is getting predicted labels from a convolutional neural net output. In this case, the prediction usually consists of an x/y/z stack, where at each [x,y] the pixel values along the z-axis give the probabilities of being in the associated classes. The z-projection for the sum is always 1 in this case.

The argmax function in what I’d use in python/numpy to do this, and it would be great to be able to do the same thing in ImageJ.

I think this use case is becoming a lot more common now and would be a very useful (and hopefully straightforward) addition to the “Image/Stacks/Z-project…” menu. Hopefully others (and Wayne Rasband!) will too.

Cheers,
Jon

1 Like

Hi @JonNathan ,

that’s a great idea indeed. In case you need an argmax function urgently, you can give argMaximumZProjection in the clij ImageJ/Fiji plugin a try.

Best,
Robert

2 Likes

Hi Robert,

Thanks, I didn’t know that was function was included as part of the clij project. I’ll give it a whirl!

Cheers,
Jon

1 Like

Hi, What slice number should this procedure return when the maximum value happens in more than one slice?

Hi Gabriel,

I would suggest returning the index of the first occurrence of the maximum value, if it there are multiple instances. This would be consistent with the implementation in numpy.

1 Like

Hello @JonNathan

We made a plugin recently that generates Z-projection, and can return the height-map (Z at which it happens):

Maybe you can use it for your purpose?

2 Likes

Thanks, Jean-Yves – I’ll check that out.

There are evidently lots of implementations of this functionality out there that I missed!

Jon

1 Like

That is called the “blanket transform”. It is described in a paper by Karsten Rodenacker. Can’t remember if he keeps the first or the last slice.
[…]
Ah, no sorry, similar but not the same. The blanket transform is for binary sets.