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

load_image_wrapper returns 5D data with channel_axis:1 #14

Merged
merged 3 commits into from
Jun 28, 2020

Conversation

will-moore
Copy link
Collaborator

When loading OMERO image, instead of looping through Channels, getting metadata and lazy data for each in turn,
we now get the 5D data (regardless of whether this is a multi-Z or multi-T image) and a single dict with channel_axis:1

This means that the data dimensions don't change and are consistent with the ome-zarr spec. Shape is (t, c, z, y, x).

@codecov-commenter
Copy link

codecov-commenter commented Jun 28, 2020

Codecov Report

Merging #14 into master will not change coverage.
The diff coverage is 0.00%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master     #14   +/-   ##
======================================
  Coverage    0.00%   0.00%           
======================================
  Files          11      11           
  Lines         724     723    -1     
======================================
+ Misses        724     723    -1     
Impacted Files Coverage Δ
src/napari_omero/plugins/loaders.py 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6d45d4c...e7849c4. Read the comment docs.

Copy link
Owner

@tlambert03 tlambert03 left a comment

Choose a reason for hiding this comment

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

love it. will definitely make things easier.

left a couple comments. but you can merge once you're ready (let me know if the merge button isn't available for you)



@timer
def get_data_lazy(image: ImageWrapper, c_index: int = 0) -> da.Array:
"""Get n-dimensional dask array, with delayed reading from OMERO image."""
def get_data_lazy(image: ImageWrapper) -> da.Array:
Copy link
Owner

Choose a reason for hiding this comment

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

proposal for trimming this down a bit?

@timer
def get_data_lazy(image: ImageWrapper) -> da.Array:
    """Get 5D dask array, with delayed reading from OMERO image."""
    nt, nc, nz, ny, nx = [getattr(image, f'getSize{x}')() for x in 'TCZYX']
    pixels = image.getPrimaryPixels()
    dtype = PIXEL_TYPES.get(pixels.getPixelsType().value, None)
    get_plane = delayed(timer(lambda idx: pixels.getPlane(*idx)))

    def get_lazy_plane(zct):
        return da.from_delayed(get_plane(zct), shape=(ny, nx), dtype=dtype)

    # 5D stack: TCZXY
    t_stacks = []
    for t in range(nt):
        c_stacks = []
        for c in range(nc):
            z_stack = []
            for z in range(nz):
                z_stack.append(get_lazy_plane((z, c, t)))
            c_stacks.append(da.stack(z_stack))
        t_stacks.append(da.stack(c_stacks))
    return da.stack(t_stacks)

Copy link
Collaborator

Choose a reason for hiding this comment

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

will continue this discussion on ome/omero-py#227

'contrast_limits': contrast_limits,
'name': names,
'visible': visibles,
'scale': scale,
Copy link
Owner

Choose a reason for hiding this comment

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

while we're at it, we might want to add something to the {'metadata': ... } field (in the met dict). That's a place where devs can put anything they want... we could drop the actual wrapper object there? or perhaps just the proxy string like "Image:1"?
Ultimately, I'm thinking down the road about saving ROIs and stuff back to the server. That's easy when we know we only have a single image open... but if we eventually allow multiple images to be open, we'll need to know which image the ROI corresponds to, and retaining some of the OMERO metadata will make it easier to know what our "options" are. thoughts?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Created #16 so we don't have to decide before merging this

@will-moore will-moore mentioned this pull request Jun 28, 2020
@will-moore will-moore merged commit 9fbea12 into tlambert03:master Jun 28, 2020
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.

4 participants