IJM.show('I') or net.imagej.matlab.ImageJMATLABCommands.show('I') is a great way to transfer array data from MATLAB workspace to ImageJ, thanks to ImageJ-MATLAB.
However, I’ve noticed that this method does not really support multi-dimentional or multi-channel images well. Whatever the dimensions are, all the channels are treated as a stack of single channel image.
Surely, one can define the syntax based on the dimensions of array I. I think *.ome.tif is using a 5d format. The third, forth, and fifth dimensions can be one of Z, channel, or time.
In addition, whatever data type I can be, ie, uint8, uint16, etc, data type in ImageJ is 32bit per channel. This can also be improved by specifying a rule, I suppose.
This sounds like setting up some convention on how to interpret additional dimensions/axes since MATLAB matrices don’t offer any additional information. One would have to somehow define what the “meaning” of the additional axes is so that a proper conversion to an ImageJ2 Dataset can be achieved. You can take a look at how the conversion is actually done here. I only had a quick look at that, but I assume that the legacy UI does not know how to handle the additional “Page x” axes and falls back to showing them in stack.
I assume you are using ImageJ with the legacy UI. In this case, the imagej-legacy component kicks in to convert the mentioned types to something ImageJ 1.x can display which in many cases is a 32-bit float image. I haven’t tried using ImageJ-MATLAB with the modern UI (you can go to Help > Switch to Modern in the legacy UI to do that), but this should skip the step of conversion and tell you a bit more about the “real” type of the images.
Yes, I think one needs to define a rule, and that’s what I meant.
I = zeros(400,600,10,3,20)
I can probably come up with revision of DefaultImageJMATLABService.java, but I don’t know how to actually develop JAVA code for ImageJ. Learning the environment might take up a lot more of time than actual coding … Does anyone know a good guidance for JAVA coding for ImageJ? How to make modification to exisiting component?
Yes, I never knew there is a new face to ImageJ, and it suprsingly look as old as legecy UI!!!
>> ij.IJ.run("Switch to Modern Mode", "");
>> I = uint8(randi(255,400,400,3));
[INFO] Found 10 JHotDraw adapters.
New UI resulted in even more weird behavior.
It showed up a 32 bit stack image with 3 pages and 64 bit stack image with 3 pages. Why do we need two windows??
Yes, I think so, but it would have to be done carefully to avoid performance hits.
One possible reason to prefer the current state of affairs is that it avoids copying data around. Matlab stores arrays in column major scheme (like Fortran) and ImageJ stores them in a row major scheme.
Looks like XYCZT is the default for ImageJ. (see this)
I can suggest syntaxes like below for IJM.show()
IJM.show('A') % interpret as 'YXCZT'
% flip X and Y by default
% what if A has more than 5 dimensions?
IJM.show('A','CTZ') % specify the 3rd to 5th dimensions
IJM.show('A','XYCTZ') % force XYCTZ order (X and Y are flipped)