quantumjot / btrack

Bayesian multi-object tracking
https://btrack.readthedocs.io
MIT License
311 stars 50 forks source link

Raise error when trying to measure properties from multichannel image #188

Closed nthndy closed 1 year ago

nthndy commented 1 year ago

Lmk if you'd rather this just switched USE_WEIGHTED = False, thought it more sensible to warn the user than redefine their input parameters.

quantumjot commented 1 year ago

Looks like the tests are failing - specifically this one which tests whether a 3D (volumetric) input can be used. Your code now throws an error when given an image volume, causing the test to fail:

  =================================== FAILURES ===================================
  ___________________________ test_intensity_image[3] ____________________________

  default_rng = Generator(PCG64) at 0x7F974E7F4580, ndim = 3

      @pytest.mark.parametrize("ndim", [2, 3])
      def test_intensity_image(default_rng, ndim):
          """Test using an intensity image."""
          img, centroids = create_test_image(ndim=ndim, binary=True)
          intensity_image = img * default_rng.uniform(size=img.shape)
  >       objects = utils.segmentation_to_objects(
              img[np.newaxis, ...],
              intensity_image=intensity_image[np.newaxis, ...],
              use_weighted_centroid=True,
              properties=("max_intensity",),
          )

  tests/test_utils.py:124: 

you can look at the log here: https://github.com/quantumjot/BayesianTracker/actions/runs/3437960703/jobs/5733408248#step:6:122

nthndy commented 1 year ago

trying an alternate approach to assessing whether an input intensity image is multichannel or not: the previous method could read a TZXY image as multichannel hence the test failing. Afaik there's not rigorous way of assessing whether the last dimension encodes the image channels without having a separate parameter to define. Still need to fix some other ways the localisation could fail though, just wanted to check this first.

codecov-commenter commented 1 year ago

Codecov Report

Base: 86.93% // Head: 86.88% // Decreases project coverage by -0.05% :warning:

Coverage data is based on head (f728294) compared to base (86ec60b). Patch coverage: 66.66% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #188 +/- ## ========================================== - Coverage 86.93% 86.88% -0.05% ========================================== Files 14 14 Lines 1523 1525 +2 ========================================== + Hits 1324 1325 +1 - Misses 199 200 +1 ``` | [Impacted Files](https://codecov.io/gh/quantumjot/BayesianTracker/pull/188?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Alan+R+Lowe) | Coverage Δ | | |---|---|---| | [btrack/\_localization.py](https://codecov.io/gh/quantumjot/BayesianTracker/pull/188?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Alan+R+Lowe#diff-YnRyYWNrL19sb2NhbGl6YXRpb24ucHk=) | `90.90% <66.66%> (-0.96%)` | :arrow_down: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Alan+R+Lowe). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Alan+R+Lowe)

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

deprecated-napari-hub-preview-bot[bot] commented 1 year ago

Preview page for your plugin is ready here: https://preview.napari-hub.org/quantumjot/BayesianTracker/188 Updated: 2023-01-19T17:17:50.164015

quantumjot commented 1 year ago

@nthndy - try merging with main now. That should fix the tests failing.