|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": 1, |
| 6 | + "metadata": {}, |
| 7 | + "outputs": [], |
| 8 | + "source": [ |
| 9 | + "import napari\n", |
| 10 | + "from skimage import io, measure\n", |
| 11 | + "import h5py\n", |
| 12 | + "from napari_animation import AnimationWidget\n" |
| 13 | + ] |
| 14 | + }, |
| 15 | + { |
| 16 | + "cell_type": "code", |
| 17 | + "execution_count": 2, |
| 18 | + "metadata": {}, |
| 19 | + "outputs": [], |
| 20 | + "source": [ |
| 21 | + "im = io.imread(\"/Users/thomasathey/Documents/mimlab/mouselight/input/images/first10_quantitative/images/2018-08-01_1_first10_quantitative.tif\")\n", |
| 22 | + "\n", |
| 23 | + "f = h5py.File(\"/Users/thomasathey/Documents/mimlab/mouselight/input/images/first10_quantitative/2018-08-01_1_first10_quantitative_Probabilities.h5\", 'r')\n", |
| 24 | + "pred = f.get('exported_data')\n", |
| 25 | + "pred = pred[:,:,:,1]\n", |
| 26 | + "probs = pred\n", |
| 27 | + "\n", |
| 28 | + "thresh = 0.5\n", |
| 29 | + "mask = probs > thresh\n", |
| 30 | + "labs = measure.label(mask)\n", |
| 31 | + "\n", |
| 32 | + "res = [0.3,0.3,1]" |
| 33 | + ] |
| 34 | + }, |
| 35 | + { |
| 36 | + "cell_type": "code", |
| 37 | + "execution_count": 3, |
| 38 | + "metadata": {}, |
| 39 | + "outputs": [ |
| 40 | + { |
| 41 | + "name": "stderr", |
| 42 | + "output_type": "stream", |
| 43 | + "text": [ |
| 44 | + "/Users/thomasathey/Documents/mimlab/mouselight/docs_env/lib/python3.8/site-packages/napari_animation/_qt/keyframeslist_widget.py:156: FutureWarning: Themes were changed to use evented model with Pydantic's color type rather than the `rgb(x, y, z)`. You can get the old color by calling `color.as_rgb()`. The `as_dict=True` option will be removed in 0.X.X\n", |
| 45 | + " self.setStyleSheet(template(qss_template, **get_theme(theme_name)))\n" |
| 46 | + ] |
| 47 | + } |
| 48 | + ], |
| 49 | + "source": [ |
| 50 | + "viewer = napari.Viewer(ndisplay=3)\n", |
| 51 | + "viewer.add_image(im, scale=res)\n", |
| 52 | + "viewer.add_labels(mask, scale=res)\n", |
| 53 | + "viewer.add_labels(labs, scale=res)\n", |
| 54 | + "animation_widget = AnimationWidget(viewer)\n", |
| 55 | + "viewer.window.add_dock_widget(animation_widget, area=\"right\")\n", |
| 56 | + "viewer.camera.angles = [90, 90, 0]\n", |
| 57 | + "viewer.scale_bar.visible = True\n" |
| 58 | + ] |
| 59 | + }, |
| 60 | + { |
| 61 | + "cell_type": "code", |
| 62 | + "execution_count": null, |
| 63 | + "metadata": {}, |
| 64 | + "outputs": [], |
| 65 | + "source": [] |
| 66 | + } |
| 67 | + ], |
| 68 | + "metadata": { |
| 69 | + "interpreter": { |
| 70 | + "hash": "5dc00d68ff54f8375e99934614da4863299fb9e10af4294c095b7f517546ff26" |
| 71 | + }, |
| 72 | + "kernelspec": { |
| 73 | + "display_name": "Python 3.8.10 64-bit ('docs_env': venv)", |
| 74 | + "language": "python", |
| 75 | + "name": "python3" |
| 76 | + }, |
| 77 | + "language_info": { |
| 78 | + "codemirror_mode": { |
| 79 | + "name": "ipython", |
| 80 | + "version": 3 |
| 81 | + }, |
| 82 | + "file_extension": ".py", |
| 83 | + "mimetype": "text/x-python", |
| 84 | + "name": "python", |
| 85 | + "nbconvert_exporter": "python", |
| 86 | + "pygments_lexer": "ipython3", |
| 87 | + "version": "3.8.10" |
| 88 | + }, |
| 89 | + "orig_nbformat": 4 |
| 90 | + }, |
| 91 | + "nbformat": 4, |
| 92 | + "nbformat_minor": 2 |
| 93 | +} |
0 commit comments