-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add method to create masks grouped by label id #6
base: master
Are you sure you want to change the base?
Conversation
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 ability to transform multidimensional labelled image into a series of ROIs with all masks for a given label alongside a dimension is a use case we keep encountering. One small downside of the approach proposed in this PR is that it makes strong assumptions about the planes and a new method would be required e.g. if one wanted to group masks by label across the time dimension.
If the main objective is to group all masks by label for a listof planes, another option might be to use the return value of mask_from_label_image
. As this API returns an ordered list of masks, where the list index is effectively the label value, it might be possible to combine it with Python's built-in zip/itertools.zip_longest
functions e.g.
from itertools import ziplongest
masks_per_plane = []
for z, plane in enumerate(planes):
masks = masks_from_label_image(plane, rgba, z, c, t, text, raise_on_no_mask=False)
masks_per_plane.append(masks)
masks_per_label = list(zip_longest(*masks_per_plane))
Note the example above will fill missing values with None
by default. For consistency, it might be preferable to fill it with empty masks.
Indeed, the index of the masks coming from |
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.
As discussed earlier today, let us drive this functionality with the IDR submission as a concrete use case while we make progress on the API implementation and tests.
Still relevant? |
Add a method to create masks from labelled z-stack image, grouped by label ids. These can used to create "3D'ish" ROIs. Input is a list of planes so that the output from the
getPlanes()
method can be used directly.