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

WIP: refactor contrastive learning code with virtual staining code #109

Closed
1 of 8 tasks
mattersoflight opened this issue Jul 17, 2024 · 7 comments · Fixed by #113
Closed
1 of 8 tasks

WIP: refactor contrastive learning code with virtual staining code #109

mattersoflight opened this issue Jul 17, 2024 · 7 comments · Fixed by #113
Assignees
Milestone

Comments

@mattersoflight
Copy link
Member

mattersoflight commented Jul 17, 2024

This issue tracks our progress toward integration of the contrastive learning code with virtual staining code.

Our preprocessing code is currently in good shape and consists of:

  • fluorescence deskewing/deconvolution: shrimPy
  • phase deconvolution: recOrder
  • Registration with fluorescence: shrimPy
  • virtual staining of nuclei and membrane: VisCy
  • Segmentation: VisCy (Adding segmentation utility functions  #108)
  • Tracking: ultrack

We are still improving the tracking to capture cell division and cells near the boundary of the FOV: @tayllatheodoro

Training
It works well via pytorch lightning CLI and configs. The dataloader also works well with the HCS data format.

Pending improvements:
Architecture :

Data loader and loss functions:

Prediction and evaluation
It works well via pytorch lightning CLI and configs.

In this round, we should make any changes in the code path that can affect the architecture.

@ziw-liu
Copy link
Collaborator

ziw-liu commented Jul 18, 2024

Currently (Slurm) Cellpose segmentation is implemented in shrimPy, and will be moved to the new bioimage analysis repo.

@Soorya19Pradeep I'm outdated! It's now in #108

@ziw-liu
Copy link
Collaborator

ziw-liu commented Jul 18, 2024

For the napari UI I think we should first try interacting with the plugin through standardized data files so we don't have to maintain our own interface.

@ziw-liu
Copy link
Collaborator

ziw-liu commented Jul 18, 2024

The napari-clusters-plotter plugin does not implement readers. So it relies on what's available in the napari layer list (features are stored as attribute of the labels layer).

I now think a workable way is to implement a custom reader in napari-iohub for the images and tracks so the visualization is easier (handle mixed dimensions and scales etc). The ultrack plugin does load the extra columns in its output CSVs as layer features so it can be used by the cluster plotter.

As for clustering, I think dimensionality reduction should be done beforehand on all the cells, instead of on the limited number of cells in each FOV.

@mattersoflight
Copy link
Member Author

mattersoflight commented Jul 19, 2024

The ultrack plugin does load the extra columns in its output CSVs as layer features so it can be used by the cluster plotter.

That's interesting. Can this work?

  • Write projected embeddings to the same table as the output of ultrack
  • load the tracks using ultrack plugin
  • use napari-cluster-plotter to visualize labels that match projected embeddings.
    If yes, we don't need to create a new widget.

@ziw-liu please go ahead and decide on a useful and low-maintenance solution.

@ziw-liu ziw-liu linked a pull request Jul 23, 2024 that will close this issue
@mattersoflight
Copy link
Member Author

mattersoflight commented Jul 23, 2024

@ziw-liu @alishbaimran Given our offline discussion, here is the prioritization of features:

  1. update data format and data module for efficiency + allow selection of channels to encode,
  2. define positive pairs based on temporal closeness, and
  3. pool different datasets.

You could partition the refactor in 3 PRs, each of which implements the above and is tested with the corresponding training run.

We will train contrastive phenotyping models via the python scripts and CLIs that wrap these scripts. We don't have to prioritize integration with lighting CLI yet.

@mattersoflight
Copy link
Member Author

@ziw-liu and @alishbaimran I think we can bypass the patchification step by chunking the Zarr store in C*Y*X sized chunks. The data chunked like this can be loaded fast enough on VAST since we just have to fetch the images within specific Z and T ranges. This will also simplify the processing pipeline and avoid the need to track one more data format.

I got this idea while exploring the data we are preparing for release with the paper on mantis.
Take a look at:
/hpc/projects/comp.micro/mantis/mantis_paper_data_release/figure_1.zarr

@ziw-liu ziw-liu reopened this Aug 2, 2024
@ziw-liu ziw-liu added this to the v0.3.0 milestone Oct 18, 2024
@ziw-liu
Copy link
Collaborator

ziw-liu commented Oct 18, 2024

@mattersoflight I consider the refactoring completed after #153. Feel free to open new issues for specific tasks.

@ziw-liu ziw-liu closed this as completed Oct 18, 2024
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 a pull request may close this issue.

6 participants