Load ome.zarr Image with labels from a public S3 repository, analyze using StarDist and compare results
Help improve this workflow!
This workflow has been published but could be further improved with some additional meta data:- Keyword(s) in categories input, output, operation
You can help improve this workflow by suggesting the addition or removal of keywords, suggest changes and report issues, or request to become a maintainer of the Workflow .
The image is referenced in the paper "NesSys: a novel method for accurate nuclear segmentation in 3D" published August 2019 in PLOS Biology: https://doi.org/10.1371/journal.pbio.3000388 and can be viewed online in the Image Data Resource . This original image was converted into the Zarr format. The analysis results produced by the authors of the paper were converted into labels and linked to the Zarr file which was placed into a public S3 repository. In this notebook, the Zarr file is then loaded together with the labels from the S3 storage and analyzed using StarDist . The StarDist analysis produces a segmentation, which is then viewed side-by-side with the original segmentations produced by the authors of the paper obtained via the loaded labels. Launch This notebook uses the environment_stardist.yml file. See Setup .
Code Snippets
2 3 4 5 | # Package to access data on S3 %pip install aiohttp==3.8.4 zarr==2.14.2 %pip install stardist==0.8.2 |
9 10 11 12 13 14 15 16 | import dask import dask.array as da import matplotlib.pyplot as plt %matplotlib inline from dask.diagnostics import ProgressBar import numpy import zarr |
20 | image_id = 6001247 |
24 | ENDPOINT_URL = 'https://uk1s3.embassy.ebi.ac.uk/' |
28 29 30 31 | def load_binary_from_s3(name, resolution='0'): root = '%s/%s/' % (name, resolution) with ProgressBar(): return numpy.asarray(da.from_zarr(ENDPOINT_URL + root)) |
35 36 37 | name = 'idr/zarr/v0.1/%s.zarr' % image_id data = load_binary_from_s3(name) print(data.shape) |
41 42 43 | name = 'idr/zarr/v0.1/%s.zarr/labels' % image_id labels = load_binary_from_s3(name) print(labels.shape) |
47 48 | from stardist.models import StarDist2D model_versatile = StarDist2D.from_pretrained('2D_demo') |
52 53 54 55 56 57 58 59 60 | from csbdeep.utils import normalize axis_norm = (0,1) img = normalize(data[0, 1, :, :, :], 1,99.8, axis=axis_norm) results = [] for im in img: new_labels, details = model_versatile.predict_instances(im) results.append(new_labels) label_slices = numpy.array(results) |
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | from ipywidgets import * def update(z=0): fig = plt.figure(figsize=(10, 10)) plt.subplot(121) c = 1 plt.imshow(data[0, c, z, :, :], cmap='gray') try: plt.imshow(labels[0, c, z, :, :], cmap='jet', alpha=0.5) except Exception: print(z) plt.subplot(122) plt.imshow(data[0, c, z, :, :], cmap='gray') plt.imshow(label_slices[z, :, :], cmap='jet', alpha=0.5) plt.tight_layout() fig.canvas.flush_events() interact(update, z= widgets.IntSlider(value=0, min=0, max=data.shape[2]-1, step=1, description="Select Z", continuous_update=False)) |
Support
- Future updates
Related Workflows
![psychip_snakemake](https://media.bioworkflows.com/bioworkflows/public_preview/791b56ccab3630bcb1746d66097f813640394655ed21d3c39cb591b7016d2994.jpg)
![ncov_2](https://media.bioworkflows.com/bioworkflows/public_preview/16bd34a67b114b98942f09d5bcfb47c01d0e12aaccac38e15c9bbcc5856d6139.jpg)
![cellranger-snakemake-gke](https://media.bioworkflows.com/bioworkflows/public_preview/1045115046015ac39a849801172555df3b41ec5023f7f7c8230f0640b8f89a2b.jpg)
![atlas](https://media.bioworkflows.com/bioworkflows/public_preview/2e9488df62bdb57adbd8f8a137263f57f970f5571566588f6242d63f73c67151.jpg)
![rna-seq-star-deseq2](https://media.bioworkflows.com/bioworkflows/public_preview/2b57d357da619c31943bbffc57e2cc955325669933c9b5b91e33b81fd78c18d4.jpg)
![dna-seq-gatk-variant-calling](https://media.bioworkflows.com/bioworkflows/public_preview/4b8eed0f6a179f18a43e601e653aee298718468aaf37ee1b3d0f8dddaffcaf6a.jpg)