• Views
  • Iteration Report
  • My Iteration Report
  •  
OMERO.server
  • Login
  • Help/Guide
  • About Trac
  • Preferences
  • Wiki
  • Timeline
  • Roadmap
  • Browse Source
  • View Tickets
  • Search

Context Navigation

  • Start Page
  • Index
  • History
  • Last Change

Table of Contents

  1. BETA 3.2
  2. Installing the OMERO gateway for Matlab
  3. Compiling OMERO Gateway
    1. OMERO Gateway Dependancies
  4. Creating a connection using OMERO Gateway in Java
  5. The Gateway Methods
    1. Connection Methods
    2. Data Service Methods
    3. Image Service Methods
    4. File Service Methods
    5. Helper Methods
  6. Matlab Helper methods
  7. Examples in Matlab using OMEROJava
    1. Retrieve all current user Projects, and get Images in datasets
    2. Simple Image Viewer
    3. Perform Projection on z-Stack
  8. BETA 4.0
    1. Installing the new Gateway
    2. Examples using the new gateway and GatewayUtils

A Matlab interface to OMERO.blitz

OMERO Gateway is in a state of flux, please be aware that the code is changing alot.

Omero provides a mechanism to access the OMERO.blitz server from Matlab. The interface provides a java gateway to OMERO.blitz which can be accessed from Matlab.

BETA 3.2

Installing the OMERO gateway for Matlab

To install the OMERO gateway you will need to compile the OMERO gateway in the omero/components/blitz directory (see Compiling OMERO Gateway), or the Blitz-3.0-Beta3.jar from ~/omero/dist/client created when compiling the server. The resulting jar should be copied into the libs (MatlabDir/java/libs) directory of Matlab with all the dependent libs(see Compiling The OMERO Gateway, subsection OMEROJava dependancies). The path to the newly added jars should be added to the class path file (MatlabDir/local/toolbox/classpath.txt).

Compiling OMERO Gateway

The OMERO Gateway will be compiled as part of the OMERO.blitz build and the resulting jar, Blitz-3.0-Beta3.jar will be created in the OMERODir/dist/client directory.

OMERO Gateway Dependancies

The OMERO Gateway consists of 3 files which are located in the /dist/client directory once the OMERO.blitz server has been built. These files are

  • ice-3.2.0.jar
  • model-psql-3.0-Beta3.jar

Creating a connection using OMERO Gateway in Java

The OMERO gateway provides methods to access the OMERO.blitz server, many of the methods are helper methods which provide extra functionality so that using the OMERO.blitz server does not require understanding of the data model, or server services.

To create a connection to the server we need to create a client object, and a session and then ask to create a gateway object.

client = omero.client('hostname');
session = client.createSession('username','password');
gateway = session.createGateway();

For further information on the connecting to OMERO see [wiki OmeroJava]

The Gateway Methods

The following are a list of methods provided by OMERO Gateway.

Connection Methods

These methods create and maintain connections to the OMERO.blitz server.

Method Detail

isClosed

public boolean isClosed()
Is the session closed?

Returns:
true if closed.


close

public void close()
Close the session with the server.


createSession

public void createSession(java.lang.String username,
                          java.lang.String password)
                   throws DSOutOfServiceException,
                          DSAccessException
Open a session to the server with username and password.

Parameters:
username - see above.
password - see above.
Throws:
DSOutOfServiceException
DSAccessException

keepAlive

public void keepAlive()
               throws DSOutOfServiceException,
                      DSAccessException
Keep service alive.

Throws:
DSOutOfServiceException
DSAccessException


Data Service Methods

These methods work with the data in the server but not on the images or file directly, for instance, methods in the data service will work with project->dataset->image objects.

Method Detail

getProjects

public java.util.List<Project> getProjects(java.util.List<java.lang.Long> ids,
                                           boolean withLeaves)
                                    throws DSOutOfServiceException,
                                           DSAccessException
Get the projects, and datasets in the OMERO.Blitz server in the user account.

Parameters:
ids - user ids to get the projects from, if null will retrieve all projects from the users account.
withLeaves - get the projects, images and pixels too.
Returns:
see above.
Throws:
DSOutOfServiceException
DSAccessException


getDatasets

public java.util.List<Dataset> getDatasets(java.util.List<java.lang.Long> ids,
                                           boolean withLeaves)
                                    throws DSOutOfServiceException,
                                           DSAccessException
Get the datasets in the OMERO.Blitz server in the projects ids.

Parameters:
ids - of the datasets to retrieve, if null get all users datasets.
withLeaves - get the images and pixels too.
Returns:
see above.
Throws:
DSOutOfServiceException
DSAccessException


getPixelsFromImage

public java.util.List<Pixels> getPixelsFromImage(long imageId)
                                          throws DSOutOfServiceException,
                                                 DSAccessException
Get the pixels associated with the image, this is normally one pixels per image, but can be more.

Parameters:
imageId -
Returns:
the list of pixels.
Throws:
DSOutOfServiceException
DSAccessException


getImage

public Image getImage(long id)
               throws DSOutOfServiceException,
                      DSAccessException
Get the image with id

Parameters:
id - see above
Returns:
see above.
Throws:
DSOutOfServiceException
DSAccessException


getImages

public java.util.List<Image> getImages(OMEROClass parentType,
                                       java.util.List<java.lang.Long> ids)
                                throws DSOutOfServiceException,
                                       DSAccessException
Get the images in the OMERO.Blitz server from the object parentType with id's in list ids.

Parameters:
parentType - see above.
ids - see above.
Returns:
see above.
Throws:
DSOutOfServiceException
DSAccessException


findAllByQuery

public java.lang.Object findAllByQuery(java.lang.String myQuery)
                                throws DSOutOfServiceException,
                                       DSAccessException
Run the query passed as a string in the iQuery interface. This method will return list of objects.

Parameters:
myQuery - string containing the query.
Returns:
the result.
Throws:
DSOutOfServiceException
DSAccessException


findByQuery

public java.lang.Object findByQuery(java.lang.String myQuery)
                             throws DSOutOfServiceException,
                                    DSAccessException
Run the query passed as a string in the iQuery interface. The method expects to return only one result from the query, if more than one result is to be returned the method will throw an exception.

Parameters:
myQuery - string containing the query.
Returns:
the result.
Throws:
DSOutOfServiceException
DSAccessException



getPixels

public Pixels getPixels(long pixelsId)
                 throws DSOutOfServiceException,
                        DSAccessException
Get the pixels information for an image, this method will also attach the logical channels, channels, and other metadata in the pixels.

Parameters:
pixelsId - image id relating to the pixels.
Returns:
see above.
Throws:
DSAccessException
DSOutOfServiceException
DSOutOfServiceException
DSAccessException


copyPixels

public long copyPixels(long pixelsID,
                       int x,
                       int y,
                       int t,
                       int z,
                       java.util.List<java.lang.Integer> channelList,
                       java.lang.String methodology)
                throws DSOutOfServiceException,
                       DSAccessException
Copy the pixels to a new pixels, this is only the data object and does not create a pixels object in the RawPixelsStore, To load data into the plane the uploadPlane(long, int, int, int, double[][]) to add data to the pixels.

Parameters:
pixelsID - pixels id to copy.
x - width of plane.
y - height of plane.
t - num timepoints
z - num zsections.
channelList - the list of channels to copy, this is the channel index.
methodology - user supplied text, describing the methods that created the pixels.
Returns:
new id.
Throws:
DSOutOfServiceException
DSAccessException


copyImage

public long copyImage(long imageId,
                      int x,
                      int y,
                      int t,
                      int z,
                      java.util.List<java.lang.Integer> channelList,
                      java.lang.String imageName)
               throws DSOutOfServiceException,
                      DSAccessException
Copy the image and it's attached pixels and metadata to a new Image and return the id of the new image. The method will not copy annotations or attachments.

Parameters:
imageId - image id to copy.
x - width of plane.
y - height of plane.
t - The number of time-points
z - The number of zSections.
channelList - the list of channels to copy, [0-(sizeC-1)].
imageName - The new imageName.
Returns:
new id.
Throws:
DSOutOfServiceException
DSAccessException


updatePixels

public Pixels updatePixels(Pixels object)
                    throws DSOutOfServiceException,
                           DSAccessException
Update the pixels object on the server, updating appropriate tables in the database and returning a new copy of the pixels.

Parameters:
object - see above.
Returns:
the new updated pixels.
Throws:
DSOutOfServiceException
DSAccessException


getPixelTypes

public java.util.List<PixelsType> getPixelTypes()
                                         throws DSOutOfServiceException,
                                                DSAccessException
Get a list of all the possible pixelsTypes in the server.

Returns:
see above.
Throws:
DSOutOfServiceException
DSAccessException


getPixelType


public PixelsType getPixelType(java.lang.String type)
                        throws DSOutOfServiceException,
                               DSAccessException
Get the pixelsType for type of name type.

Parameters:
type - see above.
Returns:
see above.
Throws:
DSOutOfServiceException
DSAccessException


attachImageToDataset

public void attachImageToDataset(Dataset dataset,
                                 Image image)
                          throws DSOutOfServiceException,
                                 DSAccessException
Attach an image to a dataset.

Parameters:
dataset - see above.
image - see above.
Throws:
DSOutOfServiceException
DSAccessException


createImage

public long createImage(int sizeX,
                        int sizeY,
                        int sizeZ,
                        int sizeT,
                        java.util.List<java.lang.Integer> channelList,
                        PixelsType pixelsType,
                        java.lang.String name,
                        java.lang.String description)
                 throws DSOutOfServiceException,
                        DSAccessException
Create a new Image of X,Y, and zSections+time-points. The channelList is the emission wavelength of the channel and the pixelsType.

Parameters:
sizeX - width of plane.
sizeY - height of plane.
sizeZ - num zSections.
sizeT - num time-points
channelList - the list of channels to copy.
pixelsType - the type of pixels in the image.
name - the image name.
description - the description of the image.
Returns:
new id.
Throws:
DSOutOfServiceException
DSAccessException


getImageFromDatasetByName

public java.util.List<Image> getImageFromDatasetByName(long datasetId,
                                                       java.lang.String imageName)
                                                throws DSOutOfServiceException,
                                                       DSAccessException
Get the images from the dataset with name, this can use wild cards.

Parameters:
datasetId - see above.
imageName - see above.
Returns:
see above.
Throws:
DSOutOfServiceException
DSAccessException


getImageByName

public java.util.List<Image> getImageByName(java.lang.String imageName)
                                     throws DSOutOfServiceException,
                                            DSAccessException
Get the list of images with name containing imageName.

Parameters:
imageName - see above.
Returns:
see above.
Throws:
DSOutOfServiceException
DSAccessException


saveObject

public void saveObject(IObject obj)
                throws DSOutOfServiceException,
                       DSAccessException
Save the object to the db .

Parameters:
obj - see above.
Throws:
DSOutOfServiceException
DSAccessException


saveAndReturnObject

public IObject saveAndReturnObject(IObject obj)
                            throws DSOutOfServiceException,
                                   DSAccessException
Save and return the Object.

Parameters:
obj - see above.
Returns:
see above.
Throws:
DSOutOfServiceException
DSAccessException


saveArray

public void saveArray(java.util.List<IObject> graph)
               throws DSOutOfServiceException,
                      DSAccessException
Save the array.

Parameters:
graph - see above.
Throws:
DSOutOfServiceException
DSAccessException


saveAndReturnArray

public <T extends omero.model.IObject> java.util.List<T> saveAndReturnArray(java.util.List<IObject> graph)
                                                                 throws DSOutOfServiceException,
                                                                        DSAccessException
Save and return the array.

Type Parameters:
T - The Type to return.
Parameters:
graph - the object
Returns:
see above.
Throws:
DSOutOfServiceException
DSAccessException


deleteObject

public void deleteObject(IObject row)
                  throws DSOutOfServiceException,
                         DSAccessException
Delete the object.

Parameters:
row - the object.(commonly a row in db)
Throws:
DSOutOfServiceException
DSAccessException



Image Service Methods

These methods manage the interactions with images on the server, creating, copying, uploading and retrieving.

Method Detail

getPlane

public double[][] getPlane(long pixelsId,
                           int z,
                           int c,
                           int t)
                    throws DSOutOfServiceException,
                           DSAccessException
Get the raw plane for the pixels pixelsId, this returns a 2d array representing the plane, it returns doubles but will not lose data.

Parameters:
pixelsId - id of the pixels to retrieve.
c - the channel of the pixels to retrieve.
t - the time point to retrieve.
z - the z section to retrieve.
Returns:
The raw plane in 2-d array of doubles.
Throws:
DSAccessException
DSOutOfServiceException


getPlane

public double[][][] getPlaneStack(long pixelsId,
                           int c,
                           int t)
                    throws DSOutOfServiceException,
                           DSAccessException
Get the zSection stack containing all the planes for the pixels pixelsId, this returns a 3d array representing the z-Stack of the plane for channel c and timepoint t, it returns doubles but will not lose data.

Parameters:
pixelsId - id of the pixels to retrieve.
c - the channel of the pixels to retrieve.
t - the time point to retrieve.
Returns:
The raw plane in 3-d array of doubles.
Throws:
DSAccessException
DSOutOfServiceException


getRenderedImage

public java.awt.image.BufferedImage getRenderedImage(long pixelsId,
                                                     int z,
                                                     int t)
                                              throws DSOutOfServiceException,
                                                     DSAccessException
Render the pixels for the zSection z and timePoint t.

Parameters:
pixelsId - pixels id of the plane to render
z - z section to render
t - timepoint to render
Returns:
The image as a buffered image.
Throws:
DSOutOfServiceException
DSAccessException


getRenderedImageMatrix

public int[][][] getRenderedImageMatrix(long pixelsId,
                                        int z,
                                        int t)
                                 throws DSOutOfServiceException,
                                        DSAccessException
Render the pixels for the zSection z and timePoint t.

Parameters:
pixelsId - pixels id of the plane to render
z - z section to render
t - timepoint to render
Returns:
The image as a 3d array where it represents the image as [x][y][channel]
Throws:
DSOutOfServiceException
DSAccessException


renderAsPackedInt

public int[] renderAsPackedInt(long pixelsId,

                               int z,
                               int t)
                        throws DSOutOfServiceException,
                               DSAccessException
Render the pixels for the zSection z and timePoint t.

Parameters:
pixelsId - pixels id of the plane to render
z - z section to render
t - timepoint to render
Returns:
The pixels are returned as 4 bytes representing the r,g,b,a of image.
Throws:
DSOutOfServiceException
DSAccessException


setActive

public void setActive(long pixelsId,
                      int w,
                      boolean active)
               throws DSOutOfServiceException,
                      DSAccessException
Set the active channels to be on or off in the rendering engine for the pixels.

Parameters:
pixelsId - the pixels id.
w - the channel
active - set active?
Throws:
DSOutOfServiceException
DSAccessException


isActive

public boolean isActive(long pixelsId,
                        int w)
                 throws DSOutOfServiceException,
                        DSAccessException
Is the channel active, turned on in the rendering engine.

Parameters:
pixelsId - the pixels id.
w - channel
Returns:
true if the channel active.
Throws:
DSOutOfServiceException
DSAccessException


getDefaultZ

public int getDefaultZ(long pixelsId)
                throws DSOutOfServiceException,
                       DSAccessException
Get the default zSection of the image, this is the zSection the image should open on when an image viewer is loaded.

Parameters:
pixelsId - the pixelsId of the image.
Returns:
see above.
Throws:
DSOutOfServiceException
DSAccessException


getDefaultT

public int getDefaultT(long pixelsId)
                throws DSOutOfServiceException,
                       DSAccessException
Get the default time-point of the image, this is the time-point the image should open on when an image viewer is loaded.

Parameters:
pixelsId - the pixelsId of the image.
Returns:
see above.
Throws:
DSOutOfServiceException
DSAccessException


setDefaultZ

public void setDefaultZ(long pixelsId,
                        int z)
                 throws DSOutOfServiceException,
                        DSAccessException
Set the default zSection of the image, this is the zSection the image should open on when an image viewer is loaded.

Parameters:
pixelsId - the pixelsId of the image.
z - see above.
Throws:
DSOutOfServiceException
DSAccessException


setDefaultT

public void setDefaultT(long pixelsId,
                        int t)
                 throws DSOutOfServiceException,
                        DSAccessException
Set the default timepoint of the image, this is the timepoint the image should open on when an image viewer is loaded.

Parameters:
pixelsId - the pixelsId of the image.
t - see above.
Throws:
DSOutOfServiceException
DSAccessException


setChannelWindow

public void setChannelWindow(long pixelsId,
                             int w,
                             double start,
                             double end)
                      throws DSOutOfServiceException,
                             DSAccessException
Set the channel Minimum, Maximum values, that map from image space to rendered space (3 channel, 8 bit, screen).

Parameters:
pixelsId - the pixelsId of the image the mapping applied to.
w - channel of the pixels.
start - The minimum value to map from.
end - The maximum value to map to.
Throws:
DSOutOfServiceException
DSAccessException


getChannelWindowStart

public double getChannelWindowStart(long pixelsId,
                                    int w)
                             throws DSOutOfServiceException,
                                    DSAccessException
Get the channel Minimum value, that maps from image space to rendered space.

Parameters:
pixelsId - the pixelsId of the image the mapping applied to.
w - channel of the pixels.
Returns:
see above.
Throws:
DSOutOfServiceException
DSAccessException


getChannelWindowEnd

public double getChannelWindowEnd(long pixelsId,
                                  int w)
                           throws DSOutOfServiceException,
                                  DSAccessException
Get the channel Maximum value, that maps from image space to rendered space.

Parameters:
pixelsId - the pixelsId of the image the mapping applied to.
w - channel of the pixels.
Returns:
see above.
Throws:
DSOutOfServiceException
DSAccessException


setRenderingDefId

public void setRenderingDefId(long pixelsId,
                              long renderingDefId)
                       throws DSOutOfServiceException,
                              DSAccessException
Set the rendering definition of the rendering engine from the default to the one supplied. This allows for more than one rendering definition- mapping per pixels.

Parameters:
pixelsId - for pixelsId
renderingDefId - see above.
Throws:
DSOutOfServiceException
DSAccessException


getThumbnail

public byte[] getThumbnail(long pixelsId,
                           omero.RInt sizeX,
                           omero.RInt sizeY)
                    throws DSOutOfServiceException,
                           DSAccessException
Get the thumbnail of the image.

Parameters:
pixelsId - for pixelsId
sizeX - size of thumbnail.
sizeY - size of thumbnail.
Returns:
see above.
Throws:
DSOutOfServiceException
DSAccessException


getThumbnailSet

public java.util.Map<java.lang.Long,byte[]> getThumbnailSet(omero.RInt sizeX,
                                                            omero.RInt sizeY,
                                                            java.util.List<java.lang.Long> pixelsIds)
                                                     throws DSOutOfServiceException,
                                                            DSAccessException
Get a set of thumbnails, of size X, Y from the list of pixelId's supplied in the list.

Parameters:
sizeX - size of thumbnail.
sizeY - size of thumbnail.
pixelsIds - list of ids.
Returns:
see above.
Throws:
DSOutOfServiceException
DSAccessException


getThumbnailBylongestSideSet

public java.util.Map<java.lang.Long,byte[]> getThumbnailBylongestSideSet(omero.RInt size,
                                                                         java.util.List<java.lang.Long> pixelsIds)
                                                                  throws DSOutOfServiceException,
                                                                         DSAccessException
Get a set of thumbnails from the pixelsId's in the list, maintaining aspect ratio.

Parameters:
size - size of thumbnail.
pixelsIds - list of ids.
Returns:
see above.
Throws:
DSOutOfServiceException
DSAccessException


getThumbnailBylongestSide

public byte[] getThumbnailBylongestSide(long pixelsId,
                                        omero.RInt size)
                                 throws DSOutOfServiceException,
                                        DSAccessException
Get the thumbnail of the image, maintain aspect ratio.

Parameters:
pixelsId - for pixelsId
size - size of thumbnail.
Returns:
see above.
Throws:
DSOutOfServiceException
DSAccessException


uploadPlane

public void uploadPlane(long pixelsId,
                        int z,
                        int c,
                        int t,
                        double[][] data)
                 throws DSOutOfServiceException,
                        DSAccessException
Upload the plane to the server, on pixels id with channel and the time, + z section. the data is the client 2d data values. This will be converted to the raw server bytes.

Parameters:
pixelsId - pixels id to upload to .
z - z section.
c - channel.
t - time point.
data - plane data.
Throws:
DSOutOfServiceException
DSAccessException


getPlaneFromImage

public double[][] getPlaneFromImage(long imageId,
                                    int z,
                                    int c,
                                    int t)
                             throws DSOutOfServiceException,
                                    DSAccessException
Get the plane from the image with imageId.

Parameters:
imageId - see above.
z - zSection of the plane.
c - channel of the plane.
t - timepoint of the plane.
Returns:
see above.
Throws:
DSOutOfServiceException
DSAccessException



File Service Methods

These methods deal with the interaction with attached files and scripts.

Method Detail

getScripts

public java.util.Map<java.lang.Long,java.lang.String> getScripts()
                                                          throws DSOutOfServiceException,
                                                                 DSAccessException
Get the scripts from the iScript Service.

Returns:
All the available scripts in a map by id and name.
Throws:
DSOutOfServiceException
DSAccessException


getScriptID

public long getScriptID(java.lang.String name)
                 throws DSOutOfServiceException,
                        DSAccessException
Get the id of the script with name

Parameters:
name - name of the script.
Returns:
the id of the script.
Throws:
DSOutOfServiceException
DSAccessException


uploadScript

public long uploadScript(java.lang.String script)
                  throws DSOutOfServiceException,
                         DSAccessException
Upload the script to the server.

Parameters:
script - script to upload
Returns:
id of the new script.
Throws:
DSOutOfServiceException
DSAccessException


getScript

public java.lang.String getScript(long id)
                           throws DSOutOfServiceException,
                                  DSAccessException
Get the script with id, this returns the actual script as a string.

Parameters:
id - id of the script to retrieve.
Returns:
see above.
Throws:
DSOutOfServiceException
DSAccessException


getParams

public java.util.Map<java.lang.String,RType> getParams(long id)
                                                throws DSOutOfServiceException,
                                                       DSAccessException
Get the parameters the script takes, this is a map of the parameter name and type.

Parameters:
id - id of the script.
Returns:
see above.
Throws:
DSOutOfServiceException
DSAccessException


runScript

public java.util.Map<java.lang.String,RType> runScript(long id,
                                                       java.util.Map<java.lang.String,RType> map)
                                                throws DSOutOfServiceException,
                                                       DSAccessException
Run the script and get the results returned as a name , value map.

Parameters:
id - id of the script to run.
map - the map of parameters, values for inputs.
Returns:
see above.
Throws:
DSOutOfServiceException
DSAccessException


deleteScript

public void deleteScript(long id)
                  throws DSOutOfServiceException,
                         DSAccessException
Delete the script with id from the server.

Parameters:
id - id of the script to delete.
Throws:
DSOutOfServiceException
DSAccessException



Helper Methods

These methods provide mechanisms to interact with different omero.model datastructures without making calls to the server.

Method Detail

getImagesFromDataset

public java.util.List<Image> getImagesFromDataset(Dataset dataset)
                                           throws DSOutOfServiceException,
                                                  DSAccessException
This is a helper method and makes no calls to the server. It gets a list of all the images in a dataset if the dataset has already had the datasets attached, via getLeaves in getProjects(List, boolean) or fetched via HQL in findAllByQuery(String), findByQuery(String)

Parameters:
dataset - see above.
Returns:
see above.
Throws:
DSOutOfServiceException
DSAccessException


getDatasetsFromProject

public java.util.List<Dataset> getDatasetsFromProject(Project project)
                                               throws DSOutOfServiceException,
                                                      DSAccessException
This is a helper method and makes no calls to the server. It gets a list of all the dataset in a project if the project has already had the datasets attached, via getLeaves in getProjects(List, boolean) or fetched via HQL in findAllByQuery(String), findByQuery(String)

Parameters:
project - see above.
Returns:
see above.
Throws:
DSOutOfServiceException
DSAccessException


getPixelsFromDataset

public java.util.List<Pixels> getPixelsFromDataset(Dataset dataset)
                                            throws DSOutOfServiceException,
                                                   DSAccessException
This is a helper method and makes no calls to the server. It gets a list of all the pixels in a dataset if the dataset has already had the pixels attached, via getLeaves in getProjects(List, boolean) getDatasets(List, boolean) or fetched via HQL in findAllByQuery(String), findByQuery(String)

Parameters:
dataset - see above.
Returns:
see above.
Throws:
DSOutOfServiceException
DSAccessException


getPixelsFromProject

public java.util.List<Pixels> getPixelsFromProject(Project project)
                                            throws DSOutOfServiceException,
                                                   DSAccessException
This is a helper method and makes no calls to the server. It gets a list of all the pixels in a project if the project has already had the pixels attached, via getLeaves in getProjects(List, boolean) or fetched via HQL in findAllByQuery(String), findByQuery(String)

Parameters:
project - see above.
Returns:
see above.
Throws:
DSOutOfServiceException
DSAccessException


getPixelsImageMap

public java.util.Map<java.lang.Long,Pixels> getPixelsImageMap(java.util.List<Image> images)
This is a helper methods, which makes no calls to the server. It get all the pixels attached to a list of images. It requires that the pixels are already attached via getProjects(List, boolean) getDatasets(List, boolean) or fetched via HQL in findAllByQuery(String), findByQuery(String) Get the pixels from the images in the list.

Parameters:
images - see above.
Returns:
map of the pixels-->imageId.


getPixelsFromImageList

public java.util.List<Pixels> getPixelsFromImageList(java.util.List<Image> images)
This is a helper methods, which makes no calls to the server. It get all the pixels attached to a list of images. It requires that the pixels are already attached via getProjects(List, boolean) getDatasets(List, boolean) or fetched via HQL in findAllByQuery(String), findByQuery(String) Get the pixels from the images in the list.

Parameters:
images - see above.
Returns:
list of the pixels.



Matlab Helper methods

Sometimes the data conversion from one type to another that allows methods to be used in Matlab requires to be done by Matlab functions. This section describes these methods and their uses.

Method Detail

getImagesFromDataset

uint8[][][] javaImageToMatlab(BufferedImage javaImage)                 
This is a helper method and makes no calls to the server. It converts the BufferImage returned by getRenderedImage(long, int, int)

Parameters:
dataset - see above.
Returns:
see above.
Throws:
DSOutOfServiceException
DSAccessException



Examples in Matlab using OMEROJava

The following sections contain examples of Matlab code using the OMEROJava Matlab wrappers.

Retrieve all current user Projects, and get Images in datasets

function [images] = findAllImages()
client = omero.client('hostname');
session = client.createSession('username','password');
gateway = session.createGateway();
% Get the current user projects and populate the datasets.
projects = gateway.getProjects([], true)

datasetList = java.util.ArrayList;

for projectCnt = 0:projects.size()-1,
    projectDatasetList = gateway.getDatasetsFromProject(projects.get(projectCnt));
    for j = 0:projectDatasetList.size()-1,
    	datasetList.add(projectDatasetList.get(j));
    end
end
images = java.util.ArrayList;
for i = 0:datasetList.size()-1,
    imageList = gateway.getImagesFromDataset(datasetList.get(i));
    for j = 0:imageList.size()-1,
        images.add(imageList.get(j));
    end
end

Simple Image Viewer

function drawImage(pixelsId)
client = omero.client('hostname');
session = client.createSession('username','password');
gateway = session.createGateway();
pixels = gateway.getPixels(pixelsId);
channel = 0;
figure(1);
for z=1:pixels.sizeZ.val,
    for t=1:pixels.sizeT.val,
        plane = gateway.getPlane(pixelsId, z-1, channel, t-1);
        figure(1);
        imagesc(plane);
        drawnow;
    end
end

Perform Projection on z-Stack

function performProjection(pixelsId, zSection)

client = omero.client('hostname');
session = client.createSession('username','password');
gateway = session.createGateway();
pixels = gateway.getPixels(pixelsId);
stack = gateway.getPlaneStack(pixelsId, zSection);
projectedImage = ProjectionOnStack(stack,'mean');
function [resultImage] = ProjectionOnStack(imageStack,type)

[zSections, X, Y] = size(imageStack);

if(strcmp(type,'mean') || strcmp(type, 'sum'))
    resultImage = squeeze(sum(imageStack));
    if(strcmp(type,'mean'))
        resultImage = resultImage./zSections;
    end
end
if(strcmp(type,'max'))
    resultImage = squeeze(max(imageStack,[],1));
end

BETA 4.0

Installing the new Gateway

The new gateway is installed just like the old gateway except that the jars required are located in OMERO_DIR/dist/lib/client and are:

omero_client.jar
ice.jar
model-psql.jar
blitz.jar

There have been a number of changes between Beta 3.2 and Beta 4, mostly these are the movement of methods which were strictly local transformations of the data from methods in the gateway to methods in a new package in OMEROJava called GatewayUtils.

These methods are:

Plane2D getPlane2D(PixelsI pixels, byte[] databuffer)

This method takes a pixels object and the byte buffer from getPlane and 
returns a Plane2D object which will convert the bytes to the any type.

Plane2D will be described later.

List<Projects> getDatasetsFromProject(Project)
This method is the same as getDatasetsFromProject in the Gateway, except that
the calls are all preformed locally on the client. 

List<Pixels> getPixelsFromProject(Project)
This method is the same as getPixelsFromProject in the Gateway, except that
the calls are all preformed locally on the client. 

List<Pixels> getPixelsFromImageList(List<Image>)
This method is the same as getPixelsFromImageList in the Gateway, except that
the calls are all preformed locally on the client. 

Map<Long, Image> getPixelsImageMap(List<Image>)
This method is the same as getPixelsImageMap in the Gateway, except that
the calls are all preformed locally on the client. 

List<Pixels> getPixelsFromDataset(Dataset)
This method is the same as getPixelsFromDataset in the Gateway, except that
the calls are all preformed locally on the client. 

List<Image> getImagesFromDataset(Dataset)
This method is the same as getImagesFromDataset in the Gateway, except that
the calls are all preformed locally on the client. 

List<Image> getImagesFromProject(Project)
This method is the same as getImagesFromProject in the Gateway, except that
the calls are all preformed locally on the client. 


and a new methods

BufferedImage toBufferedImage(PixelsI, int[] databuffer)

This method converts the dataBuffer from getRenderedPlane in the gateway to 
a bufferedImage. 

The other class which is new to the gateway is the Plane2D object which will convert byte data of the type in Pixels to the any appropriate 2D array.

The methods in Plane2D are:

double[][] getPixelsArrayAsDouble(boolean)
float[][]getPixelsArrayAsLong(boolean)
int[][]getPixelsArrayAsInt(boolean)
short[][]getPixelsArrayAsShort(boolean)
byte[][]getPixelsArrayAsByte(boolean)


Where the boolean will transpose the matrix from row data to column data.

Examples using the new gateway and GatewayUtils

The differences between the Gateway object in Beta3.2 and Beta4.0 are very small. The gateway is instantiated the same way:

client = omero.client('hostname');
session = client.createSession('username','password');
gateway = session.createGateway();

We retrieve data the same way

pixels = gateway.getPixels(56);

The only difference is using the GatewayUtils to transform the image data

rawPlane = gateway.getPlane(56, 0, 0 , 0);
plane2D = omerojava.util.GatewayUtils.getPlane2D(pixels, rawPlane);
plane = plane2D.getPixelsAsDouble(1);
imagesc(plane);

Download in other formats:

  • Plain Text

Trac Powered

Powered by Trac 0.11
By Edgewall Software.

Visit the Trac open source project at
http://trac.edgewall.org/