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

Plates #57

Merged
merged 21 commits into from
Nov 17, 2020
Merged

Plates #57

merged 21 commits into from
Nov 17, 2020

Conversation

will-moore
Copy link
Member

@will-moore will-moore commented Oct 22, 2020

Test sets:

To test:

  • Install ome-zarr-py from this branch
  • cd ome-zarr-py and pip install -e .
  • Open plates (urls above) via e.g:
$ napari https://minio-dev.openmicroscopy.org/idr/idr0002-heriche-condensation/plate1_1_013/pr_43/422.zarr 
  • Plates should be displayed in a grid with Well labels overlaid.
  • You can view an individual Well by appending e.g. /A/1/ to the URL (actually, this will only work with the last plate above. The others were generated with an acquisition level in the hierarchy and need to add e.g. 0/A/1 or Run 422/A/1 for idr0002.

Screenshot 2020-10-23 at 07 18 04

@will-moore
Copy link
Member Author

will-moore commented Oct 22, 2020

Not doing very well with pre-commit here.
With pre-commit install I can't commit because flake8 is failing.
When I run flake8 locally it fails on a ton of files that I've not edited.

So I ran flake8 and fixed a bunch of errors, but when I try to commit them
the pre-commit hook fails and black undoes all the changes I just made!
So, reverted to pre-commit uninstall again!

@will-moore
Copy link
Member Author

will-moore commented Oct 22, 2020

Exploring ways to add click handling to napari....
With ome-zarr-py using this branch.
Save this code to eg. plate.py:


import numpy as np
import napari
from string import ascii_uppercase


with napari.gui_qt():
    np.random.seed(1)
    viewer = napari.Viewer()

    # TODO: take this from command-line args
    # plate_url = "422.zarr".    # local usage
    plate_url = "https://s3.embassy.ebi.ac.uk/idr/share/community-call-2020-10-29/idr0002-heriche-condensation/plate1_1_013/422.zarr"

    field = "Field_1"

    plate_layers = viewer.open(plate_url)

    for plate_layer in plate_layers:

        @plate_layer.mouse_drag_callbacks.append
        def get_connected_component_shape(layer, event):
            # mouse-down event - ignore
            yield
            dragged = False
            # on move event
            while event.type == 'mouse_move':
                dragged = True
                yield
            # on release - ignore if user dragged
            if dragged:
                return

            click_x = layer.coordinates[-1]
            click_y = layer.coordinates[-2]

            # If user clicked on the Shapes layer, need to query other layers for Plate.shape
            # TODO: add the width and height to layer metadata
            for layer in viewer.layers:
                try:
                    plate_width = layer.data.shape[-1]
                    plate_height = layer.data.shape[-2]
                    break
                except Exception:
                    pass

            # Use 'plate' metadata to work out which Well was clicked
            print(layer.metadata)
            if "plate" in layer.metadata:
                plate = layer.metadata['plate']
                rows = plate['rows']
                columns = plate['columns']
                plateAcquisitions = plate.get('plateAcquisitions', [{'path': '0'}])
                run = plateAcquisitions[0]['path']
                print (rows, columns, plate_width, plate_height)
                well_width = plate_width // columns
                well_height = plate_height // rows
                row = int(click_y // well_height)
                column = int(click_x // well_width)
                print('row', row, 'column', column)

                # Open the Image from clicked Well
                field_url = f'{plate_url}/{run}/{ascii_uppercase[row]}/{column + 1}/{field}/'
                print('Open', field_url)
                well_name = f'{ascii_uppercase[row]}{column + 1}'
                napari.view_path(field_url)

Then run python plate.py

This loads the stitched plate.
When you click a Well (with one of the stitched plate layers selected), it works out which Well you clicked on and opens that Image - and renames the layers with the Well name. E.g. in this screenshot, A1 was clicked:

Screenshot 2020-10-22 at 22 18 42

EDIT: updated to open Well in new window.

@will-moore
Copy link
Member Author

will-moore commented Oct 23, 2020

That last commit adds Well labels and outlines (see screenshot above)

@joshmoore
Copy link
Member

Nice!

@will-moore
Copy link
Member Author

Running $ pre-commit run -a locally is passing now...

@will-moore
Copy link
Member Author

Travis is failing because napari 0.4.0 release has dropped python 3.6

@will-moore
Copy link
Member Author

will-moore commented Nov 5, 2020

With that last commit we can open a single Well, showing fields in a grid, using data exported with ome/omero-cli-zarr#43
e.g. 3 x 3 grid stitches together well in this example (but loading stitching together 9 x 1080 * 1080 images is very slow)

$ napari https://minio-dev.openmicroscopy.org/idr/idr0033-rohban-pathways/41744_illum_corrected/pr_43/5966.zarr/0/H/6/

Screenshot 2020-11-05 at 15 07 25

@will-moore
Copy link
Member Author

Showing a Plate exported with ome/omero-cli-zarr#43

napari https://minio-dev.openmicroscopy.org/idr/idr0094-ellinger-sarscov2/screenB/7825.zarr/

Screenshot 2020-11-05 at 15 42 18

Copy link
Member

@joshmoore joshmoore left a comment

Choose a reason for hiding this comment

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

I generated a fake plate:

mkfake  plate -runs 2 -rows 2 -fields 2
omero import plate.fake/
omero zarr export Plate:101
napari 101.zarr/

and see:

pr-57-a

👍 (No acquisitions expected yet, right?)

ome_zarr/reader.py Outdated Show resolved Hide resolved
@will-moore
Copy link
Member Author

I'm not yet filtering by acquisition here: e.g.
napari https://minio-dev.openmicroscopy.org/idr/idr0001-graml-sysgro/JL_120731_S6A/pr_45/2551.zarr/C/4/&acquisition=2661
filters by acquisition in vizarr but not in napari:

Screenshot 2020-11-16 at 16 17 43

Copy link
Member

@joshmoore joshmoore left a comment

Choose a reason for hiding this comment

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

Thanks for getting rid of the print statements. Locally, napari -v 101.zarr # <- a plate! works fine. Getting this in.

@joshmoore joshmoore merged commit ea299f3 into ome:master Nov 17, 2020
@pwalczysko
Copy link
Member

If I do

napari "https://minio-dev.openmicroscopy.org/idr/idr0002-heriche-condensation/plate1_1_013/pr_43/422.zarr/Run 422/A/1"

then it works and shows the well A1. But, when I play the timelapse, it seems to persistently play the frames between 8 and 18, and loop. Is there any explanation for that ? Update: When I clicked on the timebar, the movie jumped as expected to much higher framenumbers. When I clicked the timelapse play button again, it started to play the whole video, albeit in jumps of some 5 or 10 frames per displayed step, so no smoothness.

@pwalczysko
Copy link
Member

on the sparse plate

napari https://minio-dev.openmicroscopy.org/idr/idr0004-thorpe-rad52/P101/pr_43/1751.zarr

18:30:21 ERROR Failed to load 0/D/12/0/3
18:30:21 ERROR Failed to load 0/G/11/0/3
18:30:21 ERROR Failed to load 0/H/10/0/3
18:30:21 ERROR Failed to load 0/F/12/0/3

Do we want to supress the message if and when there is no well ?

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