-
Notifications
You must be signed in to change notification settings - Fork 3
68 create a widget for vesicle pool assignments #73
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
68 create a widget for vesicle pool assignments #73
Conversation
…tation layer's properties attribute
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic for the pool assignments could be simplified a lot:
- First find all the vesicles that are in any pool. From previous queries, if any, and the current query.
- That is easy: get the ids matching the current query (currently
valid_vesicle_ids), and combine it with ids from past queries (if any), which you have access to via the layer properties (if it exists). - If the pool name of the current query is already in the past pool names, then you over-write the ids for that poolname.
- That is easy: get the ids matching the current query (currently
- After this you don't need to introduce any special cases, just filter out the vesicle ids not in any pool, construct the properties and over-write the layer data and properties. (Or add a new layer with the properties if this is the first query)
| props=props, | ||
| ) | ||
| self._add_table(coords, radii, props, name="Vesicles") | ||
| self._add_table(coords, radii, props, name="Vesicles Morphology") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The proper spelling is "Vesicle Morphology".
| pool_id = len(np.unique(layer.properties["pool"])) + 1 | ||
| # compute vesicles with new pool_id and properties | ||
| for vesicle_id in valid_vesicle_ids: | ||
| new_layer_data[segmentation == vesicle_id] = pool_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few problems here:
- You set the value in the layer to the
pool_id. Instead we should keep the vesicle ids intact, but just filter out the vesicles that are not part of any pool. - The whole pool assignment and property logic could be simplified a lot, see the general comment for how.
- The way you do this is in general inefficient. Instead of solving this with a loop you can for example do
filtered_vesicle_mask = ~np.isin(segmentation, valid_vesicle_ids)
new_layer_data[filtered_vesicle_mask] = 0|
I have simplified the implementation of the vesicle pool widget. It does not work 100% yet, but it should be easy to finish now. I will merge it despite the widget not 100% working, as I have fixed many other issues in the plugins and did quite some refactoring. |
@constantinpape
I detected following issue with the current logic: after querying a vesicle pool and then querying a new vesicle pool, you cannot go back to the first one and edit it, as it will be overridden.