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

easy functions for ROIs #8

Open
1 of 2 tasks
kmader opened this issue Sep 7, 2018 · 1 comment
Open
1 of 2 tasks

easy functions for ROIs #8

kmader opened this issue Sep 7, 2018 · 1 comment
Labels
enhancement New feature or request

Comments

@kmader
Copy link
Collaborator

kmader commented Sep 7, 2018

  • set/get bounding box
  • polygons
@kmader kmader added the enhancement New feature or request label Sep 7, 2018
@kmader
Copy link
Collaborator Author

kmader commented Sep 7, 2018

freehand (polygons)

  • get
freehand_shapes = cs_view.cur_image_view.get_tool_state().\
    get('imageIdToolState', {}).\
    get('', {}).\
    get('freehand', {}).\
    get('data', [])

setters are much more difficult if the old state is to be preserved

old_state = cs_view.cur_image_view.get_tool_state()
new_state = old_state.copy()
new_state['imageIdToolState']['']['freehand']['data'] = new_shape
cs_view.cur_image_view.set_tool_state(new_state)

aggressive setters are easy

freehand_defaults = {'visible': True, 'active': False, 
                     'invalidated': False, 'canComplete': False,
                     'highlight': False}
test_pts = [{'x': x_coord, 'y': y_coord,
             'highlight': True, 'active': False} for x_coord, y_coord in
           zip(range(5),  range(5))]
new_state = {'elementToolState': {},
             'elementViewport': {},
             'imageIdToolState': {'': {'freehand': {'data': [
    dict(handles=test_pts, **freehand_defaults)]}}}}
cs_view.cur_image_view.set_tool_state(new_state)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant