Page 1 of 2
Data and OMERO Tables
Posted:
Tue Nov 02, 2010 3:25 pm
by icaoberg
i downloaded one of the generated tables with feature values but they are empty. i think i might be doing something wrong.
- Code: Select all
resources = session.sharedResources()
repositories = resources.repositories()
fileLink = omero.model.ImageAnnotationLinkI()
#features
featuresTable = resources.newTable( iid, str(iid) + '_features.h5' )
featuresFileAnnotation = omero.model.FileAnnotationI()
featuresFileAnnotation.file = featuresTable.getOriginalFile()
fileLink.link( omero.model.ImageI(iid, False), featuresFileAnnotation)
session.getUpdateService().saveObject(fileLink)
features_column = omero.grid.DoubleColumn("feature_value", """Feature value""", [] )
featuresTable.initialize([features_column])
for i in range(len(features)):
features_column.values.append( features[i] )
featurestable.addData([features_column])
Re: Data and OMERO Tables
Posted:
Tue Nov 02, 2010 3:38 pm
by jmoore
With a few modifications like capitalizations and parsing to double:
- Code: Select all
def test(session, features, iid):
resources = session.sharedResources()
repositories = resources.repositories()
fileLink = omero.model.ImageAnnotationLinkI()
#features
featuresTable = resources.newTable( iid, str(iid) + '_features.h5' )
featuresFileAnnotation = omero.model.FileAnnotationI()
featuresFileAnnotation.file = featuresTable.getOriginalFile()
fileLink.link( omero.model.ImageI(iid, False), featuresFileAnnotation)
session.getUpdateService().saveObject(fileLink)
features_column = omero.grid.DoubleColumn("feature_value", """Feature value""", [] )
featuresTable.initialize([features_column])
for i in range(len(features)):
features_column.values.append( float(features[i]) )
featuresTable.addData([features_column])
print featuresTable.read([0], 0, 10)
I get this result:
- Code: Select all
In [30]: test(client.sf, range(10), i.id.val)
object #0 (::omero::grid::Data)
{
lastModification = 1288712208046
rowNumbers =
{
[0] = 0
[1] = 1
[2] = 2
[3] = 3
[4] = 4
[5] = 5
[6] = 6
[7] = 7
[8] = 8
[9] = 9
}
columns =
{
[0] = object #1 (::omero::grid::DoubleColumn)
{
name = feature_value
description =
values =
{
[0] = 0.0
[1] = 1.0
[2] = 2.0
[3] = 3.0
[4] = 4.0
[5] = 5.0
[6] = 6.0
[7] = 7.0
[8] = 8.0
[9] = 9.0
}
}
}
}
Hope that helps.
~Josh
Re: Data and OMERO Tables
Posted:
Tue Nov 02, 2010 3:42 pm
by jmoore
Ah, something else that occurs to me: try closing the table instance (which I should have done as well). Only when it's closed does the server update the length, and that's how much you download. See
http://trac.openmicroscopy.org.uk/omero/ticket/2908 for more information.
~J.
Re: Data and OMERO Tables
Posted:
Wed Nov 03, 2010 3:41 pm
by icaoberg
shouldnt i be able to open the created h5 file using
- Code: Select all
table = resources.openTable( "iid4401_features.h5" )
but i get the error
- Code: Select all
In [35]: table = resources.openTable( 'iid4401_features.h5')
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/afs/cs.cmu.edu/user/bhcho/<ipython console> in <module>()
/usr0/local/omero.server/OMERO.server-Beta-4.2.0/lib/python/omero_SharedResources_ice.pyc in openTable(self, file, _ctx)
105
106 def openTable(self, file, _ctx=None):
--> 107 return _M_omero.grid.SharedResources._op_openTable.invoke(self, ((file, ), _ctx))
108
109 def checkedCast(proxy, facetOrCtx=None, _ctx=None):
ValueError: invalid value for argument 1 in operation `openTable'
Re: Data and OMERO Tables
Posted:
Wed Nov 03, 2010 4:01 pm
by jmoore
Hi Ivan,
SharedResoures.openTable doesn't take a string but an omero.model.OriginalFile object. If you only have the id of the file, then you can use:
- Code: Select all
resources.openTable(omero.model.OriginalFileI(FILE_ID, False))
Cheers,
~Josh
Re: Data and OMERO Tables
Posted:
Mon Nov 08, 2010 6:38 pm
by icaoberg
is there a way to retrieve the table using the file name? or an image id? or is there a way to keep track of the table?
the thing is for every image with image id <iid> we create an h5 table named <iid>-features.h5
i want a way to retrieve all the tables by this <iid> but im navigating through the api and cant seem to find a way.
Re: Data and OMERO Tables
Posted:
Thu Nov 25, 2010 2:54 pm
by jmoore
Ivan,
have you had any luck with the solution we discussed?
Cheers,
~Josh
Re: Data and OMERO Tables
Posted:
Fri Dec 03, 2010 3:44 pm
by icaoberg
Yes I get a list of all the attachments. But I have a question: can I make a query and search for filename and get the file ID for that filename? I mean, can I query say table.h5 and get the file ID? if so what would be the query? sorry i really have no clue on how to do this.
Re: Data and OMERO Tables
Posted:
Fri Dec 03, 2010 3:54 pm
by jmoore
I'm not sure exactly what you're asking but perhaps something like this:
- Code: Select all
iQuery.projection("select f.id from OriginalFile f where f.path = '/dir/' and f.name = 'table.h5'");
If you'd like to also use the annotation metadata you'll need a query like this:
- Code: Select all
select f.id from FileAnnotation fa join fa.file f where fa.ns = 'CMU:abc' and f.name = 'table.h5'
Hope that helps.
~Josh.
Re: Data and OMERO Tables
Posted:
Fri Dec 03, 2010 4:33 pm
by icaoberg
say i save a table and i name it features.h5 and omero returns a file id 1 -which i dont know-. on disk the file features.h5 doesn't exist, a file with name 1 exist in the repository. since i know the name of the file -not the file id-, is there a way to make a query where given the filename i get the file id? i know i cant do this through the api, since i can only load a table using the file id not the file name.
ivan
ps your previous solution works but it returns every file link and i would like to know if there is a more efficient way.