Query all images from a given instrument in OMERO

Hi all

I would like to retrieve all the images taken by a given instrument through the Python API.
This (in principle) works, but is of course super inefficient:

with BlitzGateway("root", "XXX", host=host, port=port) as conn: 
 
    conn.SERVICE_OPTS.setOmeroGroup("-1") 
    all_images = [ 
          im.getId() for im in conn.getObjects("Image") 
          if im.getInstrument() == 10455 
    ] 

Is there a way to perform a direct database query from BlitzGateway, as

SELECT Id FROM image WHERE instrument=10455;

retrieves the relevant data?

Thanks a lot!

Guillaume

You can try the Query Service

https://docs.openmicroscopy.org/omero/5.6.1/developers/GettingStarted.html#hql-examples

1 Like

Thanks a lot! Guess I didn’t read the “getting started” section carefully enough :confused:

And since HQL isn’t everyone’s cup of :tea: :

select i.id from Image i where i.instrument.id = 10455

~Josh

1 Like

Thanks, I’m not sure I would have converged to that very quickly! (I never ‘tasted’ HQL)

1 Like