Created
October 7, 2021 16:04
-
-
Save d-v-b/0f1c3ed486329171795027345405dfbb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zarr | |
import napari | |
import click | |
# Challenge napari with some big data. | |
# Compare with how neuroglancer handles the same dataset: | |
# http://neuroglancer-demo.appspot.com/#!%7B%22dimensions%22:%7B%22x%22:%5B4e-9%2C%22m%22%5D%2C%22y%22:%5B4e-9%2C%22m%22%5D%2C%22z%22:%5B4e-9%2C%22m%22%5D%7D%2C%22position%22:%5B5877.4033203125%2C7050.5%2C5252.34033203125%5D%2C%22crossSectionScale%22:36.598234443678%2C%22projectionScale%22:16384%2C%22layers%22:%5B%7B%22type%22:%22image%22%2C%22source%22:%22n5://https://janelia-cosem-datasets.s3.amazonaws.com/jrc_fly-fsb-1/jrc_fly-fsb-1.n5/em/fibsem-uint16%22%2C%22tab%22:%22rendering%22%2C%22shaderControls%22:%7B%22normalized%22:%7B%22range%22:%5B1773%2C4458%5D%7D%7D%2C%22name%22:%22fibsem-uint16%22%7D%5D%2C%22selectedLayer%22:%7B%22visible%22:true%2C%22layer%22:%22fibsem-uint16%22%7D%2C%22layout%22:%224panel%22%7D | |
containerPath = 's3://janelia-cosem-datasets/jrc_fly-fsb-1/jrc_fly-fsb-1.n5' | |
groupPath = 'em/fibsem-uint16' | |
@click.command() | |
@click.argument('mode', type=str, default='easy') | |
def show_n5(containerPath=containerPath, groupPath=groupPath, mode='easy'): | |
contrast_limits=(0,4700) | |
cmap = 'gray_r' | |
group = zarr.open(zarr.N5FSStore(containerPath), path=groupPath) | |
# get multiscale pyramid as a list of arrays | |
arrays = list(dict(group.arrays()).values()) | |
click.echo(arrays) | |
if mode == 'easy': | |
# show the smallest array | |
to_show = arrays[-1] | |
elif mode == 'hard': | |
# show the full pyramid | |
to_show = arrays | |
else: | |
raise ValueError("Mode {mode} not recognized. Choose from `easy` or `hard`") | |
viewer = napari.view_image(to_show, contrast_limits=contrast_limits, colormap=cmap) | |
napari.run() | |
if __name__ == '__main__': | |
show_n5() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment