Skip to content
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

maint: unify centroid computation #610

Merged
merged 9 commits into from
Nov 6, 2024
Merged

Conversation

AhmetNSimsek
Copy link
Collaborator

@AhmetNSimsek AhmetNSimsek commented Oct 29, 2024

This PR fixes #613 by using the robust centroid computation used in Region.spatial_props(). Now all centroid computation is done by finding the components of an image with skimage.measure.label.() and then finding the center of the non-zero values in the voxel space.

Also:

  • volume.ComponentSpatialProperties is introduced in place of region.SpatialPropCmpt.
  • region.SpatialProp is removed since it is not used and was only introduced for typing.
  • added tests
  • Allow user to not split to components

Not backward compatible:
Instead of using SpatialProps.components now the result of Volume.compute_spatial_props() is a list of ComponentSpatialProperties per component. If the image is not split to components then it will return a single ComponentSpatialProperties.

Note: this PR does not address #157. The root cause of this issue is the concaved geometry of the regions.

@AhmetNSimsek AhmetNSimsek requested a review from xgui3783 November 4, 2024 15:05
@AhmetNSimsek AhmetNSimsek removed the request for review from xgui3783 November 5, 2024 09:59
@AhmetNSimsek AhmetNSimsek requested a review from xgui3783 November 6, 2024 10:59
Copy link
Member

@xgui3783 xgui3783 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

codecov bot commented Nov 6, 2024

Codecov Report

Attention: Patch coverage is 29.16667% with 34 lines in your changes missing coverage. Please review.

Project coverage is 46.00%. Comparing base (8da694f) to head (dc63457).
Report is 162 commits behind head on main.

Files with missing lines Patch % Lines
siibra/volumes/volume.py 34.61% 17 Missing ⚠️
siibra/volumes/parcellationmap.py 9.09% 10 Missing ⚠️
siibra/core/region.py 16.66% 5 Missing ⚠️
siibra/locations/point.py 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #610      +/-   ##
==========================================
- Coverage   51.64%   46.00%   -5.64%     
==========================================
  Files          74       75       +1     
  Lines        7012     7232     +220     
==========================================
- Hits         3621     3327     -294     
- Misses       3391     3905     +514     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@AhmetNSimsek AhmetNSimsek merged commit e4fd452 into main Nov 6, 2024
36 of 39 checks passed
@AhmetNSimsek AhmetNSimsek deleted the maint_compute_centroids branch November 6, 2024 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some maps produce NaN centroids
2 participants