We're Hiring!

Interacting with Matlab

General user discussion about using the OMERO platform to its fullest. Please ask 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

There are workflow guides for various OMERO functions on our help site - http://help.openmicroscopy.org

You should find answers to any basic questions about using the clients there.

Interacting with Matlab

Postby sdrulhe » Fri Mar 04, 2011 6:48 pm

Dear CoUsers,
Could anyone post a basic Matlab script to interact with OME.server ? Something about:
- import or retrieve images from a given given data set, and a given project, stored on a given server?
- for the import : how to specify metadata
- for the retrieval : how to also retrieve time, channel, etc...
I would appreciate a lot for a helping hand :)
Yours,
S D
User avatar
sdrulhe
 
Posts: 4
Joined: Fri Mar 04, 2011 6:36 pm

Re: Interacting with Matlab

Postby jmoore » Mon Mar 07, 2011 6:31 pm

Hi S D,

for a very simple matlab example you might start by looking at Main.m under the examples. For importing, you will either need to use the GUI client, the CLI client, or the library. You can read more under http://trac.openmicroscopy.org.uk/ome/wiki/ImportLibrary.

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

Re: Interacting with Matlab

Postby sdrulhe » Sat Mar 12, 2011 8:45 pm

Thanks.
Question: in Insight, I can choose the group I am working with on a given server. I don't see how to select this from a Matlab point of view. it seems that I can just connect to the last group I was working with under Insight...
Code: Select all
loadOmero;
client = omero.client(serverName, serverPort);
session = client.createSession(userID,userPwd);
gateway = session.createGateway;
User avatar
sdrulhe
 
Posts: 4
Joined: Fri Mar 04, 2011 6:36 pm

Re: Interacting with Matlab

Postby jmoore » Mon Mar 14, 2011 8:41 am

sdrulhe wrote:Thanks.

Sure, no problem.

Question: in Insight, I can choose the group I am working with on a given server. I don't see how to select this from a Matlab point of view. it seems that I can just connect to the last group I was working with under Insight...
Code: Select all
loadOmero;
client = omero.client(serverName, serverPort);
session = client.createSession(userID,userPwd);
gateway = session.createGateway;


If you are working from the develop or dev_4_2 branches of git, or from any of the recent "trunk" or "4.2" builds from Hudson, then you can set the group by passing the "omero.group" property to omero.client:
Code: Select all
   p = java.util.Properties();
   p.setProperty('omero.host', 'example.com');
   p.setProperty('omero.user', 'me');
   p.setProperty('omero.pass', 'super_secret!');
   p.setProperty('omero.group', 'my-group');
   c = loadOmero(p);

If you are working from the released 4.2 version, that will not be possible due to a bug (#2951), and instead you will have to use setSecurityContext:
Code: Select all
client = omero.client(serverName, serverPort);
session = client.createSession(userID,userPwd);
session.setSecurityContext(omero.model.ExperimenterGroupI(GROUP_ID_HERE, false));
gateway = session.createGateway;


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

Re: Interacting with Matlab

Postby sdrulhe » Mon Mar 14, 2011 12:50 pm

Great...
I am working with the last release:
Code: Select all
>> disp(omeroVersion);
4.3.0-DEV-956e9264

The second method gives the following result:
Code: Select all
??? No constructor 'omero.model.ExperimenterGroupI' with matching signature found.

Error in ==> OMEtemplatescript at 18
session.setSecurityContext(omero.model.ExperimenterGroupI(groupID, false));

This works:
Code: Select all
p = java.util.Properties();
p.setProperty('omero.host', serverName);
%p.setProperty('omero.port', serverPort);
p.setProperty('omero.user', userID);
p.setProperty('omero.pass', userPwd);
p.setProperty('omero.group', groupID);
[client,session,gateway] = loadOmero(p);
clear p

I did not find how to setup the server port, nor where to look for this... My attempt to define an omero.port failed. :)
User avatar
sdrulhe
 
Posts: 4
Joined: Fri Mar 04, 2011 6:36 pm

Re: Interacting with Matlab

Postby jmoore » Mon Mar 14, 2011 4:07 pm

sdrulhe wrote:The second method gives the following result:
Code: Select all
??? No constructor 'omero.model.ExperimenterGroupI' with matching signature found.

Error in ==> OMEtemplatescript at 18
session.setSecurityContext(omero.model.ExperimenterGroupI(groupID, false));


What's the type of groupID? If it's omero.rtypes.rlong, you'll need to unwrap it:
Code: Select all
>> loadOmero
--------------------------
OmeroMatlab Toolbox
4.3.0-DEV-808325d1
--------------------------
>> omero.model.ExperimenterGroupI(1, false)

ans =

omero.model.ExperimenterGroupI@1aaa2594

>> groupID = omero.rtypes.rlong(1)

groupID =

omero.rtypes$RLongI@1

>> omero.model.ExperimenterGroupI(groupID.getValue(), false)

ans =

omero.model.ExperimenterGroupI@626f144
>>


This works:
Code: Select all
p = java.util.Properties();
p.setProperty('omero.host', serverName);
%p.setProperty('omero.port', serverPort);
p.setProperty('omero.user', userID);
p.setProperty('omero.pass', userPwd);
p.setProperty('omero.group', groupID);
[client,session,gateway] = loadOmero(p);
clear p

I did not find how to setup the server port, nor where to look for this... My attempt to define an omero.port failed. :)

I'd assume it's a similar issue with the type. Could you try converting serverPort to a string?

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

Re: Interacting with Matlab

Postby sdrulhe » Tue Mar 15, 2011 12:50 am

What's the type of groupID? If it's omero.rtypes.rlong, you'll need to unwrap it

The type is Matlab string. Don't get how to make it be omero.rtypes.rlong if it is what I need to do.
I'd assume it's a similar issue with the type. Could you try converting serverPort to a string?

Exact, well done!
Now it works perfectly, thanks! :D
User avatar
sdrulhe
 
Posts: 4
Joined: Fri Mar 04, 2011 6:36 pm

Re: Interacting with Matlab

Postby jmoore » Tue Mar 15, 2011 7:23 am

sdrulhe wrote:
What's the type of groupID? If it's omero.rtypes.rlong, you'll need to unwrap it

The type is Matlab string. Don't get how to make it be omero.rtypes.rlong if it is what I need to do.

Ah, ok. No, the type should be long or java.lang.Long. So, java.lang.Long.valueOf() or similar should work.

I'd assume it's a similar issue with the type. Could you try converting serverPort to a string?

Exact, well done!
Now it works perfectly, thanks! :D

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


Return to User Discussion

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron