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

Bug fix and improvement in TrackMate export #90

Merged
merged 3 commits into from
Feb 29, 2024

Conversation

qin-yu
Copy link
Contributor

@qin-yu qin-yu commented Feb 29, 2024

Hey @JoOkuma,

@tischi and I encountered a small but critical and elusive bug, fixed by this PR.

image

Fig. 1. TrackMate. Before: no tracks | After: tracks | After: details

image

Fig. 2. Mastodon. After: tracks and details

The current test for exporting tracks to TrackMate solely verifies the inclusion of all spots in the output, neglecting tracking semantics. In this PR, I choose not to implement an additional test that merely converts the XML back, since the essential validation comes from the actual opening and viewing of successful tracks. I revised the function's name, though I suspect it has not been used for a while.

Before Fix

TrackMate launches with error:

Some errors occurred while reading file:

Unknown spot ID: 2000008
Could not find the detector element in file.
Could not find the tracker element in file.
Could not find the feature analyzer element.
Could not find the display-settings element. Returning user defaults.

Mastodon throws error only:

Exception in thread "Thread-8" java.lang.NullPointerException
	at org.mastodon.mamut.io.importer.trackmate.TrackMateImporter$Import.<init>(TrackMateImporter.java:429)
	at org.mastodon.mamut.io.importer.trackmate.TrackMateImporter.readModel(TrackMateImporter.java:236)
	at org.mastodon.mamut.launcher.MastodonLauncher.lambda$importMaMuT$18(MastodonLauncher.java:504)
	at java.lang.Thread.run(Thread.java:748)

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 71.42857% with 2 lines in your changes are missing coverage. Please review.

❗ No coverage uploaded for pull request base (main@09807e8). Click here to learn what that means.

Files Patch % Lines
ultrack/core/export/trackmate.py 71.42% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main      #90   +/-   ##
=======================================
  Coverage        ?   85.41%           
=======================================
  Files           ?       71           
  Lines           ?     3916           
  Branches        ?        0           
=======================================
  Hits            ?     3345           
  Misses          ?      571           
  Partials        ?        0           

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

Copy link
Member

@JoOkuma JoOkuma left a comment

Choose a reason for hiding this comment

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

Hi @qin-yu and @tischi, thanks once again for your contribution.

I think I figured out why we did not observe this bug before; we always assumed the id matches the data frame index. And this is not always true, especially depending on how you load/save your data frame.

Could you check if my suggestions fix your problem while avoiding the line

parent_spot_id = tracks_df.index[tracks_df['id'] == parent_id][0] # uniqueness checked above

It fixed the example that I generated on my side.

ultrack/core/export/trackmate.py Outdated Show resolved Hide resolved
ultrack/core/export/trackmate.py Show resolved Hide resolved
Co-authored-by: Jordão Bragantini <[email protected]>
@JoOkuma JoOkuma merged commit 5dc7839 into royerlab:main Feb 29, 2024
6 of 7 checks passed
@JoOkuma
Copy link
Member

JoOkuma commented Feb 29, 2024

LGTM! Thanks @qin-yu

JoOkuma added a commit that referenced this pull request Sep 3, 2024
* removing smallest  segments min_size/4

* removing smaller segments than min_size/4

* Update ultrack/core/segmentation/hierarchy.py

---------

Co-authored-by: Jordão Bragantini <[email protected]>
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.

3 participants