We're Hiring!

Bioformats API

General and open developer discussion about using OMERO APIs from C++, Java, Python, Matlab and more! Please new questions at https://forum.image.sc/tags/omero
Please note:
Historical discussions about OMERO. Please look for and ask new questions at https://forum.image.sc/tags/omero

If you are having trouble with custom code, please provide a link to a public repository, ideally GitHub.

Bioformats API

Postby icaoberg » Wed Oct 06, 2010 8:44 pm

when accessing the omero shell, is there access to the bioformats api?
Last edited by icaoberg on Thu Oct 07, 2010 6:45 pm, edited 2 times in total.
icaoberg
 
Posts: 145
Joined: Fri Sep 17, 2010 9:05 pm
Location: Pittsburgh, PA

Re: Biomodels API

Postby jmoore » Wed Oct 06, 2010 8:47 pm

Do you mean the bioformats API? If so, no. It's strictly available in Java. What are you trying to achieve?

~J.
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Re: Biomodels API

Postby icaoberg » Wed Oct 06, 2010 8:51 pm

i want to retrieve an image from the server and export it to a desired format, say a numpy array.
icaoberg
 
Posts: 145
Joined: Fri Sep 17, 2010 9:05 pm
Location: Pittsburgh, PA

Re: Biomodels API

Postby jmoore » Thu Oct 07, 2010 5:43 am

Do you mean something like https://trac.openmicroscopy.org.uk/omero/browser/trunk/components/tools/OmeroPy/src/omero/util/script_utils.py#L395 ? This retrieves an "image", i.e. what OMERO calls a plane, as a NumPy array.

~J
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Re: Biomodels API

Postby icaoberg » Thu Oct 07, 2010 6:44 pm

script_utils has a method for converting a tiff to a numpy array. i guess there is a way to map the byte array containing the image to tiff. so i could that. but i am looking for a method the parses the byte array directly to a numpy array without writing to disk, that is without writing an image to file.
icaoberg
 
Posts: 145
Joined: Fri Sep 17, 2010 9:05 pm
Location: Pittsburgh, PA

Re: Bioformats API

Postby jmoore » Thu Oct 07, 2010 7:06 pm

The method I pointed to does take the byte array returned by rawPixelsStore.getPlane() and converts it to a NumPy array:


Code: Select all

395   def downloadPlane(rawPixelsStore, pixels, z, c, t):
...
406       rawPlane = rawPixelsStore.getPlane(z, c, t);
...
411       convertType ='>'+str(sizeX*sizeY)+pixelstypetopython.toPython(pixelType);
412       convertedPlane = unpack(convertType, rawPlane);
413       numpyType = pixelstypetopython.toNumpy(pixelType)
414       remappedPlane = numpy.array(convertedPlane, numpyType);
415       remappedPlane.resize(sizeY, sizeX);
416       return remappedPlane;


Where are you getting your byte array from? If not from RawPixelsStore, then I you can just copy that bottom portion and make it into your own method.

Cheers,
~Josh.
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Re: Bioformats API

Postby icaoberg » Thu Oct 07, 2010 7:53 pm

i was trying to get the byte stream from the importer like in Run_Matlab.py but this is way cooler! Awesome should be a technical term. I'll try it and let you know. :lol:
icaoberg
 
Posts: 145
Joined: Fri Sep 17, 2010 9:05 pm
Location: Pittsburgh, PA

Re: Bioformats API

Postby icaoberg » Mon Oct 25, 2010 6:14 am

i tried it and got this error.

Code: Select all
In [122]: plane = utils.downloadPlane( rawPixelsStore, pixels, 0, 0, 0 );
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (8, 0))

ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (22, 0))

---------------------------------------------------------------------------
UnloadedEntityException                   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/util/script_utils.pyc in downloadPlane(rawPixelsStore, pixels, z, c, t)
    404     sizeY = pixels.getSizeY().getValue();
    405     pixelsId = pixels.getId().getValue();
--> 406     pixelType = pixels.getPixelsType().getValue().getValue();
    407     convertType ='>'+str(sizeX*sizeY)+pixelstypetopython.toPython(pixelType);
    408     convertedPlane = unpack(convertType, rawPlane);

/usr0/local/omero.server/OMERO.server-Beta-4.2.0/lib/python/omero_model_PixelsTypeI.pyc in getValue(self, current)
    109
    110       def getValue(self, current = None):
--> 111           self.errorIfUnloaded()
    112           return self._value
    113

/usr0/local/omero.server/OMERO.server-Beta-4.2.0/lib/python/omero_model_PixelsTypeI.pyc in errorIfUnloaded(self)
     36       def errorIfUnloaded(self):
     37           if not self._loaded:
---> 38               raise _omero.UnloadedEntityException("Object unloaded:"+str(self))
     39
     40       def throwNullCollectionException(self,propertyName):

UnloadedEntityException: Object unloaded:object #0 (::omero::model::PixelsType)
{
    _id = object #1 (::omero::RLong)
    {
        _val = 5
    }
    _details = <nil>
    _loaded = False
    _value = <nil>
}
icaoberg
 
Posts: 145
Joined: Fri Sep 17, 2010 9:05 pm
Location: Pittsburgh, PA

Re: Bioformats API

Postby jmoore » Mon Oct 25, 2010 6:31 am

Hi Ivan,

can you show me your entire code snippet? Where are you getting your Pixels object from? It's "unloaded" which means that none of the fields are present. See http://trac.openmicroscopy.org.uk/omero/wiki/ObjectModel#States for more information. http://hudson.openmicroscopy.org.uk/job/OMERO/javadoc/ome/api/IPixels.html#retrievePixDescription(long) will return a properly loaded Pixel instance.

Cheers,
~Josh
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Re: Bioformats API

Postby icaoberg » Mon Oct 25, 2010 7:20 am

Code: Select all
   rawPixelsStore = session.createRawPixelsStore()
   image = gateway.getImage( iid )
   pixels = image.getPixels( 0 )
   pid = pixels.getId().getValue()
   rawPixelsStore.setPixelsId( pid, True )
   plane = utils.downloadPlane( rawPixelsStore, pixels, 0, 0, 0 );
icaoberg
 
Posts: 145
Joined: Fri Sep 17, 2010 9:05 pm
Location: Pittsburgh, PA

Next

Return to Developer Discussion

Who is online

Users browsing this forum: Google [Bot] and 0 guests