Page 1 of 1

using Omero.tables

PostPosted: Tue May 15, 2012 8:21 am
by Thorondor
here I am again. :D

ok, so I try to upload data using Omero.tables, but my plate is not in a dataset, only Ids I have are following:
screenId = 2
plateId = 2
imageId = 195
wellId = 116

so how do I attach data to this image?

Re: using Omero.tables

PostPosted: Tue May 15, 2012 3:02 pm
by wmoore
Hi,

Your best bet is to add rows to your table that reference individual Images in your plate.

So, use an ImageColumn as the first column, then additional columns for each parameter of that Image. This is the convention used when we store various analysis data for HCS.

Have a look at:
https://github.com/openmicroscopy/openm ... ate_roi.py

E.g. you can get the images from your Plate: https://github.com/openmicroscopy/openm ... oi.py#L446

However, I guess you could also reference ROIs (RoiColumn) or Wells if that makes more sense. See http://hudson.openmicroscopy.org.uk/job ... /grid.html

It should be noted that we don't really support the display of OMERO.tables data in our clients, so it's more of a storage facility for API access. However, we intend to improve support for OMERO.tables in our clients in due course.

If the populate_roi.py code above is too much, have another look at the OmeroPy example I sent you earlier, http://trac.openmicroscopy.org.uk/ome/w ... MEROtables for how to attach the table to a Plate. (just put Plate instead of Dataset in these lines:

Code: Select all
link = omero.model.DatasetAnnotationLinkI()
link.setParent(omero.model.DatasetI(datasetId, False))

Re: using Omero.tables

PostPosted: Fri May 18, 2012 12:47 pm
by Thorondor
so I do something like that:

Code: Select all
# Configuration
# =================================================================

screenId = 2
plateId = 2
imageId = 195
wellId = 116


# Create a name for the Original File (should be unique)
# =================================================================
from random import random
#tablename = "TablesDemo:%s" % str(random())

tablename = "image_data"

col1 = omero.grid.LongColumn('WellId', '', [])
col2 = omero.grid.LongColumn('CellCount', '', [])

columns = [col1, col2]
   
# Create and initialize a new table.
# =================================================================
repositoryId = 1
table = conn.c.sf.sharedResources().newTable(repositoryId, tablename)

table.initialize(columns)
#table.initialize(WellColumn)


# Add data to the table.
# =================================================================
well = [116, 158, 160, 149]
cellcount = [432, 562, 357, 283]

data1 = omero.grid.LongColumn('WellId', '', well)
data2 = omero.grid.LongColumn('CellCount', '', cellcount)
data = [data1, data2]
table.addData(data)
table.close()           # when we're done, close.


# Get the table as an original file...
# =================================================================
orig_file = table.getOriginalFile()
orig_file_id = orig_file.id.val
# ...so you can attach this data to an object. E.g. Dataset
fileAnn = omero.model.FileAnnotationI()
fileAnn.setFile(omero.model.OriginalFileI(orig_file_id, False))     # use unloaded OriginalFileI
fileAnn = conn.getUpdateService().saveAndReturnObject(fileAnn)
link = omero.model.DatasetAnnotationLinkI()
link.setParent(omero.model.DatasetI(plateId, False))
link.setChild(omero.model.FileAnnotationI(fileAnn.id.val, False))
conn.getUpdateService().saveAndReturnObject(link)


stops with error:

Code: Select all

No handlers could be found for logger "blitz_gateway"
WARNING:blitz_gateway:ValidationException on <class 'omero.gateway.OmeroGatewaySafeCallWrapper'> to <47298244-7ef3-4592-b2ea-835fcb79bbe0omero.api.IUpdate> saveAndReturnObject((object #0 (::omero::model::DatasetAnnotationLink)
{
    _id = <nil>
    _details = object #1 (::omero::model::Details)
    {
        _owner = <nil>
        _group = <nil>
        _creationEvent = <nil>
        _updateEvent = <nil>
        _permissions = <nil>
        _externalInfo = <nil>
    }
    _loaded = True
    _version = <nil>
    _parent = object #2 (::omero::model::Dataset)
    {
        _id = object #3 (::omero::RLong)
        {
            _val = 2
        }
        _details = <nil>
        _loaded = False
        _version = <nil>
        _projectLinksSeq = {}
        _projectLinksLoaded = False
        _projectLinksCountPerOwner = {}
        _imageLinksSeq = {}
        _imageLinksLoaded = False
        _imageLinksCountPerOwner = {}
        _annotationLinksSeq = {}
        _annotationLinksLoaded = False
        _annotationLinksCountPerOwner = {}
        _name = <nil>
        _description = <nil>
    }
    _child = object #4 (::omero::model::FileAnnotation)
    {
        _id = object #5 (::omero::RLong)
        {
            _val = 270
        }
        _details = <nil>
        _loaded = False
        _version = <nil>
        _ns = <nil>
        _description = <nil>
        _annotationLinksSeq = {}
        _annotationLinksLoaded = False
        _annotationLinksCountPerOwner = {}
        _file = <nil>
    }
},), {})
Traceback (most recent call last):
  File "/data/applications/OMERO.server-Beta-4.3.4/lib/python/omero/gateway/__init__.py", line 2956, in __call__
    return self.f(*args, **kwargs)
  File "/data/applications/OMERO.server-Beta-4.3.4/lib/python/omero_api_IUpdate_ice.py", line 97, in saveAndReturnObject
    return _M_omero.api.IUpdate._op_saveAndReturnObject.invoke(self, ((obj, ), _ctx))
ValidationException: exception ::omero::ValidationException
{
    serverStackTrace = ome.conditions.ValidationException: No row with the given identifier exists: [ome.model.containers.Dataset#2]; nested exception is org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [ome.model.containers.Dataset#2]
        at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:663)
        at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
        at org.springframework.orm.hibernate3.HibernateInterceptor.invoke(HibernateInterceptor.java:117)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:108)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at ome.tools.hibernate.ProxyCleanupFilter$Interceptor.invoke(ProxyCleanupFilter.java:231)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at ome.services.util.ServiceHandler.invoke(ServiceHandler.java:116)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
        at $Proxy77.saveAndReturnObject(Unknown Source)
        at sun.reflect.GeneratedMethodAccessor385.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
        at ome.security.basic.BasicSecurityWiring.invoke(BasicSecurityWiring.java:83)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at ome.services.blitz.fire.AopContextInitializer.invoke(AopContextInitializer.java:43)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
        at $Proxy77.saveAndReturnObject(Unknown Source)
        at sun.reflect.GeneratedMethodAccessor1532.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at ome.services.blitz.util.IceMethodInvoker.invoke(IceMethodInvoker.java:179)
        at ome.services.throttling.Callback.run(Callback.java:56)
        at ome.services.throttling.InThreadThrottlingStrategy.callInvokerOnRawArgs(InThreadThrottlingStrategy.java:56)
        at ome.services.blitz.impl.AbstractAmdServant.callInvokerOnRawArgs(AbstractAmdServant.java:136)
        at ome.services.blitz.impl.UpdateI.saveAndReturnObject_async(UpdateI.java:64)
        at omero.api._IUpdateTie.saveAndReturnObject_async(_IUpdateTie.java:92)
        at omero.api._IUpdateDisp.___saveAndReturnObject(_IUpdateDisp.java:185)
        at omero.api._IUpdateDisp.__dispatch(_IUpdateDisp.java:365)
        at IceInternal.Incoming.invoke(Incoming.java:159)
        at Ice.ConnectionI.invokeAll(ConnectionI.java:2037)
        at Ice.ConnectionI.message(ConnectionI.java:972)
        at IceInternal.ThreadPool.run(ThreadPool.java:577)
        at IceInternal.ThreadPool.access$100(ThreadPool.java:12)
        at IceInternal.ThreadPool$EventHandlerThread.run(ThreadPool.java:971)

    serverExceptionClass = ome.conditions.ValidationException
    message = No row with the given identifier exists: [ome.model.containers.Dataset#2]; nested exception is org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [ome.model.containers.Dataset#2]
}
Traceback (most recent call last):
  File "test_tables.py", line 88, in ?
    conn.getUpdateService().saveAndReturnObject(link)
  File "/data/applications/OMERO.server-Beta-4.3.4/lib/python/omero/gateway/__init__.py", line 2959, in __call__
    return self.handle_exception(e, *args, **kwargs)
  File "/data/applications/OMERO.server-Beta-4.3.4/lib/python/omero/gateway/__init__.py", line 2956, in __call__
    return self.f(*args, **kwargs)
  File "/data/applications/OMERO.server-Beta-4.3.4/lib/python/omero_api_IUpdate_ice.py", line 97, in saveAndReturnObject
    return _M_omero.api.IUpdate._op_saveAndReturnObject.invoke(self, ((obj, ), _ctx))
omero.ValidationException: exception ::omero::ValidationException
{
    serverStackTrace = ome.conditions.ValidationException: No row with the given identifier exists: [ome.model.containers.Dataset#2]; nested exception is org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [ome.model.containers.Dataset#2]
        at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:663)
        at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
        at org.springframework.orm.hibernate3.HibernateInterceptor.invoke(HibernateInterceptor.java:117)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:108)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at ome.tools.hibernate.ProxyCleanupFilter$Interceptor.invoke(ProxyCleanupFilter.java:231)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at ome.services.util.ServiceHandler.invoke(ServiceHandler.java:116)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
        at $Proxy77.saveAndReturnObject(Unknown Source)
        at sun.reflect.GeneratedMethodAccessor385.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
        at ome.security.basic.BasicSecurityWiring.invoke(BasicSecurityWiring.java:83)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at ome.services.blitz.fire.AopContextInitializer.invoke(AopContextInitializer.java:43)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
        at $Proxy77.saveAndReturnObject(Unknown Source)
        at sun.reflect.GeneratedMethodAccessor1532.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at ome.services.blitz.util.IceMethodInvoker.invoke(IceMethodInvoker.java:179)
        at ome.services.throttling.Callback.run(Callback.java:56)
        at ome.services.throttling.InThreadThrottlingStrategy.callInvokerOnRawArgs(InThreadThrottlingStrategy.java:56)
        at ome.services.blitz.impl.AbstractAmdServant.callInvokerOnRawArgs(AbstractAmdServant.java:136)
        at ome.services.blitz.impl.UpdateI.saveAndReturnObject_async(UpdateI.java:64)
        at omero.api._IUpdateTie.saveAndReturnObject_async(_IUpdateTie.java:92)
        at omero.api._IUpdateDisp.___saveAndReturnObject(_IUpdateDisp.java:185)
        at omero.api._IUpdateDisp.__dispatch(_IUpdateDisp.java:365)
        at IceInternal.Incoming.invoke(Incoming.java:159)
        at Ice.ConnectionI.invokeAll(ConnectionI.java:2037)
        at Ice.ConnectionI.message(ConnectionI.java:972)
        at IceInternal.ThreadPool.run(ThreadPool.java:577)
        at IceInternal.ThreadPool.access$100(ThreadPool.java:12)
        at IceInternal.ThreadPool$EventHandlerThread.run(ThreadPool.java:971)

    serverExceptionClass = ome.conditions.ValidationException
    message = No row with the given identifier exists: [ome.model.containers.Dataset#2]; nested exception is org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [ome.model.containers.Dataset#2]
}

Re: using Omero.tables

PostPosted: Fri May 18, 2012 1:45 pm
by jmoore
These two lines will need to be changed from:
Code: Select all
link = omero.model.DatasetAnnotationLinkI()
link.setParent(omero.model.DatasetI(plateId, False))

to
Code: Select all
link = omero.model.PlateAnnotationLinkI()
link.setParent(omero.model.PlateI(plateId, False))


Cheers,
~Josh

Re: using Omero.tables

PostPosted: Mon May 21, 2012 9:11 am
by Thorondor
wmoore wrote:It should be noted that we don't really support the display of OMERO.tables data in our clients, so it's more of a storage facility for API access. However, we intend to improve support for OMERO.tables in our clients in due course.

again thanks for your help.
We will need to view the data in Omero in some way if we will use Omero for our purpose. Or are there other ways to attach data to image/plates e.g. Structured Annotations?

Re: using Omero.tables

PostPosted: Tue May 22, 2012 1:18 pm
by cxallan
Noted. Yes there are other ways, however the structured annotations you would be using there are just free text really.

Re: using Omero.tables

PostPosted: Tue May 22, 2012 2:56 pm
by wmoore
The web client "should" support the display of our various Structured Annotations, although this hasn't been tested very thoroughly since it's not used much.

Try adding a few and see how it works for you.

This example Python code might help: https://gist.github.com/2769549

Let us know how it goes....

NB: This should be seen as a temporary measure until we do a better job of displaying OMERO.tables data in the clients, since *large* numbers of annotations won't scale well.