Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polygon python training example #4412

Merged
merged 5 commits into from Jan 24, 2016

Conversation

will-moore
Copy link
Member

Improve ROIs examples in python with new Polygon example and setting of strokeWidth and stroke + fill colours. See http://lists.openmicroscopy.org.uk/pipermail/ome-users/2016-January/005804.html

To test, review and run the example.

Also broke multi-shape ROI into several smaller ROIs, with single shape each
in case someone wants to view result in Insight
""" Returns strange format supported by Insight """
points = ["%s,%s" % (p[0], p[1]) for p in points]
csv = ", ".join(points)
return "points[%s] points1[%s] points2[%s]" % (csv, csv, csv)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you need to set it to something other than what's described at http://www.openmicroscopy.org/Schemas/Documentation/Generated/OME-2015-01/ROI_xsd.html#Polygon_Points then we probably need a card.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mtbc : I think this is the older format. @jburel / @dominikl : is the support for the newer available / carded?

@joshmoore
Copy link
Member

Objections to my adding a mask example here?

@will-moore
Copy link
Member Author

Please do! (in another PR you mean)?

@joshmoore
Copy link
Member

Yup, I'll build on this commit but re-use the ROIs.py file unless we think there should be a Masks.py one.

@sbesson
Copy link
Member

sbesson commented Jan 18, 2016

I would reuse ROIs.py minimally to stay consistent with the other training languages (https://github.com/openmicroscopy/openmicroscopy/blob/v5.2.1/examples/Training/java/src/training/ROIs.java, https://github.com/openmicroscopy/openmicroscopy/blob/v5.2.1/examples/Training/matlab/ROIs.m) where ROIs.ext is the generic script demonstrating how to create available shapes.

@will-moore
Copy link
Member Author

Comment from http://lists.openmicroscopy.org.uk/pipermail/ome-users/2016-January/005807.html
"My particular use-case required that the colours set on ROIs include the
alpha-channel (which I created) so as not to completely hide the segment
begin the ROI. You might also want to include that in rgbToRGBInt()."

@will-moore
Copy link
Member Author

The previous commit added support for Alpha, but if I try to set alpha > 127 (50%) for strokeColor then I get this error:

Traceback (most recent call last):
  File "ROIs.py", line 128, in <module>
    createROI(image, [polygon])
  File "ROIs.py", line 56, in createROI
    updateService.saveObject(roi)
  File "/Users/wmoore/Desktop/OMERO/openmicroscopy/dist/lib/python/omero/gateway/__init__.py", line 4205, in __call__
    return self.handle_exception(e, *args, **kwargs)
  File "/Users/wmoore/Desktop/OMERO/openmicroscopy/dist/lib/python/omero/gateway/__init__.py", line 4202, in __call__
    return self.f(*args, **kwargs)
  File "/Users/wmoore/Desktop/OMERO/openmicroscopy/dist/lib/python/omero_api_IUpdate_ice.py", line 107, in saveObject
    return _M_omero.api.IUpdate._op_saveObject.invoke(self, ((obj, ), _ctx))
ValueError: invalid value for ::omero::RInt member `_val'

Any ideas what I'm doing wrong here?

@mtbc
Copy link
Member

mtbc commented Jan 20, 2016

http://www.openmicroscopy.org/Schemas/Documentation/Generated/OME-2015-01/ROI_xsd.html#Shape_FillColor and its kin specify a signed 32 bit value: if alpha > 127 then do you need to subtract to make the most significant bit act like a sign bit? Just as my example from http://lists.openmicroscopy.org.uk/pipermail/ome-users/2016-January/005803.html had #C4C4C4C4 represented by -993737532.

@will-moore
Copy link
Member Author

Hmmm - I wonder if anyone knows straight off how to convert from unsigned 32 bit to signed? Don't really want to spend a day trying to research 2's complement (or whatever) and work it out in python. Do we have code to do this in Java anywhere?

@mtbc
Copy link
Member

mtbc commented Jan 20, 2016

If the number is larger than 2^31-1 then subtract 2^32 from it.

@will-moore
Copy link
Member Author

Thanks @mtbc. Script is working now with range of alpha values.

screen shot 2016-01-21 at 11 52 22

@joshmoore
Copy link
Member

Makes sense to me and works for me locally. Merging and I'll 1) remark on the list thread and 2) update by PR to not include your commits.

joshmoore added a commit that referenced this pull request Jan 24, 2016
@joshmoore joshmoore merged commit bea1363 into ome:develop Jan 24, 2016
@jburel jburel added this to the 5.2.2 milestone Feb 29, 2016
@will-moore will-moore deleted the polygon_python_training_example branch February 18, 2019 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants