Using mapla app for hyperspectral unmixing of 3d tif stacks

Hello, I am a first time user of this toolbox for the purpose of unmixing some fluorescence images.

I have 2 8-bit tif stacks each of dimension [512, 512, 32] where 32 is the number of slices. They come from different channel wavelengths. I’d like to know how to use this toolbox to unmix each of these stacks (because it is believed that each channel has some infra signals that need to be separated).

In the documentation, the input image is said to have the dimension l*n where n is the number of channels. So, should i reshape the tif files as [512,512,32,2] ?

I tried to make a hyperstack using ImageJ with each of the image stacks above. Choosing 512 mb as RAM, i click ‘execute’ on the EndmemberNumberEstimation page of montevardi application. The end members estimates comes up as 1 with “virtual dimensionality” algorithm. Next, i select the VertexComponentAnalysis" and run it with the hyperstack. This gives the error: : Invalid Matrix size. Number of columns must be the same as the image number of channels.

Can someone please tell me how to use this app with the above image stacks ?

Platform: Windows 10, Orfeo toolbox 7.2.0

Dear @akatav,

Thank you for using OTB. I hope we will figure out how to unmix your images.

Since you have 2 image files for the same scene, I think you should first stack them together using the ConcatenateImages application. This will output a [512, 512, 64] image that you can then use as input of the EndmemberNumberEstimation and VertexComponentAnalysis applications.

I hope this help.

1 Like

@julienosman thanks for your kind reply.

Yes, i have 2 image stacks where each slice in the stack records the same area of the brain (in the z-axis).
For example, let image1 have 2 slices and image2 have 2 slices. image1(1) and image2(1) image the same area of the brain. image1(2) and image2(2) image a different area of the brain (at a lower depth of the brain). In my case, there are 32 slices in each image.

I tried the “ConcatenateImages” application. The concatenated image has only 2 slices. As explained above, since each slice records a deeper area of the brain, i think in my case, the concatenated image must have 64 slices like you have mentioned.

I tried to concatenate images using ImageJ and got a 512-by-512-by-64 image stack. On calling VertexComponentAnalysis on this stack, i get the same error: 2021-04-13 13:51:25 (FATAL) VertexComponentAnalysis: itk::ERROR: MatrixImageFilter(00000257E3758480): Invalid Matrix size. Number of columns must be the same as the image number of channels.

If I understand well, you want to unmixe image1(1) with image2(1), and then image1(2) with image2(2), and then … image1(i) with image2(i) ?
So you need to run the unmixing 32 times, once for each pair of slice. One solution is to run the application with the concatenated image generated previously, and use the extended filename band. So in mapla, you can write as Input Image : concatenated_image.tif?&bands=1,33 to processe image1(1) with image2(1).
More generally, you can write as Input Image : concatenated_image.tif?&bands=i,32+i to processe image1(i) with image2(i).

1 Like

Hi @julienosman thank you again for replying. yes, i think so. Basically the same area of the brain is imaged in 2 different wavelengths (channels).
I tried the above on cmd (admin mode):

otbcli_ConcatenateImages -out "C:\Users\myfolder\Downloads\out.tif" -il "G:\images\ConcatenatedImagesWith64frames.tif?bands=1,33"

This gives “Cannot open image/file does not exist” error. It is not able to recognize the part after ‘?’ i think.

I tried without the “…” and got the following error:

File … will be written in 1 blocks of 512x512 pixels
Writing …tif…: 100% [**************************************************] (1s)
‘bands’ is not recognized as an internal or external command,
operable program or batch file.

Try with otbcli_ConcatenateImages -out "C:\Users\myfolder\Downloads\out.tif" -il "G:\images\ConcatenatedImagesWith64frames.tif?&bands=1,33"
the & is mandatory.

1 Like

@julienosman thank you again. Yes, i tried as follows also:

otbcli_ConcatenateImages -out "C:\Users\....\out.tif" -il "G:\images\ConcatenatedImagesWith64frames.tif?&bands=1,33"

Gives the error:

ConcatenateImages: itk::ERROR: ExtendedFilenameToReaderOptions(000001BFA7129D20): Invalid band number.

The file is a tif stack. Should it be a hyperstack of some sort ? Also, i find that though there are 64 frames, as to the bands, band=0 and band=1 work. From band>1, the “invalid band number” error happens.

and also

otbcli_ConcatenateImages -out "C:\Users\....\out.tif" -il "G:\images\ConcatenatedImagesWith64frames.tif?&bands=1,33"
which gives the “file does not exist” error.

I tried: i,32+i

This gives the error:

(FATAL) ConcatenateImages: itk::ERROR: ExtendedFilenameToReaderOptions(0000024C07EDB330): Unkwown value i,32+i for band range. Expect a list of tokens separated with comma (each token being a single band index or a range in the form x:y)

Perhaps, can you kindly post a demo video of this sort of task. Because, maybe i am doing something wrong (with regards, concatenation of 2 different channels).

Dear @akatav,
I think I misunderstood the format of your input images. I thought you had a 2D image with 32 bands. But it seems you are working with a 3D image. I am not sure how OTB deals with that kind of data. Could you please share with us the output of:

otbcli_ReadImageInfo -in ImageWith32frames.tif

1 Like