Miji "setTool" command

Hi,

I have recently found the need to use miji to call imageJ functions through a larger Matlab script.
I specifically need to plot a segmented line through a series of pre-designated points and use the straighten tool to straighten the image in question. Although I can open the image perfectly well I can’t run any of the following functions (setTool(“polyline”); makeLine(…)).

Any help of advice to solve this problem would be greatly appreciated.

Many thanks.

@ecdn Are you using the old Miji functionality, or the new ImageJ-MATLAB support?

If you are using Miji, have you tried with ImageJ-MATLAB?

Can you post a short sample script illustrating the issue, along with the error message(s) you receive?

@ctrueden Hi Curtis, thanks for the response.

I get this far:

javaaddpath '/Users/ecdn1g14/Documents/matlab_R2015b_maci64/java/jar/mij.jar’
javaaddpath ‘/Users/ecdn1g14/Documents/matlab_R2015b_maci64/java/jar/ij.jar’

MIJ.start;


MIJ 1.3.9: Matlab to ImageJ Interface

More Info: http://bigwww.epfl.ch/sage/soft/mij/
Help: MIJ.help
JVM> 1.3.9
JVM> Version: 1.7.0_75
JVM> Total amount of memory: 169472 Kb
JVM> Amount of free memory: 35539 Kb
ImageJ> Version:1.50d
ImageJ> Memory:139MB of 469MB (29%)
ImageJ> Directory plugins: Not specified
ImageJ> Directory macros: Not specified
ImageJ> Directory luts: /Users/ecdn1g14/Documents/MATLAB/luts/
ImageJ> Directory image: Not specified
ImageJ> Directory imagej: /Users/ecdn1g14/Documents/MATLAB/
ImageJ> Directory startup: /Users/ecdn1g14/Documents/MATLAB/
ImageJ> Directory home: /Users/ecdn1g14/

Status> ImageJ is running.

MIJ.creatImage(Left_top);
Undefined function or variable ‘creatImage’.

MIJ.createImage(Left_top); %creates the image in imageJ from matlab

%But when i try to either set the selection tool:

MIJ.run(‘setTool’,‘polyline’);

%it gives me the error:

Java exception occurred:
java.lang.RuntimeException: Macro canceled
at ij.IJ.abort(IJ.java:2110)
at ij.IJ.testAbort(IJ.java:361)
at ij.IJ.run(IJ.java:295)
at MIJ.run(MIJ.java:1212)

% or when I try and set the line myself:

MIJ.run(‘makeLine’,’(580,246,725,108,953,452)’);
Java exception occurred:
java.lang.RuntimeException: Macro canceled
at ij.IJ.abort(IJ.java:2110)
at ij.IJ.testAbort(IJ.java:361)
at ij.IJ.run(IJ.java:295)
at MIJ.run(MIJ.java:1212)

If you could offer any help or advice that would be really appreciated!!

many thanks

setTool is not a valid ImageJ command. The MIJ documentation says that MIJ.run “runs a command or macro” but actually, AFAICT, it is just commands.

One way to achieve what you want is to write:

ij.IJ.runMacro('setTool("polyline");');

As an aside, I would recommend using the version of MIJ that is available from the ImageJ-MATLAB update site:

  1. Download Fiji.

  2. Enable the ImageJ-MATLAB update site.

  3. Launch Miji:

    addpath('/Applications/Fiji.app/scripts')
    Miji
    

See the Miji page for further details.

1 Like