-
Notifications
You must be signed in to change notification settings - Fork 70
Filter Operations on Label2DModel and Shape #946
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
base: main
Are you sure you want to change the base?
Filter Operations on Label2DModel and Shape #946
Conversation
for more information, see https://pre-commit.ci
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #946 +/- ##
==========================================
+ Coverage 92.36% 92.44% +0.08%
==========================================
Files 48 48
Lines 7416 7470 +54
==========================================
+ Hits 6850 6906 +56
+ Misses 566 564 -2
🚀 New features to boost your workflow:
|
for more information, see https://pre-commit.ci
…om/selmanozleyen/spatialdata into feature/filter_operations_on_label
for more information, see https://pre-commit.ci
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.
Can this PR make use of
def match_sdata_to_table( |
def match_element_to_table( |
from spatialdata.datasets import blobs_annotating_element | ||
|
||
|
||
def test_filter_labels2dmodel_by_instance_ids(): |
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.
Parametrise, don't loop over inputs
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 loop here is for the multiple scales. Or did you mean something else?
preserved_ids = np.unique(labels_element[scale].image.compute()) | ||
assert filtered_ids == (set(all_instance_ids) - {2, 3}) | ||
# check if there is modification of the original labels | ||
assert set(preserved_ids) == set(all_instance_ids) | {0} |
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.
Use np.testing instead
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.
but these are all simple set comparisons. would have to order then compare the matrices which seems convoluted. But if you think the same still I can do it
|
||
@_filter_by_instance_ids.register(DataArray) | ||
def _(element: DataArray, ids_to_remove: list[int], instance_key: str) -> DataArray: | ||
del instance_key |
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.
Why this?
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.
you mean why del instance_key? It is to explicitly clarify that I won't be using it for this dispatch
@timtreis About using |
@timtreis now I make use of |
Hi @timtreis @ilan-gold ,
I am working on this PR also and thought maybe it will be smart to have the code I use there supported here because they seem useful at first glance. So I wrote and tested subset_sdata_by_table_mask in this PR.
@LucaMarconato I can't ask for reviews other than @ilan-gold do you know why?
Some notes
PointsModel
(GeoDataFrame
) it assumes the index isinstance_id
alwaysLabel2DModel
the image is assumed to have theinstance_id
s as values themselvesLabel2DModel
when the element is axr.DataTree
it assumes the keys are the different scalesscanpy.pp.filter_cells
Code excerpt from tests to demonstrate the usage: