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 support #253

Merged
merged 29 commits into from
Apr 5, 2018
Merged

polygon support #253

merged 29 commits into from
Apr 5, 2018

Conversation

will-moore
Copy link
Member

@will-moore will-moore commented Nov 20, 2017

Supports adding of Polygons from OMERO to figure and editing them in Figure.

NB: creation of NEW polygons in figure is not supported in this PR.

To test:

  • Create and save Polygons AND Polylines in:
    • iviewer
    • Insight
    • ImageJ.
  • Open image in Figure
  • Add ROIs -> Load from OMERO -> Pick Polygon / Polyline
  • Once added, can edit (drag shape or corner handles)
  • Test Copy and Paste of Polygons/Polylines, between panels AND within 1 panel
  • Save figure, reload etc - check Polygons/Polylines saved OK.
  • Export to TIFF and PDF *NB: Polyline not supported here yet

cc @pwalczysko

screen shot 2017-11-20 at 09 51 06

@jburel
Copy link
Member

jburel commented Nov 20, 2017

let's put that onhold, we will do without for training.
We need to discuss the future of our own drawing library
ROI handling in figure in general needs to be reviewed.

@jburel
Copy link
Member

jburel commented Dec 18, 2017

To add to the description:
polygon should be created from different source: minimally insight and imageJ
since I noticed some difference between applications see ome/openmicroscopy#5597

@manics
Copy link
Member

manics commented Dec 18, 2017

Don't forget there's the really old format too: https://github.com/openmicroscopy/openmicroscopy/blob/v5.4.1/components/tools/OmeroPy/test/unit/test_rois.py#L32 which should be either tested or an appropriate error message shown.

@will-moore
Copy link
Member Author

@jburel jburel added this to the 3.2.0 milestone Jan 4, 2018
@jburel
Copy link
Member

jburel commented Jan 11, 2018

The same should be done for Polyline

@jburel
Copy link
Member

jburel commented Jan 11, 2018

The changes in shape-editor must go to its repository https://github.com/ome/shape-editor
A new version will be released prior to adding the feature in figure

@jburel jburel removed this from the 3.2.0 milestone Jan 11, 2018
Gruntfile.js Outdated
expand: true,
cwd: 'node_modules/ome-shape-editor/dist/js',
src: 'shape-editor.js',
dest: 'omero_figure/static/figure/3rdparty/shape-editor-3.1.0'
Copy link
Member

@jburel jburel Mar 1, 2018

Choose a reason for hiding this comment

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

The version of shape-editor should ideally be retrieved from package.json

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm - that might be kinda tricky.
This version number is also in index.html

<script src="{% static 'figure/3rdparty/shape-editor-3.1.0/shape-editor.js' %}"></script>

Having that version number in multiple places is not new, but now we don't have the shape-editor.js code itself.

@will-moore
Copy link
Member Author

@jburel Any idea what's going on here? Even when I remove the small change I made to setup.py, travis is still failing here with

+ python setup.py sdist
running sdist
running grunt
running npm_install
npm install
unable to execute npm: No such file or directory
error: command 'npm' failed with exit status 1

@pwalczysko
Copy link
Member

2 problems detected #253 (comment) and #253 (comment), otherwise works as expected

@rgozim
Copy link
Member

rgozim commented Mar 8, 2018

Tested locally and working is working fine for editing an iviewer image with ROIs.

Small issue with copying an image with shapes that lie outside the image viewport, as @pwalczysko mentioned before me.

@joshmoore
Copy link
Member

Raising the limit to 500 seems fairly arbitrary and likely to require your testers to increase the number of ROIs they have to add before they see a potential problem, no?

@will-moore
Copy link
Member Author

Not entirely arbitrary, but this was a quick fix I needed for the iviewer demo movie and could certainly be improved.
500 is the default max limit of the JSON API allows, so setting it higher than that here would not allow you to load any more ROIs.
I could get the max limit from api and use that, so that if someone were to config a higher value then it would allow more to be loaded here too.
Unfortunately there is only 1 API_MAX_LIMIT setting which applies to all objects, so it's not possible to allow loading of 1000 ROIs while keeping the limit lower for e.g. Wells or Images (which tend to be more verbose).

@joshmoore
Copy link
Member

was a quick fix I needed for the iviewer demo movie

understood.

500 is the default max limit of the JSON API allows, so setting it higher than that here would not allow you to load any more ROIs.

understood. Was having it at 200 causing issues because it was different from the API's 500 or is there another underlying issue? i.e. must the values be the same?

@jburel
Copy link
Member

jburel commented Mar 14, 2018

I reckon 200 was an arbitrary value set since figure did not use the json api to load roi.

@will-moore
Copy link
Member Author

On the image I used in the movie, the ImageJ Analyse-Particles created over 200 polygons on the image, so that the Arrow I added in iviewer was not included in the first 200 shapes I loaded into figure (so it didn't show up in figure).
200 is the default API_LIMIT of the json api.

@joshmoore
Copy link
Member

Sorry for derailing this PR. Assuming the summary is correct, happy for "figure should load more than 1 page of ROIs" to be captured somewhere.

@will-moore
Copy link
Member Author

That should fix the 2 problems reported by @pwalczysko above.

h = sqrt(dx * dx + dy * dy)
# and the angle (avoid division by zero!)
if dy == 0:
dy = 0.000001
Copy link
Member

Choose a reason for hiding this comment

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

what is the rationale?

Copy link
Member Author

Choose a reason for hiding this comment

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

You can't divide by zero, but dividing by a number close to zero works very well and is the simplest workaround (the previous workaround was not working).

Copy link
Member

@sbesson sbesson Mar 21, 2018

Choose a reason for hiding this comment

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

Isn't this the case we you want to use math.atan2 rather than math.atan?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, that works. Thanks

@pwalczysko
Copy link
Member

That should fix the 2 problems reported by @pwalczysko above.

Yes, both problems are fixed. Ready to merge FMPOV

@jburel
Copy link
Member

jburel commented Mar 27, 2018

Could you open a PR against shape-editor?
We first need to tag shape-editor before moving forward with this PR

@snoopycrimecop
Copy link
Member

snoopycrimecop commented Mar 27, 2018

Conflicting PR. Removed from build FIGURE-merge#677. See the console output for more details.
Possible conflicts:

  • PR Big images #243 will-moore 'Big images'
    • omero_figure/templates/figure/index.html

--conflicts Conflict resolved in build FIGURE-merge#678. See the console output for more details.

@will-moore
Copy link
Member Author

Doh - conflict was bound to happen sometime I guess with these two big PRs.
But shape-editor PR is open in the meantime...

@will-moore will-moore mentioned this pull request Mar 28, 2018
10 tasks
@jburel
Copy link
Member

jburel commented Mar 29, 2018

No problem noticed with handling of polygons/polylines
next steps are:

@will-moore
Copy link
Member Author

I have deprecated shape-editor from npm (couldn't unpublish).

$ npm deprecate -f 'ome-shape-editor@3.1.0' "To be replaced by openmicroscopy/shape-editor"

Can you now publish openmicroscopy/shape-editor so I can use that?

@jburel
Copy link
Member

jburel commented Apr 5, 2018

package has now been published under the organisation
https://www.npmjs.com/settings/openmicroscopy/packages

@will-moore
Copy link
Member Author

Thanks. Hopefully with a final test to check this is working, we should be good to merge?

@jburel
Copy link
Member

jburel commented Apr 5, 2018

I would think so. Added chat to standup

@jburel
Copy link
Member

jburel commented Apr 5, 2018

Retested with the latest change on web-dev-merge
Still not great to have the version in 3 different places with it
Merging so we can move forward with the Big images review

@jburel jburel merged commit 715aeb0 into ome:master Apr 5, 2018
@jburel jburel added this to the 4.0.0 milestone May 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants