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

Visualize tracked cells and their features #13

Merged
merged 33 commits into from
Oct 18, 2024
Merged

Visualize tracked cells and their features #13

merged 33 commits into from
Oct 18, 2024

Conversation

ziw-liu
Copy link
Collaborator

@ziw-liu ziw-liu commented Jul 22, 2024

Visualize TCZYX images and TYX tracking labels.

Loads T(N*Z) UMAP embeddings into the labels layer's attribute to be used with napari-clusters-plotter.

Hover on input fields to view tips.

Before testing

Install again with pip install -e ".[dev]".

Apple silicon users must install higra from conda-forge before installing this plugin. Upstream issue: higra/Higra#249

@ziw-liu ziw-liu added the enhancement New feature or request label Jul 22, 2024
@mattersoflight
Copy link
Collaborator

mattersoflight commented Jul 23, 2024

@ziw-liu can you point me to paths of matching zarr stores so I can try this out?. Found them in code.

@mattersoflight
Copy link
Collaborator

@ziw-liu installing napari-clusters-plotter via mamba as per the README of project breaks the napari environment. pip install napari-clusters-plotter plays well with our other instructions on Wiki.

@mattersoflight
Copy link
Collaborator

mattersoflight commented Jul 24, 2024

The loading crashed while trying the FOV B/4/0 and is quite slow with B/4/2 on the login-02 node. Slowest parts are loading the movie and, somewhat surprisingly, loading features.

What contributes to the slow loading of features? Can we lazy load time points, given the typical XYZ chunks?

@mattersoflight
Copy link
Collaborator

@ziw-liu I now see a peculiar behavior. The INFO logs say that the data is being loaded, but the canvas stays empty. Let's take a look at this in person.

@ziw-liu
Copy link
Collaborator Author

ziw-liu commented Jul 24, 2024

@mattersoflight a know issue is that napari-clusters-plotter does not work with the new napari 0.5.0: BiAPoL/napari-clusters-plotter#308 (comment). However 0.5.0 brings useful features for users of other widgets so I didn't pin the version. I'm also seeing flakiness on HPC with the also newly released PyQt 6.7.1, sometimes using PyQt5 seems better.

also redo packaging with pyproject.toml
@ziw-liu
Copy link
Collaborator Author

ziw-liu commented Jul 24, 2024

@mattersoflight Now if you do:

pip install -e ".[dev]"

This will include [all] that installs napari, pyqt5, and napari-clusters-plotter.

@mattersoflight
Copy link
Collaborator

@ziw-liu works well. I enjoyed watching cells move from one part of UMAP space to another. The viewer widget can use a few tweaks (after the current work on data formats and VisCy is completed):

  • show tracks (via napari.view_tracks().
  • rename the fields for clarity.

@Soorya19Pradeep
Copy link

Soorya19Pradeep commented Sep 12, 2024

@ziw-liu, I was able to use the plugin as well. I can see the whole track of the cell starting from timepoint 0. Is it possible to visualize the progression of tracking along time instead?
image
I think I can see the progression sliding over the z-slice slider though.

@ziw-liu
Copy link
Collaborator Author

ziw-liu commented Sep 13, 2024

@Soorya19Pradeep trajectory dimensionality has been fixed.

@mattersoflight
Copy link
Collaborator

mattersoflight commented Sep 16, 2024

@ziw-liu the updated field names read well.

Following improvements are needed:

  • dependencies for the plugin need to be worked out and documented. I needed to install the following:

    • iohub from github (main branch)
    • ultrack
      Since this plugin is experimental, why not install iohub from github?
      Although napari-clusters-plotter requires numpy ~<1.26, it worked just fine with numpy 2.0.2 installed by ultrack.
  • Improve the analysis workflow:

    • compute the 3-component UMAP and 6-component PCA across all FOVs in advance to enable comparison of cells across FOVs.
    • rename the widget to view embedding dynamics.
    • our widget loads the napari-clusters-plotter/plotter-widget with correct layer selected. We don't need napari-clusters-plotter/dimensionality-reduction.
  • Clear the layers when Load button is pressed. If layers are present, and the Load button is pressed, I get an error.

  Signal emitted at: /hpc/mydata/shalin.mehta/envs/ndutils/lib/python3.11/site-packages/magicgui/widgets/bases/_value_widget.py:71, in _on_value_change
    >  self.changed.emit(value)

  Callback error at: /hpc/mydata/shalin.mehta/envs/ndutils/lib/python3.11/site-packages/napari/layers/_scalar_field/scalar_field.py:381, in _get_level_shapes
    >  shapes = [self.data.shape]

    Local variables:
       data = [array([[[[547.1515 , 524.1734 , 539.83496, ..., 572.00104, ...

@mattersoflight
Copy link
Collaborator

mattersoflight commented Sep 16, 2024

Animations like the following are handy for exploring each FOV. The speed of analysis will improve if we don't have to do the dimensionality reduction for each FOV.
https://github.com/user-attachments/assets/97fc8824-622b-44ff-b324-212932fc08b3

@mattersoflight
Copy link
Collaborator

mattersoflight commented Sep 16, 2024

I couldn't cluster the instances manually - perhaps because I have napari 0.5. I get the following error when I draw an ROI.

File "/hpc/mydata/shalin.mehta/envs/ndutils/lib/python3.11/site-packages/napari_clusters_plotter/_Qt_code.py", line 516, in onselect
    self.parent.manual_clustering_method(self.ind_mask)
  File "/hpc/mydata/shalin.mehta/envs/ndutils/lib/python3.11/site-packages/napari_clusters_plotter/_plotter.py", line 125, in manual_clustering_method
    self.run(
  File "/hpc/mydata/shalin.mehta/envs/ndutils/lib/python3.11/site-packages/napari_clusters_plotter/_plotter.py", line 730, in run
    self._update_cluster_image(
  File "/hpc/mydata/shalin.mehta/envs/ndutils/lib/python3.11/site-packages/napari_clusters_plotter/_plotter.py", line 805, in _update_cluster_image
    self.visualized_layer = self._draw_cluster_image(
                            ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/hpc/mydata/shalin.mehta/envs/ndutils/lib/python3.11/site-packages/napari_clusters_plotter/_plotter.py", line 862, in _draw_cluster_image
    cluster_layer = Layer.create(
                    ^^^^^^^^^^^^^
  File "/hpc/mydata/shalin.mehta/envs/ndutils/lib/python3.11/site-packages/napari/layers/base/base.py", line 2310, in create
    raise TypeError(
TypeError: _add_layer_from_data received an unexpected keyword argument ('color') for layer type labels

@ziw-liu
Copy link
Collaborator Author

ziw-liu commented Sep 16, 2024

dependencies for the plugin need to be worked out and documented.
perhaps because I have napari 0.5. I get the following error when I draw an ROI.

@mattersoflight I fixed it in 6d1b8f4. Did you run installation again after pulling?

@Soorya19Pradeep
Copy link

@ziw-liu , I am getting the following error after I pulled the changes:

File /hpc/mydata/soorya.pradeep/tracking/lib/python3.10/site-packages/npe2/_command_registry.py:34, in CommandHandler.resolve(self=CommandHandler(id='napari-iohub.get_reader', fun...on_name='napari_iohub._reader:napari_get_reader'))
32 self.function = utils.import_python_name(self.python_name)
33 except Exception as e:
---> 34 raise RuntimeError(
self.python_name = 'napari_iohub._reader:napari_get_reader'
self = CommandHandler(id='napari-iohub.get_reader', function=None, python_name='napari_iohub._reader:napari_get_reader')
35 f"Failed to import command at {self.python_name!r}: {e}"
36 ) from e
38 return self.function

RuntimeError: Failed to import command at 'napari_iohub._reader:napari_get_reader': No module named 'iohub.ngff.nodes'; 'iohub.ngff' is not a package

Any idea what happened here?

@ziw-liu
Copy link
Collaborator Author

ziw-liu commented Sep 16, 2024

@Soorya19Pradeep Please run pip install again after pulling. There were some dependency updates to make ultrack work.

@Soorya19Pradeep
Copy link

Thanks @ziw-liu ! It works well!

@ziw-liu ziw-liu changed the title View tracking labels Visualize tracked cells and their features Sep 18, 2024
@ziw-liu ziw-liu mentioned this pull request Sep 19, 2024
Copy link

@Soorya19Pradeep Soorya19Pradeep left a comment

Choose a reason for hiding this comment

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

I have tested visualizing tracks and features for the June dataset using these changes. Works really well!

@ziw-liu ziw-liu merged commit 28c49c2 into main Oct 18, 2024
10 checks passed
@ziw-liu ziw-liu deleted the view-tracks branch October 18, 2024 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants