-
Notifications
You must be signed in to change notification settings - Fork 10
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
Fix Tracking Layer #286
Fix Tracking Layer #286
Conversation
* The generate_cluster_tracks() function did not work with the version without map_array * A unit test is added to proof this
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
…ml to enable related unit test
for more information, see https://pre-commit.ci
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #286 +/- ##
==========================================
+ Coverage 76.39% 77.17% +0.78%
==========================================
Files 16 16
Lines 1860 1893 +33
==========================================
+ Hits 1421 1461 +40
+ Misses 439 432 -7 ☔ View full report in Codecov by Sentry. |
Hey @stefanhahmann ,
Will do some testing now and report back. |
Okay so some testing on the very simple tracking example you implemented in the unit test showed me that actually the problem did not lie with the generate_cluster_immage function but indeed was caused by the wrong extraction of labels in the generate_cluster_tracks function.
Regarding this: do you maybe have a simple tracking example dataset you might want to share which I can use for testing? After I have tested this in detail I will adjust the code and merge. Thanks for the unit tests again! |
Hm, I'm a bit confused. I just checkout your branch, put my new
Edit: Ah, @Cryaaa found the reason. |
…ile and removing tests that are covered elsewhere
for more information, see https://pre-commit.ci
@stefanhahmann, |
* The unit test before had two time frames containing each a 3d image. Both 3d images contained *all* labels that occur in the full timelapse * The unit test now has two time frames containing each a 3d image. The 3d image of the first timeframe now does not contain all labels that occur in the full timelapse.
…_cluster_image function * int(np.max(label_image)) could lead to an index out of bounds error, in case where a single timeframe does not contain all labels of the complete timelapse
for more information, see https://pre-commit.ci
…name generate_cluster_image to generate_cluster_image_new
for more information, see https://pre-commit.ci
Sorry for the confusion. I updated the respective unit test so that it actually fails, cf.: 1d952d7 The unit test did pass, since both timeframes included in it had all labels of the complete timelapse. If a single timeframe does not have all timeframes of the complete timelapse, it causes an array index out of bounds error. @Cryaaa and @thorstenwagner in b6e5f60 I have committed a suggestion how to fix this error with the new generate_cluster_image() version, but this breaks other tests: https://github.com/BiAPoL/napari-clusters-plotter/actions/runs/7212283328/job/19649645462 (test_cluster_image_generation_unsorted_non_sequential_labels() and test_generate_cluster_4d_labels()) Only with generate_cluster_image_old() all tests pass at the moment, cf.: 5957977 and https://github.com/BiAPoL/napari-clusters-plotter/actions/runs/7212550935/job/19650463473 Currently, I have no good idea how to make the new version of generate_cluster_image() pass all tests. |
for more information, see https://pre-commit.ci
With my fix, all tests pass. The problem is that my method assumes that label_list only contains labels that are actually part of the label_image, which is not the case for your track data. I think it should, and the implementation of |
… to an numpy array first.
…er then using np.max()
Regarding my very last commit of today: With that we reduce the runtime to
However, this is probably not relevant for the total runtime of that method. Anyway ... 🤓 |
I just want to mention: As soon this is merged, we can probably go back to the 'old' map_array function :-) |
Thanks for the fix.
Thanks for clarifying the assumptions of the new generate_cluster_image() method.
With the old implementation it did not matter, which labels were contained at which timepoint. However, I agree, that including only those labels that exist in the considered timepoint should be included. generate_cluster_tracks() can be optimized in this regard. Thanks to you fix, functionality does not currently depend on this optimization. |
@thorstenwagner, @stefanhahmann: I think we can merge this now that you have fixed some of the more specific details? |
Lgtm, from my side you can merge. |
The cluster layer was not generated for layers of type tracking layer in function generate_cluster_tracks()
This was caused by bugs in 2 functions():
This PR adds a bugfix for this. In order to do so also some recent changes regarding performance optimization had to be reverted (1c2ec0f, dcd83c1, 5fee912, 0800f48)
@thorstenwagner there is now a unit test for the cluster plotter in combination with tracking layers. Perhaps you could try, if you could make your performance optimizations with this as well?
The PR additionally adds some unit tests to check for bugs that had recently been introduced.