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

implement a dialog for importing externally generated tracks from csv #109

Merged
merged 49 commits into from
Feb 19, 2025

Conversation

AnniekStok
Copy link
Collaborator

@AnniekStok AnniekStok commented Nov 18, 2024

Goals for this PR:

  • Import segmentations from zarr and tiff files
  • Automatically relabel segmentations if not unique across time
  • Import tracks from CSV with custom column names for required attributes (don't require exact string match to our internal names)
    • Allow specifying a seg_id column if the segmentations are not unique across time
  • Have the option to compute area from the segmentation (if there is one) or use a column of the CSV, or don't have it at all
  • Make the user specify metadata:
    • Dimensionality of data
    • Existance of segmentation
    • Scale of segmentation
  • Export custom features to csv from solution tracks

Copy link
Collaborator

@cmalinmayor cmalinmayor left a comment

Choose a reason for hiding this comment

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

I think this is mostly stuff we discussed Monday. I updated the file structure a bit to make an import_export folder, and I didn't see any circular import issues when I ran it, but let me know if there is anything weird. I'll keep thinking about how we want to generally handle attributes in a more consistent way too.

AnniekStok and others added 25 commits November 29, 2024 08:51
…uess fields and updates the name of the custom attributes when a column is selected
…_tracks instead. Update also view_external_tracks.py and documentation
…dinates does not match with the provided seg_id from the csv file, as this likely indicates that the wrong pair of files has been selected. Remove the warning about viewing tracks that are not a motile run
Update conda config and pyproject napari entrypoint to tracker
…anging them to integers and relabeling the segmentation to match the id, if necessary
… area is computed correctly if it is missing at import
@AnniekStok
Copy link
Collaborator Author

@cmalinmayor Some updates here: I have changed the import code to work with the unique node ids while still allowing importing from a seg that is not labeled by id but by track_id or something else. I also included tests. For export, I switched to the export_tracks function on SolutionTracks. I also made some changes in preparation of having multiple feature measurements (I have this working on a separate branch but I changed it here too even though we only have one measurement (area)).

@cmalinmayor
Copy link
Collaborator

@AnniekStok A couple quick notes in addition to my pushed changes (casting the track id to int was the easiest way to fix my numpy float issue):

  • Can we have an option to scale the points as well? In case people have coordinates in pixel space, not calibrated units. It can be a check box on the scaled units page that says "Scale the point coordiantes"
  • Currently if you try and load a segmentation zarr from the browse pop up dialog, it won't let you actually select it, because it is a directory. I think it's possible in the browse dialog to allow selecting directories?
  • It would be nice to add a tiny bit of text above the segmentation text box to say what kinds of segmentations are supported (.tif, .tiff, .zarr)
  • The option to compute area comes up even if you dont load a segmentation. I'm okay with this if it makes sense when we have more features, but it's a little wonky now

@AnniekStok
Copy link
Collaborator Author

AnniekStok commented Feb 17, 2025

@cmalinmayor Some updates:

  • points are now scaling automatically according to the x scale value. I also re-enabled setting it in the GUI, it seemed to be fine and I did not encounter the off-target effect any more (have to test more thoroughly still).
  • I changed the segmentation browse menu so that you can either choose a tiff file or a zarr folder (it was not possible to allow both .tiff files and .zarr folders at the same time in a single dialog, as far as I could find).
  • I have added some explanatory text for the segmentation file/folder
  • the area recompute should not pop up anymore if there is no segmentation.

I have additional updates on another branch, to allow importing of custom features for viewing in the plot. Maybe we want to merge this in here eventually as well.

The example script for importing external tracks still needs to be updated, I will look into that tomorrow and also do some additional tests and checks.

@cmalinmayor
Copy link
Collaborator

@AnniekStok My "final" reorganization is complete (I think). Some notes:

points are now scaling automatically according to the x scale value. I also re-enabled setting it in the GUI, it seemed to be fine and I did not encounter the off-target effect any more (have to test more thoroughly still).
I meant scaling them into world units from pixel coordinates, not scaling them in the UI, sorry! I set the UI value back to the default of "5", and we can leave supporting import from pixel coordinates to the next PR.

Otherwise, I mostly moved all the widgets into their own files inside a menus folder, and then split up CSV and Segmentation related functionality into separate pages (the segmentation file browser is now merged with the scaling information page).

I did try it with and without a segmentation on the hela example dataset, and also tried importing invalid data/options (selecting 3D for my 2D example). I'll approve this, and then when you get up, you can do a final test and merge if you like it!

Copy link
Collaborator

@cmalinmayor cmalinmayor left a comment

Choose a reason for hiding this comment

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

🎉 😃

…e sends update_buttons signal, this causes the menu to be set to the wrong index and you have to click next twice
@cmalinmayor cmalinmayor merged commit 85b6244 into main Feb 19, 2025
4 checks passed
@cmalinmayor cmalinmayor deleted the import_external_tracks_menu branch February 19, 2025 15:01
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.

2 participants