We're Hiring!

managing ROIs

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.

managing ROIs

Postby yuriy_alexandrov » Fri Jul 12, 2013 1:17 pm

Hi All,

I try to use ROI schema from Matlab to place our image segmentation results in Omero, and have couple of, hopefully, very simple questions.

I succeeded to transfer bounding rectangles around each object - they are seen in Omero Web browser.
But the idea is, certainly, to transfer shapes (or "masks" - not sure which term is proper. blobs, anyway).

The code below uses the segmented image "segmmask" as source of "masks" and attaches ROI with corresponding "masks" to the Omero image:

Code: Select all
            stats = regionprops(segmmask,'PixelList');
            for k=1:numel(stats)
                    X = stats(k).PixelList(:,1);
                    Y = stats(k).PixelList(:,2);
                    %
                    x0 = min(X);
                    y0 = min(Y);
                    W = max(X) - x0 + 1;
                    H = max(Y) - y0 + 1;
                    %
                    m = zeros(W,H);
                    for j = 1 : numel(X),
                        x = X(j) - x0 + 1;
                        y = Y(j) - y0 + 1;
                        m(x,y) = 1;                       
                    end
                    %
                    mask = createMask(x0,y0,m);
                    setShapeCoordinates(mask, 0, 0, 0);
                    %
                    roi = omero.model.RoiI;                   
                    roi.addShape(mask);                                       
                    roi.setImage(omero.model.ImageI(image.getId.getValue, false));
                    roi = iUpdate.saveAndReturnObject(roi);
            end           

first, I'm not sure it is correct.

second, - imported ROIs and shapes are not visible in Omero-web.

third - I didn't find way how to retrieve these pixels back (which is the matter of significant interest..).

Using the example I found how to access the "mask" object if it is there:

Code: Select all
service = obj.session.getRoiService();
roiResult = service.findByImage(image.getId.getValue, []);
rois = roiResult.rois;
n = rois.size;
for thisROI  = 1:n
    roi = rois.get(thisROI-1);
    numShapes = roi.sizeOfShapes; % an ROI can have multiple shapes.
    for ns = 1:numShapes
        shape = roi.getShape(ns-1); % the shape
       
         if (isa(shape, 'omero.model.Mask'))

             shape
             % mmmmmmmmmmmm... WHAT TO DO NEXT?

         end                       
    end
end

So basically I would like to get some quick refs/usage examples for the functions managing access, visibility, and attributes of these blobs' pixels.

Best regards,
Y.
yuriy_alexandrov
 
Posts: 126
Joined: Thu Oct 25, 2012 2:06 pm

Re: managing ROIs

Postby yuriy_alexandrov » Fri Jul 12, 2013 3:10 pm

well, it looks like, I found how to get the masks back:

Code: Select all
         if (isa(shape, 'omero.model.Mask'))
            x0 = shape.getX().getValue;
            y0 = shape.getY().getValue;
            W = shape.getWidth().getValue;
            H = shape.getHeight().getValue;
            bytes = shape.getBytes();
            mask = reshape(bytes,[H,W]);
         end


but still not how to make them visible in Omero Web..
...
yuriy_alexandrov
 
Posts: 126
Joined: Thu Oct 25, 2012 2:06 pm

Re: managing ROIs

Postby wmoore » Fri Jul 12, 2013 8:41 pm

Hi,

Unfortunately we never got around to implementing mask display in the web viewer yet.
I remember at the time that I was still unsure about the specification for storing masks, and how to handle that in Python.
But now that someone's actually creating masks, we should certainly go ahead.
User avatar
wmoore
Team Member
 
Posts: 674
Joined: Mon May 18, 2009 12:46 pm

Re: managing ROIs

Postby yuriy_alexandrov » Mon Jul 15, 2013 10:11 am

many thanks Will,

and how does it work, say, with tracking applications or segmentations by CEll PRofiler/ImageJ/KNIME - are segmentation results stored in Omero as separate images or annotations?

displaying segmented ROIs - looks like very basic image visualization functionality.

one last question - how to set/get attributes of ROI, e.g. Description?
yuriy_alexandrov
 
Posts: 126
Joined: Thu Oct 25, 2012 2:06 pm

Re: managing ROIs

Postby yuriy_alexandrov » Tue Jul 16, 2013 9:39 am

..it looks like, text attribute is set by "setTextValue"

http://users.openmicroscopy.org.uk/~spl ... _Mask.html
yuriy_alexandrov
 
Posts: 126
Joined: Thu Oct 25, 2012 2:06 pm

Re: managing ROIs

Postby sbesson » Tue Jul 16, 2013 10:00 am

Hi Yuriy,

answering your first question, I know writing back results into OMERO has been mentioned in the projects you listed. I can't point you at any code that is concretely doing so at the moment.

regarding your second point, my experience is that people have two classical representation of masks. Either it is displayed an image with some transparency usually or the mask contours are computed and rendered as lines. As you said, there is nothing ground-breaking there, the biggest problem is as usual the amount of resources (people and time) required for its implementation.

Finally, here is a code example to set and retrieve the description of a ROI
Code: Select all
roi = omero.model.RoiI()
roi.setDescription(rstring('a roi description'));
description = char(roi.getDescription().getValue());


Sebastien
User avatar
sbesson
Team Member
 
Posts: 421
Joined: Tue Feb 28, 2012 7:20 pm

Re: managing ROIs

Postby sbesson » Tue Jul 16, 2013 10:03 am

Right. Here's another code examples to set/get text values on a Mask shape:

Code: Select all
shape = createMask(ones(512,512));
shape.setTextValue(rstring('a mask'));
value = char(shape.getTextValue().getValue());


Sebastien
User avatar
sbesson
Team Member
 
Posts: 421
Joined: Tue Feb 28, 2012 7:20 pm

Re: managing ROIs

Postby yuriy_alexandrov » Tue Jul 16, 2013 3:14 pm

many thanks Sebastien,

it looks OK now.

At least, when Segmentation Community solves the problem of working with lifetime-featured images + storing the ROIs in Omero, - we will be able to pick up these advanced segmentations.
For now we just managing ours.

Best,
Y.
yuriy_alexandrov
 
Posts: 126
Joined: Thu Oct 25, 2012 2:06 pm


Return to Developer Discussion

Who is online

Users browsing this forum: No registered users and 0 guests