imagej / imagej-matlab

MATLAB integration with ImageJ data structures and runtime.
https://imagej.net/scripting/matlab
BSD 2-Clause "Simplified" License
14 stars 6 forks source link

Consider using the MATLAB Engine API for Java #13

Open ctrueden opened 7 years ago

ctrueden commented 7 years ago

MATLAB 2016b and later have a new MATLAB Engine API for Java which might be better—or at least better supported and more official—than matlabcontrol.

stelfrich commented 7 years ago

I just had a look at the documentation and the examples of the MATLAB Engine w.r.t. to Converters:

// ...
// Get result from the workspace
Future<double[]> futureEval = ml.getVariableAsync("B");
double[] output = futureEval.get();
// ...

We could use that to generate Imgs of narrower types than DoubleType (which is the current status quo).

stelfrich commented 7 years ago

On the other hand, using the Engine API with Maven might not be the most fun project to work on: it is only bundled with MATLAB (http://de.mathworks.com/help/matlab/matlab_external/setup-environment.html).

ctrueden commented 7 years ago

On the other hand, using the Engine API with Maven might not be the most fun project to work on: it is only bundled with MATLAB

We could write a small shell script which does mvn install:install-file on the engine.jar. You'd just need to run the shell script before invoking mvn the first time. Then we can depend on com.mathworks:matlab-engine in the POM. However, it needs to be marked as provided scope, so that downstream code is not infected. Of course, you'd also need to have MATLAB installed on your local machine. But to develop ImageJ-MATLAB you really need to have it anyway, or else you cannot test anything.

Another possible approach would to be create and publish our own matlab-engine-stubs JAR which replicates the entire API, but as no-ops. This is how we solve the dependency on Apple-specific Java APIs, for example. Then it is possible to compile without MATLAB present, but not run unit tests.