createImageFromNumpySeq() usage?
Posted: Fri Apr 20, 2018 12:02 am
With some other scripts, I've read in a .svs image, converted to a numpy array and broke it up into smaller pieces (tiles), ran some things over each of the tiles, then stitched it back together. Now, before I try pulling the image from OMERO, I wanted to see about putting the modified image into OMERO from the numpy array.
The shape of my array is (46129, 61752, 3). This is a single layer from the original .svs and each pixel represented with 3 values (RGB) where each value is dtype=uint8. Thus, I have one plane (image layer). I have no Z stack and no Time sequence. I'm assuming that the sizes for those parameters should each be '1' and the Color size is '3'. My script bits, cribbed from the documentation example:
This keeps giving me the following error:
The error makes me think that there is more data in the array than the function was expecting. Have I got my parameters/dimensions correct? Is the organization of the array correct? Should I have more planes? Anything else that I've obviously messed up?
The shape of my array is (46129, 61752, 3). This is a single layer from the original .svs and each pixel represented with 3 values (RGB) where each value is dtype=uint8. Thus, I have one plane (image layer). I have no Z stack and no Time sequence. I'm assuming that the sizes for those parameters should each be '1' and the Color size is '3'. My script bits, cribbed from the documentation example:
- Code: Select all
planes = [reconstitutedArrayFromTiles]
sizeZ = sizeT = 1
sizeC = 3
desc = "Image created from reading numpy array off disk"
i = conn.createImageFromNumpySeq(
plane_gen(), "numpy image", sizeZ, sizeC, sizeT, description=desc,
dataset=None)
This keeps giving me the following error:
- Code: Select all
ERROR:omero.gateway:Failed to setPlane() on rawPixelsStore while creating Image
Traceback (most recent call last):
File "/home/omero/OMERO.server/lib/python/omero/gateway/__init__.py", line 3764, in createImageFromNumpySeq
image, dtype = createImage(plane, channelList)
File "/home/omero/OMERO.server/lib/python/omero/gateway/__init__.py", line 3684, in createImage
sizeY, sizeX = firstPlane.shape
ValueError: too many values to unpack
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-102-c91df066e6d0> in <module>()
3 i = conn.createImageFromNumpySeq(
4 p_gen(), "numpy image", sizeZ, sizeC, sizeT, description=desc,
----> 5 dataset=None)
6 print 'Created new Image:%s Name:"%s"' % (i.getId(), i.getName())
/home/omero/OMERO.server/lib/python/omero/gateway/__init__.pyc in createImageFromNumpySeq(self, zctPlanes, imageName, sizeZ, sizeC, sizeT, description, dataset, sourceImageId, channelList)
3791 exc = e
3792 if exc is not None:
-> 3793 raise exc
3794
3795 # simply completing the generator - to avoid a GeneratorExit error.
ValueError: too many values to unpack
The error makes me think that there is more data in the array than the function was expecting. Have I got my parameters/dimensions correct? Is the organization of the array correct? Should I have more planes? Anything else that I've obviously messed up?