Is it possible to add an image to ROI from matlab software? MIJI is running in my matlab

I really need to know if I can add an image to ROI from inside the matlab code not from command window. I mean I want it to be part of my code. MIJI plugin is set in my matlab if that’s helpful.

Hi Zeynab,
there is almost no difference from where you start the code: from the command window or from inside the code (it could be either script or function). In all cases you will use the same Miji functions for data exchange.
The only difference is when used inside a function you will have only local variables that are not seen in the main Matlab workspace, but even that may be tweaked by using global variables or assignin function.


I did not find ROI command in the miji page. and another thing that I dont understand is that how can I link the data that I have in matlab workspace to be transferred to imagej when imagej is called inside the matlab.

I did not find ROI command in the miji page

Miji is only responsible for data exchange between Matlab and Fiji, it does replace Fiji functionality. Considering your ROI command you should probably use function that starts a macro or a command within Fiji.

I dont understand is that how can I link the data that I have in matlab workspace to be transferred to imagej

What do you mean by “link”? Have you checked examples on Miji page (
For example,'Embryos (42K)');
I = MIJ.getCurrentImage;
E = imadjust(wiener2(im2double(I(:,:,1))));
MIJ.createImage('result', E, true);

MIJ.createImage(‘result’, E, true) - sends your image to Fiji from Matlab

1 Like

@Ilya_Belevich as you mentioned “MIJ.createImage(‘result’, E, true) - sends your image to Fiji from Matlab” can matlab have control over the image after sending it to the fiji? I need to have automated code and part of my analysis is on the matlab. After matlab done analysis and send the result to fiji, I need to use fiji plugins to do further analyses. I need to do this for many images and I want to be automated.

you can do that using command. It can start either single Fiji commands or a script with set of functions. It is explained in the documentation:

1 Like

@Ilya_Belevich But Miji does not return to matlab. I need to order from matlab and miji transfer the order from matlab to imagej and returns the result and then the next order from matlab.
But to my understanding, miji is designed to one time transfer from matlab to miji and it is not designed to automate the matlab-fiji connection. Am I right?

no it works in both ways:
for example, get image from Fiji back to Matlab:

img = MIJ.getImage(datasetName);
img = MIJ.getCurrentImage();

you should check the Miji reference:

1 Like

@Ilya_Belevich Thanks for your helps. What I am saying is 1) working automated 2) working interactive I mean back and forth between fiji and matlab 3)communicating not with the image only but with data.
For example a matlab code that can find the edges of an irregular cell and returns the matrix of edges (x and y coordinates) and I need those number to be input in fiji and those edges added to the ROI of that cell. I need all these steps to be done automated. To my understanding MIJI is not designed to do so.

well, I was using Miji mostly for data exchange and this is mostly the purpose of Miji. If you want to get complete interactive functionality you probably have to code everything in Matlab or Fiji.
Is there any specific task that you need Fiji to perform after the cell edges sent to Fiji?

1 Like

Yes I need to find some parameters after in fiji after matlab

Are these parameters product of a special plugin or a basic Fiji functionality?

@Ilya_Belevich Some of them are plugins some are basic Fiji functionality.