Page 1 of 1

How to stop using OMERO

PostPosted: Tue Sep 12, 2017 8:12 am
by rdecoster
Several groups are using OMERO in our department but over years labs move to other departments that do not use OMERO. What are the options for those individuals or entire groups to pull their data out OMERO. What is the best practise?

It might be also important that currently they are still working on a 4.4.9 version.

Thanks for looking into this.
Best,
Raf

Re: How to stop using OMERO

PostPosted: Tue Sep 12, 2017 11:06 pm
by wmoore
Hi Raf,

What data in OMERO are you interested in exporting?
If the images are "archived" when imported then you can export the original image files.
If not then you can export as OME-TIFF which will include a little but not all of the image metadata along with the pixel data.
What about annotations (Tags, Comments etc)?

There is no built-in functionality for large-scale exports, so the best option will be a script of some sort ( Python / Java / Bash ) depending on what you need.

Regards,

Will.

Re: How to stop using OMERO

PostPosted: Thu Sep 14, 2017 10:07 am
by rdecoster
Hi Will,

I checked with the people leaving and they just want to get the original files out grouped by project/dataset.
I found a python script online which I adjusted a bit to my needs and I can drill down to all projects and datasets of a user but now I'm a bit lost in retrieving the original image. Basically where I end up is:

Code: Select all
im = conn.getObject("Image", 43840)
#you can do ome/tiff
im.exportOmeTiff(1024 * 1024)

#the original (which fails)
im.getImportedImageFiles()



the getimportedimagefiles method doesn't exist in 4.4.9, is there an alternative?

best,
Raf

Re: How to stop using OMERO

PostPosted: Fri Sep 15, 2017 11:33 am
by wmoore
Hi Raf,

I'm not testing this on a 4.4. server since it would take me a while to set that up.
But hopefully (with a few tweaks) this will work for you, to list available archived files for a given image
and to download them locally.

Code: Select all
from omero.gateway import BlitzGateway, OriginalFileWrapper
from omero.model import OriginalFileI

params = omero.sys.ParametersI()
queryService = conn.getQueryService()
imageId = 10008
params.addId(imageId)

conn.SERVICE_OPTS.setOmeroGroup(-1)

query = """select link from PixelsOriginalFileMap as link
           left outer join fetch link.child as pixels
           left outer join fetch link.parent
           where pixels.image.id = :id"""

result = queryService.findAllByQuery(query, params)
for link in result:
    filename = link.parent.name.val
    fileId = link.parent.id.val
    print "Downloading...", fileId, filename
    origFile = OriginalFileWrapper(conn, OriginalFileI(fileId, False))

    with f = open(filename, "wb")
    try:
        for chunk in origFile.getFileInChunks(buf=2621440):
            f.write(chunk)
    finally:
        f.close()


Are you running these scripts locally, connecting to a remote OMERO server, or are you using the OMERO scripting service to run them on the server?

Let me know how you get on,
Regards,

Will.