We're Hiring!

ROI attachment

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.

ROI attachment

Postby bhcho » Mon Nov 15, 2010 9:53 pm

Hi all,

I have a couple of questions about the ROI.

Suppose you have a cell region ROI mask(s), which is a binary image with the same size as the original image. Only the cell region is bright (1) and the background is black (0).

Then could you tell me
1. how to attach this ROI mask to the original image by using the Bio-Format API? A sample code will be very appreciated.

2. after the attachment, how to recognize that the ROI is a "cell region" mask, rather than a rectangular, circle, or line. I'm asking this becasue there could be also other ROIs attached to the image, and other masks as well. But we need to retrieve the "cell region" masks for our own purpose. Can we put a name to the ROI mask (such as "cell_001") and recognize by its name? If so, could you tell me the API function that put/retrieve the name to/from the ROI? (A sample code will be more straight-forward).

Thank you alot in advance,
BK
bhcho
 
Posts: 236
Joined: Mon Apr 05, 2010 2:15 pm

Re: ROI attachment

Postby mlinkert » Sat Nov 20, 2010 10:24 pm

Hi BK,

Suppose you have a cell region ROI mask(s), which is a binary image with the same size as the original image. Only the cell region is bright (1) and the background is black (0).

Then could you tell me
1. how to attach this ROI mask to the original image by using the Bio-Format API? A sample code will be very appreciated.


If you have a MetadataStore object named 'store' and your mask is a byte array named 'mask':

Code: Select all
  // set the mask to be the 0th Shape on the 0th ROI
  store.setROIID("ROI:0", 0);
  store.setMaskID("Shape:0:0", 0, 0);
  store.setMaskBinData(mask, 0, 0);
  store.setMaskX(0d, 0, 0); // the X coordinate of the upper-left corner of the mask, relative to the image
  store.setMaskY(0d, 0, 0); // the Y coordinate of the upper-left corner of the mask, relative to the image
  store.setMaskWidth(width, 0, 0); // the width in pixels of mask
  store.setMaskHeight(height, 0, 0); // the height in pixels of the mask

  // link the mask's parent ROI to the 0th Image
  store.setImageROIRef("ROI:0", 0, 0);


2. after the attachment, how to recognize that the ROI is a "cell region" mask, rather than a rectangular, circle, or line. I'm asking this becasue there could be also other ROIs attached to the image, and other masks as well. But we need to retrieve the "cell region" masks for our own purpose. Can we put a name to the ROI mask (such as "cell_001") and recognize by its name? If so, could you tell me the API function that put/retrieve the name to/from the ROI? (A sample code will be more straight-forward).


You could certainly use the Name or Description attributes of Mask to identify in your own code whether or not the Mask corresponds to a cell region. To populate those attributes (assuming that the above code is already in place):

Code: Select all
  store.setMaskName("Cell region", 0, 0);
  store.setMaskDescription("This really is a cell region, and not anything else.", 0, 0);


And to retrieve the name and description, if you have a MetadataRetrieve object named 'retrieve':

Code: Select all
  String name = retrieve.getMaskName(0, 0);
  String description = retrieve.getMaskDescription(0, 0);


Regards,
-Melissa
User avatar
mlinkert
Team Member
 
Posts: 353
Joined: Fri May 29, 2009 2:12 pm
Location: Southwest Wisconsin

Re: ROI attachment

Postby bhcho » Sun Nov 21, 2010 1:46 am

Hi Melissa,

Thank you soooo much!! :D
bhcho
 
Posts: 236
Joined: Mon Apr 05, 2010 2:15 pm


Return to Developer Discussion

Who is online

Users browsing this forum: No registered users and 1 guest