We're Hiring!

Script in Matlab

General and open developer discussion about using OMERO APIs from C++, Java, Python, Matlab and more! Please new questions at https://forum.image.sc/tags/omero
Please note:
Historical discussions about OMERO. Please look for and ask new questions at https://forum.image.sc/tags/omero

If you are having trouble with custom code, please provide a link to a public repository, ideally GitHub.

Script in Matlab

Postby bhcho » Tue Dec 14, 2010 9:17 pm

Hi all,

could any one tell me if it's possible to plug my own Script in OMERO.Insight, which runs matlab functions?
As far as I know, currently, only the python code is callable from the Script. I guess then I need an interface between Python and Matlab to call my matlab function from the Python Script, which I don't know yet.

Or is it possible to call a matlab Script directly? if it's possible, could you give me a snippet?
What I mean is the matlab version of the following code (that the Script in Insight can recognize)
http://trac.openmicroscopy.org.uk/omero/browser/trunk/examples/ScriptingService/Edit_Descriptions.py

Best,
BK
bhcho
 
Posts: 236
Joined: Mon Apr 05, 2010 2:15 pm

Re: Script in Matlab

Postby jmoore » Wed Dec 15, 2010 9:56 am

Hi BK,

it's planned to have matlab code directly executable, but not implemented: https://trac.openmicroscopy.org.uk/omero/ticket/1761

I've added an example of how you might wrap your Matlab code to trunk by passing in a matlab script. See https://trac.openmicroscopy.org.uk/omero/changeset/8754 for the full example. The contents of the script itself are:

Code: Select all
import os
import sys
import platform

import omero
import omero.scripts as scripts

from subprocess import Popen

client = scripts.client('NativeWrapper.py',
    'Example of how to wrap some native call with a script',
    scripts.String("Target", optional=False),
    scripts.Long("Some_Param"))

# In this example, we simply list the file.
# In another context, you would want to join
# the same session that the script is a member
# of and use the values in the context:
#
#   client = omero.client()
#   session = client.createSession()
#   input = session.getInput("Some_Param")
#

if "Windows" == platform.system():
    executable = "dir"
else:
    executable = "ls"

target = client.getInput("Target", unwrap=True)

popen = Popen([executable, target])
sys.exit(popen.wait())


Cheers,
~Josh.
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany


Return to Developer Discussion

Who is online

Users browsing this forum: No registered users and 1 guest