Binning a 32-bit stack containing NaN values does not work as expected

Dear all,

I have a stack showing a piece of heart tissue displaying fluorescence. My aim is to calculate the mean intensity along the length of the tissue, but the tissue has varying thickness. Therefore, I thresholded the picture, replacing the background with NaNs, see picture.


Original tiff image: download

Now, if you set a ROI, and calculate the mean intensity, it works well, if the ROI includes NaN pixels, they are ignored and the mean intensity is correct. Great!

However, my aim is to reduce each frame from 279 x 15 to 279 x 1 pixel frame, and subsequently make a montage of all frames in the stack. This would allow me to nicely follow temporal changes in fluorescence, as in this example.

My problem is that if I use the function Transform > Binning (in Fiji), places in the frame that contain NaN values are not correctly averaged, but are set to NaN instead, see picture.

Having looked at the source code of the binning plugin (here), it appears to me that the problem is that the binning plugin converts the pixel value to an integer.

int[ ] pixel = new int[3];
int[ ] sum = new int[3];

Does anyone know a solution to this problem?

Best regards,
Teun de Boer

Good day Teun de Boer,

I’d project the 279x15 slices in y-direction to get 1D functions and make a montage from those. This should work as expected but requires some lines of macro code.

Regards

Herbie