Open
Conversation
axiomcura
reviewed
Apr 21, 2026
Comment on lines
+388
to
+393
| max_distance = numpy.percentile( | ||
| distances, 95 | ||
| ) # Use 95 percentile to avoid outliers | ||
| # max_distance = numpy.max(distances) | ||
| max_distance = numpy.max(distances) | ||
| if max_distance == 0: |
Member
There was a problem hiding this comment.
Is this intentional, or is the percentile calculation meant to be used? Because max_distance gets overwritten.
|
|
||
|
|
||
| def classify_cells_into_shells( | ||
| coords: pandas.DataFrame or dict, |
Member
There was a problem hiding this comment.
I think you meant this?
Suggested change
| coords: pandas.DataFrame or dict, | |
| coords: pandas.DataFrame | dict, |
Comment on lines
+216
to
+220
| object_mask = nuclei_mask.copy() | ||
| object_mask[object_mask != obj_id] = 0 | ||
| object_mask[object_mask == obj_id] = 1 | ||
| # Get the centroid of the object | ||
| z, y, x = numpy.where(object_mask == 1) |
Member
There was a problem hiding this comment.
I don't think the copy is necessary. you can get away by doing this. Please double check c:
Suggested change
| object_mask = nuclei_mask.copy() | |
| object_mask[object_mask != obj_id] = 0 | |
| object_mask[object_mask == obj_id] = 1 | |
| # Get the centroid of the object | |
| z, y, x = numpy.where(object_mask == 1) | |
| z, y, x = numpy.where(nuclei_mask == obj_id) |
Comment on lines
+305
to
+310
| distances = numpy.array( | ||
| [ | ||
| numpy.sqrt((coord - centroid).T @ inv_cov @ (coord - centroid)) | ||
| for coord in coords | ||
| ] | ||
| ) |
Member
There was a problem hiding this comment.
Doing it in a for loops is really slow. Here's a fater alternative.
Suggested change
| distances = numpy.array( | |
| [ | |
| numpy.sqrt((coord - centroid).T @ inv_cov @ (coord - centroid)) | |
| for coord in coords | |
| ] | |
| ) | |
| diff = coords - centroid | |
| distances = numpy.sqrt(numpy.einsum("ij,jk,ik->i", diff, inv_cov, diff)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds the neighbors module/
What kind of change(s) are included?
Checklist
Please ensure that all boxes are checked before indicating that this pull request is ready for review.