Page 1 of 1

Project/Dataset representative Image

PostPosted: Thu Apr 10, 2014 1:58 am
by bobbledavidson
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

Re: Project/Dataset representative Image

PostPosted: Thu Apr 10, 2014 10:09 am
by atarkowska
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

Re: Project/Dataset representative Image

PostPosted: Sun Apr 13, 2014 9:54 pm
by wmoore
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.

Re: Project/Dataset representative Image

PostPosted: Mon Apr 14, 2014 9:58 am
by bobbledavidson
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.

Re: Project/Dataset representative Image

PostPosted: Thu Apr 17, 2014 6:38 am
by jmoore
Duly noted, Rob. Thanks!
~Josh