-
Notifications
You must be signed in to change notification settings - Fork 116
[3/3] Add make_stitched_labels (materialise stitched labels) #1207
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
Changes from 9 commits
45165a8
afb4bde
8a196c8
9a6f45d
83c0e32
c0b24fa
5ad923e
9e59901
411de10
228f721
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,12 +31,11 @@ | |
| from scipy.ndimage import binary_closing | ||
| from scipy.sparse import csr_matrix | ||
| from scipy.sparse.csgraph import connected_components | ||
| from skimage.measure import find_contours, regionprops | ||
| from skimage.measure import label as cc_label | ||
| from skimage.measure import regionprops | ||
| from skimage.morphology import disk as morph_disk | ||
| from spatialdata._logging import logger as logg | ||
|
|
||
| from squidpy.experimental.utils._geometry import equivalent_diameter, largest_contour | ||
| from squidpy.experimental.utils._labels import iter_chunked_regionprops, resolve_labels_array | ||
| from squidpy.experimental.utils._params import resolve_params | ||
|
|
||
|
|
@@ -302,10 +301,12 @@ def _extract_cut_edges( | |
| if not cell_mask.any(): | ||
| continue | ||
| outlier_crops[lid] = cell_mask | ||
| # 1px zero-pad so cells filling their bbox still trace a closed contour. | ||
| mask = np.pad(cell_mask.astype(np.float32), 1, mode="constant", constant_values=0) | ||
| contour = largest_contour(mask) | ||
| if contour is None: | ||
| contours = find_contours(mask, 0.5) | ||
| if not contours: # degenerate mask traces nothing; skip it | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if not contours is ambigious if it means it's 0 the check should be to if contours != 0 or something like this.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah then len(contours) == 0 then right? that's what I mean by being unclear |
||
| continue | ||
| contour = max(contours, key=len) | ||
| contour_global = contour.copy() | ||
| contour_global[:, 0] += min_r - 1 | ||
| contour_global[:, 1] += min_c - 1 | ||
|
|
@@ -315,7 +316,7 @@ def _extract_cut_edges( | |
| cy = float(ys.mean()) + min_r - 1 | ||
| cx = float(xs.mean()) + min_c - 1 | ||
| area = float(mask.sum()) | ||
| eq_diameter = equivalent_diameter(area) | ||
| eq_diameter = float(np.sqrt(4 * area / np.pi)) # diameter of the equal-area circle | ||
| min_len = max(min_edge_length, min_edge_length_ratio * eq_diameter) | ||
|
|
||
| # find_contours places level set 0.5 outside the integer pixel boundary. | ||
|
|
||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.