We're Hiring!

Project/Dataset representative Image

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.

Project/Dataset representative Image

Postby bobbledavidson » Thu Apr 10, 2014 1:58 am

Hi,

I'm trying to develop OMERO as a public facing website and am having varied success with omeroweb and Django.

To aid navigation I have a page that displays all Projects with appropriate links to follow through to Datasets and then on to individual Images. What I'd like is to represent each Project by rendering one of the Images from one of the Datasets within the Project (and I'd like to do this with the subsequent Dataset lists too, rendering a representative Image from within the Dataset).

My question: is there a way to tag an Image so that it can be used as the thumbnail for either a Project or Dataset that it is a child of?

Workarounds that I've considered are: choosing a random image from the Project/Dataset's children or adding a metatag into one of the existing annotation fields and then parsing during page load, or possibly even adding an image file to the Project/Dataset's 'attachments'.

Problems that I'm having: random images may not look good! parsing text tags is slow and seems less elegant somehow. I don't know how to access the 'attachments' to display any image files uploaded in that way.

Any and all suggestions appreciated.

Thanks,

Rob
bobbledavidson
 
Posts: 2
Joined: Wed Apr 09, 2014 9:24 am

Re: Project/Dataset representative Image

Postby atarkowska » Thu Apr 10, 2014 10:09 am

Hi Rob

bobbledavidson wrote:My question: is there a way to tag an Image so that it can be used as the thumbnail for either a Project or Dataset that it is a child of?


As I understand you wish to have a cover image for your project or dataset.
We currently do not offer that functionality but what you could do is to add custom LongAnnotation to the Dataset with given namespace where value is your image ID.

Code: Select all
ns = "company.app.cover_image"
longAnn = omero.model.LongAnnotationI()
longAnn.setValue(rlong(imageID))
longAnn.setNs(rstring(ns))
longAnn = conn.saveAndReturnObject(longAnn)

dataset.linkAnnotation(longAnn)


Then you just need to do:

Code: Select all
imageID = dataset.getAnnotation(ns="your_namespace").getValue()


Let me know if that works for you

Ola
atarkowska
 
Posts: 327
Joined: Mon May 18, 2009 12:44 pm

Re: Project/Dataset representative Image

Postby wmoore » Sun Apr 13, 2014 9:54 pm

You might want to look at a prototype "public facing" web app that does much of what you want: https://github.com/will-moore/gallery

The home page displays a list of all groups, then projects, datasets and images in subsequent pages. The groups, projects and datasets pages each use a random representative image from within that "container".


If you wanted to use existing annotations supported by the Insight client, you could use Tags or Ratings on an image to indicate that this should be representative of a Project. E.g. to extend the queries in the "gallery" app to choose a single image that was rated 5, you could do:

Code: Select all
queryService = conn.getQueryService()
params = omero.sys.ParametersI()
params.addLong('pid', 1)
params.addLong('five', 5)
params.addString('ratingNs', omero.constants.metadata.NSINSIGHTRATING)
params.theFilter = omero.sys.Filter()
params.theFilter.limit = wrap(1)

query = "select i from Image as i"\
        " left outer join i.datasetLinks as dl join dl.parent as dataset"\
        " left outer join dataset.projectLinks as pl join pl.parent as project"\
        " left outer join i.annotationLinks as al join al.child as ann"\
        " where project.id = :pid"\
        " and ann.ns = :ratingNs and ann.longValue = :five"

img = queryService.findByQuery(query, params, conn.SERVICE_OPTS)
print img.id.val


Although this is a 'random' pick of a 5-rated image in the Project, it will probably always select the same image, even if you have rated several as 5. If you wanted a random one of many, then increase the filter limit and use
Code: Select all
queryService.findAllByQuery
to retrieve several images, then pick one at random.

Regards,

Will.
User avatar
wmoore
Team Member
 
Posts: 674
Joined: Mon May 18, 2009 12:46 pm

Re: Project/Dataset representative Image

Postby bobbledavidson » Mon Apr 14, 2014 9:58 am

Thanks both,

ideally I would use the Insight client for my users to upload images therefore I feel that Will's suggestion of tagging or rating an image might be more appropriate.

That said, I liked the original idea of linking the ImageID to the dataset or project (rather than searching through each image within a dataset or project) so if i was ever making a client myself, I'd add a function to 'use image as dataset cover' that made the annotation under a specified namespace... but I'm not intending to so I'll just leave this hanging as a request :)

Thanks again.
bobbledavidson
 
Posts: 2
Joined: Wed Apr 09, 2014 9:24 am

Re: Project/Dataset representative Image

Postby jmoore » Thu Apr 17, 2014 6:38 am

Duly noted, Rob. Thanks!
~Josh
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany


Return to Developer Discussion

Who is online

Users browsing this forum: Google [Bot] and 1 guest