Path to Images In OMERO

Hello everyone,

I have a Python script which needed to be uploaded into OMERO. I need to stitch images of a specific folder which have been already uploaded into OMERO server. How can I provide a Path for my Images in Python Script Code, that can be understandable for OMERO and be able to run it?

It would be greatly appreciated if you help me in this case.

Pegah

Hi @Pegah,

Something like the following:

   # Setup
   image_id = SOMETHING_HERE
   client = MUST_BE_DEFINED

   import os
   from omero.rtypes import unwrap
   resources = client.sf.sharedResources()
   repos = resources.repositories()
   for desc in repos.descriptions:
       if desc.name.val == "ManagedRepository":
           managed_repo_dir = desc.path.val + desc.name.val

   params = omero.sys.ParametersI()
   params.addId(image_id)
   rows = client.sf.getQueryService().projection("""
       SELECT DISTINCT ofile.id, ofile.path
           || ofile.name FROM Image AS i
       JOIN i.fileset AS f
       JOIN f.usedFiles AS fe
       JOIN fe.originalFile AS ofile
       WHERE i.id = :id""", params, {"omero.group": "-1"})
   imported_file = os.path.join(managed_repo_dir, unwrap(rows[0][1]))

should give you the path to the first imported file for an image.

:warning: Heads up for anyone using this code: Since only a user who should have permissions to access the image should be allowed to run this code, it is safe as written. Be careful though to not introduce a backdoor into your /OMERO/ManagedRepository!

~Josh