scikit-image icon indicating copy to clipboard operation
scikit-image copied to clipboard

Handle 2D labels in 3D images for convex hull calculation

Open zoccoler opened this issue 2 years ago • 3 comments

Hi scikit-image developers,

So I finally got some time to work around #6432 . I am basically providing an exception for the convex hull image calculation when there are 2D labels in 3D images. I drop one unitary axis and put it back by the end, so calculation is done as if it were a 2D image label.

Let me know if this solution seems reasonable to you and if there is anything missing. 😃 I also added two tests.

Description

This PR fixes #6432 .

Checklist

  • [x] Docstrings for all functions
  • [ ] Gallery example in ./doc/examples (new features only)
  • [ ] Benchmark in ./benchmarks, if your changes aren't covered by an existing benchmark
  • [x] Unit tests
  • [x] Clean style in the spirit of PEP8
  • [x] Descriptive commit messages (see below)

For reviewers

  • Check that the PR title is short, concise, and will make sense 1 year later.
  • Check that new functions are imported in corresponding __init__.py.
  • Check that new features, API changes, and deprecations are mentioned in doc/release/release_dev.rst.
  • There is a bot to help automate backporting a PR to an older branch. For example, to backport to v0.19.x after merging, add the following in a PR comment: @meeseeksdev backport to v0.19.x
  • To run benchmarks on a PR, add the run-benchmark label. To rerun, the label can be removed and then added again. The benchmark output can be checked in the "Actions" tab.

zoccoler avatar Aug 26 '22 15:08 zoccoler

Hello @zoccoler! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! :beers:

Comment last updated at 2022-08-29 07:02:00 UTC

pep8speaks avatar Aug 26 '22 15:08 pep8speaks

Valeu @zoccoler! Tests are returning the following errors:

=================================== FAILURES ===================================
________________________ test_image_convex_3D_label_2D _________________________

    def test_image_convex_3D_label_2D():
>       img = regionprops(SAMPLE_3D_LABEL_2D())[0].image_convex
E       TypeError: 'numpy.ndarray' object is not callable

scikit-image/skimage/measure/tests/test_regionprops.py:342: TypeError
________________________ test_image_convex_3D_label_1D _________________________

    def test_image_convex_3D_label_1D():
>       img = regionprops(SAMPLE_3D_LABEL_1D())[0].image_convex
E       TypeError: 'numpy.ndarray' object is not callable

scikit-image/skimage/measure/tests/test_regionprops.py:354: TypeError

Maybe some weird conversion in the way. Could you check the values regionprops(SAMPLE_3D_LABEL_1D())[0].image_convex is returning? Thanks again!

alexdesiqueira avatar Aug 26 '22 17:08 alexdesiqueira

Hi @alexdesiqueira ! Sorry, there was a typo, tests are working now.

zoccoler avatar Aug 29 '22 07:08 zoccoler

Hi @jni ,

could you take a look at @zoccoler work here?

Thank you!

Best, Robert

haesleinhuepf avatar Oct 05 '22 08:10 haesleinhuepf

@grlee77 Do you think this is the optimal solution? Should we not try and broadcast mask to input array?

stefanv avatar Oct 17 '22 19:10 stefanv

Hi everyone! I was wondering if we could merge this PR in a near future.

I am just asking because this is currently hampering some users from using regionprops in a napari plugin. Maybe a different solution could follow, but this easy fix would be much appreciated!

zoccoler avatar Jan 02 '23 10:01 zoccoler

@zoccoler I left a naive comment here:

https://github.com/scikit-image/scikit-image/pull/6493#issuecomment-1281394620

If you can respond to that, @lagru may be able to help get this over the line in time?

stefanv avatar Jan 02 '23 16:01 stefanv

@zoccoler @lagru How close are we on this one?

stefanv avatar Feb 06 '23 18:02 stefanv

Hi @stefanv , I'd say pretty close, depending on whether this fix is what you guys are looking for. I wanted to test locally again to better address @lagru 's comments, but as you know, I am unable to install scikit-image for developers properly now (due to #6494 )

zoccoler avatar Feb 07 '23 07:02 zoccoler