haesleinhuepf / napari-skimage-regionprops

Feature extraction for labeled objects in images using regionprops from scikit-image
BSD 3-Clause "New" or "Revised" License
47 stars 13 forks source link

Make feature maps work for all layers #80

Open jo-mueller opened 1 year ago

jo-mueller commented 1 year ago

Hi @haesleinhuepf,

I made a little addon to the results table. I created a function create_featuremaps that generalizes the functionality that was previously in the _on_double_click() function of the TableWidget, which is triggered when the table header is doubleclicked and which generated a featuremap.

The _on_double_click() function now just calls the new create_featuremaps function and passes the layer and the feature column to it. The new function then visualizes the feature accordingly for every layer:

Since viewer.add_surface(data, features=features) is not allowed whereas viewer.add_surface(data, metadata = {'features':features}) is, I added a little snipped in the __init__ of the TableWidget, which moves the features from the metadata to layer.features.

QA

Let me know what you think!

codecov-commenter commented 1 year ago

Codecov Report

Patch coverage: 84.90% and project coverage change: +1.55 :tada:

Comparison is base (e38cc72) 86.08% compared to head (9731298) 87.63%.

:exclamation: Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #80 +/- ## ========================================== + Coverage 86.08% 87.63% +1.55% ========================================== Files 13 14 +1 Lines 1272 1351 +79 ========================================== + Hits 1095 1184 +89 + Misses 177 167 -10 ``` | [Impacted Files](https://app.codecov.io/gh/haesleinhuepf/napari-skimage-regionprops/pull/80?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Robert+Haase) | Coverage Δ | | |---|---|---| | [napari\_skimage\_regionprops/\_table.py](https://app.codecov.io/gh/haesleinhuepf/napari-skimage-regionprops/pull/80?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Robert+Haase#diff-bmFwYXJpX3NraW1hZ2VfcmVnaW9ucHJvcHMvX3RhYmxlLnB5) | `78.06% <14.28%> (+6.63%)` | :arrow_up: | | [napari\_skimage\_regionprops/\_parametric\_images.py](https://app.codecov.io/gh/haesleinhuepf/napari-skimage-regionprops/pull/80?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Robert+Haase#diff-bmFwYXJpX3NraW1hZ2VfcmVnaW9ucHJvcHMvX3BhcmFtZXRyaWNfaW1hZ2VzLnB5) | `93.12% <90.00%> (-1.38%)` | :arrow_down: | | [...ari\_skimage\_regionprops/\_tests/test\_featuremaps.py](https://app.codecov.io/gh/haesleinhuepf/napari-skimage-regionprops/pull/80?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Robert+Haase#diff-bmFwYXJpX3NraW1hZ2VfcmVnaW9ucHJvcHMvX3Rlc3RzL3Rlc3RfZmVhdHVyZW1hcHMucHk=) | `100.00% <100.00%> (ø)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

jo-mueller commented 1 year ago

@haesleinhuepf Thanks for having a look at this. I think what I'm still missing here is taking the associated transformations (scale, affine, rotation) into the newly created feature map. Are those attributes part of what concerns you regarding backwards-compatibility?

Otherwise I would say what I did is 70% refactoring, mainly.

jo-mueller commented 1 year ago

I added the scale, affine, rotation to the properties of the returned feature map and also amended the tests to make sure that these parameters are always set.

jo-mueller commented 11 months ago

Hi @haesleinhuepf , is there something I could do to see this through? I would be really happy to see this as part of the plugin :)