Page 1 of 1
Matlab Tutorial
Posted:
Mon Oct 01, 2012 7:43 pm
by ramunno
Hello,
I have a long history in Matlab but I haven't had any luck successfully opening an image from the server, and the information on the website is not very clear. Does anyone have a step by step tutorial, or can point me to the right area of the API?
Thank You,
Damien
Re: Matlab Tutorial
Posted:
Tue Oct 02, 2012 7:50 am
by sbesson
Dear Damien,
With OMERO.matlab-4.4.4-ice33-b3099 installed and after correct initialization of the variables, the code example below should:
1. initiate the toolbox and connect to the server
2. load the image imageID using the ContainerService
3. retrieve the first plane of the image using the RawPixelsStore service
- Code: Select all
server = xxx;
username = xxx;
password = xxx;
imageID = xxx;
% Load the OMERO.matlab toolbox
loadOmero;
% Create a client and a session
client = omero.client(server);
session = client.createSession(username, password);
omeroKeepAlive(client);
% Create a list of image IDs to be retrieved
ids = java.util.ArrayList();
imageId = java.lang.Long(imageID);
ids.add(imageId);
% Load images by IDs using container service
proxy = session.getContainerService();
list = proxy.getImages('omero.model.Image', ids, omero.sys.ParametersI());
image = list.get(0);
% Create raw pixels store to read the planes
pixels = image.getPrimaryPixels();
store = session.createRawPixelsStore();
store.setPixelsId(pixels.getId().getValue(), false);
% Read the first plane and convert it into double matrix
plane = store.getPlane(0, 0, 0);
I = double(toMatrix(plane,pixels)');
Let me know if this works,
Sebastien
Re: Matlab Tutorial
Posted:
Fri Oct 05, 2012 9:21 pm
by ramunno
Hello Sebastien,
Thank you for the help! I am sorry for the delay, my disk encryption at work had a problem and I had to reinstall my OS. I was able to open an image with your commented code. It is a lot more clear now, and now I have a more narrow set of methods I can look at in the API first. (So that I can switch planes, and find the image number, etc.. )
Thanks,
Damien
Re: Matlab Tutorial
Posted:
Fri Mar 07, 2014 2:32 pm
by eberleia
Hi,
I tried to enter the following code in my MATLAB installation (installed on RedHat Linux), but get some error message on the line
list = proxy.getImages('omero.model.Image', ids, omero.sys.ParametersI());
The error message is:
Java exception occurred:
java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Long
at omero.sys.LongListHelper.write(LongListHelper.java:35)
...
at omero.api.IContainerPrxHelper.getImages(IContainerPrxHelper.java.1181)
Is there some change done in the meantime? Should I do it in some other manner?
By the way, the following calls from the documentation do not work:
projects = getProjects(session)
datasets = getDatasets(session)
images = getImages(session)
The error message is Ice.UnmarshalOutOfBoundsException.
Do you have any explanation why this does not work?
Thanks in advance,
Andreas
Re: Matlab Tutorial
Posted:
Fri Mar 07, 2014 3:10 pm
by jmoore
How is 'ids' being set? The error message seems to be saying that there's a double as opposed to a long in there. All image IDs should be java.lang.Long instances.
Cheers,
~Josh
Re: Matlab Tutorial
Posted:
Mon Mar 10, 2014 1:24 pm
by eberleia
Hi,
sorry, but I realized afterwards that we used version 4.4.10 on the server side and version 5 on the client side. After downloading the corrent version, everything worked as expected.
Thanks,
Andreas
Re: Matlab Tutorial
Posted:
Tue Mar 11, 2014 8:22 am
by jmoore
Thanks for letting us know, Andreas.
Cheers,
~Josh