Page 1 of 1

retrieving image information from OMERO.web template page

PostPosted: Thu Oct 13, 2011 2:24 pm
by bhcho
Hi all,

I'm trying to modify a template page in OMERO.web, especially \omeroweb\webclient\templates\webclient\data\containers_icon.html.
I added a custom button to execute my own app. After you select an image from the template page, then you can execute my own app for the selected image by clicking the custom button.

But before executing a custom app, I'd like to popup a dialog window to select channel, z-depth, and timepoint of the selected image.

I could get the image ID of the selected image by
Code: Select all
var productArray = $("input[type='checkbox']:checked");
if (productArray.length > 0 ) {
  productArray.each(function() {
    if(this.checked) {
      productListQuery += this.id + ",";
    }
  });
}


But is it possible to get the number of channel of the selected image (and the name of each channel if possible), the number of z, and the number of timepoint from this template page?

Best,
BK

Re: retrieving image information from OMERO.web template pag

PostPosted: Thu Oct 13, 2011 2:37 pm
by wmoore
It seems that the 'dialog window' is really just the first page of your app, and you'd need to build that page in the same way as any other.

- Create a url that takes the imageId
- In views.py create a function that gets the Image object and the channel data
Code: Select all
image = conn.getObject("Image", imageId)
sizeZ = image.getSizeZ()
sizeT = image.getSizeT()

# or use getLabel() to show wavelength or index if no name
names = [c.getName() for c in image.getChannels()]

return render_to_response('your/dialog/template.html', {'sizeZ: sizeZ, 'sizeT':sizeT, 'names':names})


In fact, you could just return the image object itself and let the template do the rest,
E.g.
Code: Select all
return render_to_response('your/dialog/template.html', {'image': image})


Code: Select all
{% for c in image.getChannels %}
  <li>{{ c.getName }}</li>
{% endfor %}

Re: retrieving image information from OMERO.web template pag

PostPosted: Thu Oct 13, 2011 2:50 pm
by bhcho
Thanks,

I was actually asking about a way to retrieve the information without using another app. (getting the information directly from the "$("input[type='checkbox']:checked")").
But I guess this is not possible.

BK

Re: retrieving image information from OMERO.web template pag

PostPosted: Thu Oct 13, 2011 3:06 pm
by wmoore
I'm afraid not.

Also it makes for a cleaner integration if you have to add less code to the webclient itself.
Keeping it together with your app is nicer.

Will.

Re: retrieving image information from OMERO.web template pag

PostPosted: Fri Oct 14, 2011 2:45 pm
by bhcho
Thanks again Will,

Two more questions.

1.
Is the "Pixels" deprecated from 4.3.x version?
from 4.2.x version (when using Gateway, not Blitzgateway), I had to inherit Pixels first like..
Code: Select all
gateway = session.createGateway()
image = gateway.getImage( iid )
pixels = image.getPixels( 0 )
C = pixels.getSizeC()
T = pixels.getSizeT()
X = pixels.getSizeX()
Y = pixels.getSizeY()
Z = pixels.getSizeZ()

I thought "Image" can have multiple Pixels, and Pixels then have multiple Channels, Depth, and timepoints.

2.
what is the equivalent code for 4.2.x? I was using
Code: Select all
    image = conn.getImage(iid)
    Channels = image.getChannels()
    sizeC=len(Channels)
    sizeZ=image.getZ()
    sizeT=image.getT()


I can get the number of channels, but SizeZ and SizeT are zeros from this. I think these should be 1.

BK

Re: retrieving image information from OMERO.web template pag

PostPosted: Fri Oct 14, 2011 3:01 pm
by wmoore
Hi BK,

We haven't got rid of Pixels, since that would be a massive model change. However, there are various places in our code where we assume Image only has one Pixels object.

The image.getSizeX() is really just a shortcut for image.getPrimaryPixels().getSizeX(). We just hide this from the user for convenience.

NB: I haven't tried using image.getPixels(0) but you should probably be using image.getPrimaryPixels() so that you get the correct PixelsWrapper object (E.g. for getting access to raw pixel data etc). Also, image.getPixels(0) will fail if the pixels are not already loaded, whereas image.getPrimaryPixels() loads pixels if needed.

Cheers,

Will.