Accept Gateway objects in all functions #5
https://github.com/ome/omero-matlab/issues/5
Following the example code shown in the above URL, I tried to use Java gateway from MATLAB.
- Code: Select all
client = loadOmero(host, port) % this adds OMERO Java jar files to Java class paths
d = javaclasspath
d =
{'xxxxxxx\OMERO-matlab\libs\omero_client.jar'}
{'xxxxxxx\OMERO-matlab\libs\guava.jar' }
{'xxxxxxx\OMERO-matlab\libs' }
- Code: Select all
cred = omero.gateway.LoginCredentials(userName, password, host, port);
simpleLogger = omero.log.SimpleLogger();
gateway = omero.gateway.Gateway(simpleLogger);
user = gateway.connect(cred);
The above attempt ends up in the following execution error.
- Code: Select all
'connect' requires one of the following:
Control System Toolbox
Instrument Control Toolbox
OPC Toolbox
Robotics System Toolbox
Vehicle Network Toolbox
This implies that the method 'connect' of 'gateway' is not visible to MATLAB. Indeed, if I try to get the list of Java methods of the 'gateway' object, it issues a Java error, complaining that `loci/formats/meta/MetadataStore` is not found.
- Code: Select all
methods(gateway)
Warning: A Java exception occurred getting the method description for the omero.gateway.Gateway class:
Java exception occurred:
java.lang.NoClassDefFoundError: loci/formats/meta/MetadataStore
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at com.mathworks.jmi.CustomURLClassLoader.findClass(ClassLoaderManager.java:760)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetPublicMethods(Unknown Source)
at java.lang.Class.getMethods(Unknown Source)
at com.mathworks.jmi.OpaqueJavaInterface.getMethodDescriptions(OpaqueJavaInterface.java:278)
Caused by: java.lang.ClassNotFoundException: loci.formats.meta.MetadataStore
at java.net.URLClassLoader.findClass(Unknown Source)
at com.mathworks.jmi.CustomURLClassLoader.findClass(ClassLoaderManager.java:760)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 17 more
Solution
Install Bioformats-MATLAB toolbox and run
- Code: Select all
`bfCheckJavaPath();`
to add java class paths for Bioformats, which include `loci.meta`.
Then
- Code: Select all
user = gateway.connect(cred);
- Code: Select all
user =
omero.gateway.model.ExperimenterData (id=2)
Now we can think of the implementation of Java gateway, for example for `getPanelInfo.m`
If you guys can suggest a proper Java code for the operation needed for `getPanelInfo.m` using `gateway`, I might be able to translate that into MATLAB, though I can't promise.
Once we figure out one example, the rest of MATLAB functions may work in a similar way, I hope.