-
Notifications
You must be signed in to change notification settings - Fork 43
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
relabel block #664
base: main
Are you sure you want to change the base?
relabel block #664
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #664 +/- ##
==========================================
+ Coverage 91.83% 91.85% +0.02%
==========================================
Files 44 44
Lines 6781 6824 +43
==========================================
+ Hits 6227 6268 +41
- Misses 554 556 +2
|
Now also added helper function I think the PR is ready for review now. |
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.
hi @ArneDefauw , thanks a lot, super useful. I went back to this function in squidpy, and remember that we also did an additional step to harmonize the labels with dask image
from dask_image.ndmeasure._utils._label import (
connected_components_delayed,
label_adjacency_graph,
relabel_blocks,
)
# max because labels are not continuous (and won't be continuous)
label_groups = label_adjacency_graph(img, None, img.max())
new_labeling = connected_components_delayed(label_groups)
relabeled = relabel_blocks(img, new_labeling)
any reason for leaving this out? Otherwise for me it is good to go!
Hi @giovp , thanks for the review! Yes, I did not include the step to harmonize the labels across chunks due to some issues I observed when cell density is high, see also my previous comments. I make it a little bit more concrete with an example: So this is map_raster on a labels layer without harmonizing labels:
Then without using the harmonizing of labels I get: and with harmonizing of the labels using
I get: Which is not great, cells on the boundary of the chunks are merged together. A solution for this, is using this approach: But I do not know if you want this to be included in this PR, see also comment of @LucaMarconato #597 (comment). |
hi @ArneDefauw , sorry for late reply. I took a look at it's a nice approach I think, and I wonder if it should be included already here. Meaning, I am not sure how useful it is the output of relabelling without the across-block label harmonization. Yes, relabelling fix one step of the chunked segmentation, but the result is not really actionable/useful right? Or am I missing something? also @LucaMarconato wdyt? you can take a look at the output of the excellent post from @ArneDefauw before to understand visually what is the problem |
Yes, indeed, if you do not know how to do the across-block label harmonization, the result will not be very useful. On the other hand, there are probably many ways to do it. |
Follow up PR for #588, see discussion #597 for relabeling in case output data is a labels layer (i.e.
dims
does not containc
) via use of a bit shift.