OMEROJava a Matlab interface to OMERO.blitz
OmeroJava provides a mechanism to access the OMERO.blitz server from Matlab. The OMEROJava interface provides a java gateway to OMERO.blitz which can be accessed from Matlab, there are also Matlab helper functions that convert some java datastructures to more Matlab friendly ones.
Installing the OMEROJava gateway for Matlab
To install the OMEROJava gateway you will need to compile the OMEROJava gateway in the omero/components/tools/OmeroJava directory (see Compiling OMEROJava), or the OmeroJava-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 OMEROJava, subsection OMEROJava dependancies). The path to the newly added jars should be added to the class path file (MatlabDir/local/toolbox/classpath.txt).
Compiling OMEROJava
OMEROJava will be compiled as part of the OMERO.blitz build and the resulting jar, OmeroJava-3.0-Beta3.jar will be created in the OMERODir/dist/client directory. OMEROJava can also be compiled using eclipse, select file->new Project and create project from existing source code, point the directory at the OMERODir/components/tools/OMEROJava/src directory. To create the OmeroJava-3.0-Beta3.jar, select export from the file menu, and click finish.
OMEROJava Dependancies
OMEROJava has dependancies on 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
- blitz-3.0-Beta3.jar
- model-psql-3.0-Beta3.jar
Creating a connection using OMEROJava in Java
To connect to the server create an instance of the OmeroJavaService passing in the path to the iceConfig file, and call createSession passing username, and password.
OmeroJavaService omerojavaService = new omerojava.service.OmeroJavaService(iceConfig);
omerojavaService.createSession(username, password);
After you are finished using the OMEROJava gateway call close to close connection to the server, and close session.
The OMEROJava gateway has a heartbeat thread which will keep the connection between your session and the server alive, until close is called.
Creating a connection in OMEROJava in Matlab
To connect to the server via matlab is very similar to creating a connection in java.
omerojavaService = omerojava.service.OmeroJavaService(java.lang.String(iceConfig));
omerojavaService.createSession(username, password);
Using the OMEROJava gateway
The OMEROJava 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.
The OMEROJava gateway consists of one public class, OmeroJavaService which creates a connection to the server and provides all methods necessary to interact with the server.
OMEROJava Methods
The following are a list of methods provided by OMEROJava OmeroJavaService.
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:
DSOutOfServiceExceptionDSAccessException
keepAlive
public void keepAlive()
throws DSOutOfServiceException,
DSAccessException
- Keep service alive.
- Throws:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
getImage
public Image getImage(long id)
throws DSOutOfServiceException,
DSAccessException
- Get the image with id
- Parameters:
id- see above- Returns:
- see above.
- Throws:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
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:
DSAccessExceptionDSOutOfServiceExceptionDSOutOfServiceExceptionDSAccessException
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 timepointsz- 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:
DSOutOfServiceExceptionDSAccessException
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-pointsz- The number of zSections.channelList- the list of channels to copy, [0-(sizeC-1)].imageName- The new imageName.- Returns:
- new id.
- Throws:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
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-pointschannelList- 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:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
saveObject
public void saveObject(IObject obj)
throws DSOutOfServiceException,
DSAccessException
- Save the object to the db .
- Parameters:
obj- see above.- Throws:
DSOutOfServiceExceptionDSAccessException
saveAndReturnObject
public IObject saveAndReturnObject(IObject obj)
throws DSOutOfServiceException,
DSAccessException
- Save and return the Object.
- Parameters:
obj- see above.- Returns:
- see above.
- Throws:
DSOutOfServiceExceptionDSAccessException
saveArray
public void saveArray(java.util.List<IObject> graph)
throws DSOutOfServiceException,
DSAccessException
- Save the array.
- Parameters:
graph- see above.- Throws:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
deleteObject
public void deleteObject(IObject row)
throws DSOutOfServiceException,
DSAccessException
- Delete the object.
- Parameters:
row- the object.(commonly a row in db)- Throws:
DSOutOfServiceExceptionDSAccessException
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:
DSAccessExceptionDSOutOfServiceException
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:
DSAccessExceptionDSOutOfServiceException
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 renderz- z section to rendert- timepoint to render- Returns:
- The image as a buffered image.
- Throws:
DSOutOfServiceExceptionDSAccessException
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 renderz- z section to rendert- timepoint to render- Returns:
- The image as a 3d array where it represents the image as [x][y][channel]
- Throws:
DSOutOfServiceExceptionDSAccessException
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 renderz- z section to rendert- timepoint to render- Returns:
- The pixels are returned as 4 bytes representing the r,g,b,a of image.
- Throws:
DSOutOfServiceExceptionDSAccessException
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 channelactive- set active?- Throws:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
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 pixelsIdrenderingDefId- see above.- Throws:
DSOutOfServiceExceptionDSAccessException
getThumbnail
public byte[] getThumbnail(long pixelsId,
omero.RInt sizeX,
omero.RInt sizeY)
throws DSOutOfServiceException,
DSAccessException
- Get the thumbnail of the image.
- Parameters:
pixelsId- for pixelsIdsizeX- size of thumbnail.sizeY- size of thumbnail.- Returns:
- see above.
- Throws:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
getThumbnailBylongestSide
public byte[] getThumbnailBylongestSide(long pixelsId,
omero.RInt size)
throws DSOutOfServiceException,
DSAccessException
- Get the thumbnail of the image, maintain aspect ratio.
- Parameters:
pixelsId- for pixelsIdsize- size of thumbnail.- Returns:
- see above.
- Throws:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
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:
DSOutOfServiceExceptionDSAccessException
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
- Parameters:
dataset- see above.- Returns:
- see above.
- Throws:
DSOutOfServiceExceptionDSAccessException
getProjects(List, boolean)
or fetched via HQL in findAllByQuery(String), findByQuery(String)
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 infindAllByQuery(String),findByQuery(String)- Parameters:
project- see above.- Returns:
- see above.
- Throws:
DSOutOfServiceExceptionDSAccessException
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 infindAllByQuery(String),findByQuery(String)- Parameters:
dataset- see above.- Returns:
- see above.
- Throws:
DSOutOfServiceExceptionDSAccessException
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 infindAllByQuery(String),findByQuery(String)- Parameters:
project- see above.- Returns:
- see above.
- Throws:
DSOutOfServiceExceptionDSAccessException
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 infindAllByQuery(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 infindAllByQuery(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
- Parameters:
dataset- see above.- Returns:
- see above.
- Throws:
DSOutOfServiceExceptionDSAccessException
getRenderedImage(long, int, int)
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()
omerojavaService = createOmeroJavaService('ice.config', 'root', 'omero');
% Get the current user projects and populate the datasets.
projects = getProjects(omerojavaService,[], true)
datasetList = java.util.ArrayList;
for projectCnt = 0:projects.size()-1,
projectDatasetList = getDatasetsFromProject(omerojavaService, 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 = getImagesFromDataset(omerojavaService, datasetList.get(i));
for j = 0:imageList.size()-1,
images.add(imageList.get(j));
end
end
Simple Image Viewer
function drawImage(pixelsId)
omerojavaService = createOmeroJavaService('ice.config', 'root', 'omero');
pixels = getPixels(omerojavaService, pixelsId);
channel = 0;
figure(1);
for z=1:pixels.sizeZ.val,
for t=1:pixels.sizeT.val,
plane = getPlane(omerojavaService, pixelsId, z-1, channel, t-1);
figure(1);
imagesc(plane);
drawnow;
end
end
Perform Projection on z-Stack
function performProjection(pixelsId, zSection)
omerojavaService = createOmeroJavaService('ice.config', 'root', 'omero');
pixels = getPixels(omerojavaService, pixelsId);
stack = getPlaneStack(omerojavaService, 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
