{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Usage: `niwidgets` examples\n", "\n", "An online interactive version of this notebook can be found on [Binder](https://mybinder.org/v2/gh/nipy/niwidgets/master?filepath=index.ipynb).\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Volume data\n", "\n", "The class for volume images is `NiftiWidget`. It takes a path to a `.nii` file as input." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Interactively plotting an image\n", "\n", "We'll start by demonstrating the most useful aspect of the package: Being able to interactively slice an image file. To do so, we will import one of the example files that ships with `niwidgets`, a T1 weighted structural scan." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "ac2e8e975d9549ef8a92e57aa05904a2", "version_major": 2, "version_minor": 0 }, "text/html": [ "

Failed to display Jupyter Widget of type interactive.

\n", "

\n", " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", " that the widgets JavaScript is still loading. If this message persists, it\n", " likely means that the widgets JavaScript library is either not installed or\n", " not enabled. See the Jupyter\n", " Widgets Documentation for setup instructions.\n", "

\n", "

\n", " If you're reading this message in another frontend (for example, a static\n", " rendering on GitHub or NBViewer),\n", " it may mean that your frontend doesn't currently support widgets.\n", "

\n" ], "text/plain": [ "interactive(children=(IntSlider(value=45, continuous_update=False, description='x', max=90), IntSlider(value=54, continuous_update=False, description='y', max=108), IntSlider(value=45, continuous_update=False, description='z', max=90), Dropdown(description='Colormap:', index=73, options=('Accent', 'Blues', 'BrBG', 'BuGn', 'BuPu', 'CMRmap', 'Dark2', 'GnBu', 'Greens', 'Greys', 'OrRd', 'Oranges', 'PRGn', 'Paired', 'Pastel1', 'Pastel2', 'PiYG', 'PuBu', 'PuBuGn', 'PuOr', 'PuRd', 'Purples', 'RdBu', 'RdGy', 'RdPu', 'RdYlBu', 'RdYlGn', 'Reds', 'Set1', 'Set2', 'Set3', 'Spectral', 'Vega10', 'Vega20', 'Vega20b', 'Vega20c', 'Wistia', 'YlGn', 'YlGnBu', 'YlOrBr', 'YlOrRd', 'afmhot', 'autumn', 'binary', 'bone', 'brg', 'bwr', 'cool', 'coolwarm', 'copper', 'cubehelix', 'flag', 'gist_earth', 'gist_gray', 'gist_heat', 'gist_ncar', 'gist_rainbow', 'gist_stern', 'gist_yarg', 'gnuplot', 'gnuplot2', 'gray', 'hot', 'hsv', 'jet', 'nipy_spectral', 'ocean', 'pink', 'prism', 'rainbow', 'seismic', 'spectral', 'spring', 'summer', 'tab10', 'tab20', 'tab20b', 'tab20c', 'terrain', 'winter'), value='summer'), Output()), _dom_classes=('widget-interact',))" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Let's try a simple parcellation map from a standard atlas\n", "from niwidgets import NiftiWidget\n", "from niwidgets import examplet1\n", "\n", "test_widget = NiftiWidget(examplet1)\n", "test_widget.nifti_plotter()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Use plotting functions from `nilearn`\n", "\n", "`niwidgets` also lets you turn standard plots from the nilearn package into widgets. You can use any of them, and provide your own keyword arguments to set the slider options (if no key word argument is provided defaults are used).\n", "\n", "In particular, `niwidgets` should allow you to pick a colormap interactively for almost any plot type\n", "\n", "### `plot_epi`\n", "\n", "Plotting the same image but with the `nilearn` function `plot_epi`, we get this:\n" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "scrolled": false }, "outputs": [ { "data": { "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "064b056b04d8405cb66ea2d4d4ae7395", "version_major": 2, "version_minor": 0 }, "text/html": [ "

Failed to display Jupyter Widget of type interactive.

\n", "

\n", " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", " that the widgets JavaScript is still loading. If this message persists, it\n", " likely means that the widgets JavaScript library is either not installed or\n", " not enabled. See the Jupyter\n", " Widgets Documentation for setup instructions.\n", "

\n", "

\n", " If you're reading this message in another frontend (for example, a static\n", " rendering on GitHub or NBViewer),\n", " it may mean that your frontend doesn't currently support widgets.\n", "

\n" ], "text/plain": [ "interactive(children=(Dropdown(description='display_mode', options=('ortho', 'x', 'y', 'z', 'yx', 'xz', 'yz'), value='ortho'), Dropdown(description='Colormap:', index=73, options=('Accent', 'Blues', 'BrBG', 'BuGn', 'BuPu', 'CMRmap', 'Dark2', 'GnBu', 'Greens', 'Greys', 'OrRd', 'Oranges', 'PRGn', 'Paired', 'Pastel1', 'Pastel2', 'PiYG', 'PuBu', 'PuBuGn', 'PuOr', 'PuRd', 'Purples', 'RdBu', 'RdGy', 'RdPu', 'RdYlBu', 'RdYlGn', 'Reds', 'Set1', 'Set2', 'Set3', 'Spectral', 'Vega10', 'Vega20', 'Vega20b', 'Vega20c', 'Wistia', 'YlGn', 'YlGnBu', 'YlOrBr', 'YlOrRd', 'afmhot', 'autumn', 'binary', 'bone', 'brg', 'bwr', 'cool', 'coolwarm', 'copper', 'cubehelix', 'flag', 'gist_earth', 'gist_gray', 'gist_heat', 'gist_ncar', 'gist_rainbow', 'gist_stern', 'gist_yarg', 'gnuplot', 'gnuplot2', 'gray', 'hot', 'hsv', 'jet', 'nipy_spectral', 'ocean', 'pink', 'prism', 'rainbow', 'seismic', 'spectral', 'spring', 'summer', 'tab10', 'tab20', 'tab20b', 'tab20c', 'terrain', 'winter'), value='summer'), IntSlider(value=0, continuous_update=False, description='x', max=90, min=-90), IntSlider(value=0, continuous_update=False, description='y', max=90, min=-90), IntSlider(value=0, continuous_update=False, description='z', max=90, min=-90), Output()), _dom_classes=('widget-interact',))" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import nilearn.plotting as nip\n", "\n", "test_widget.nifti_plotter(plotting_func=nip.plot_epi, display_mode=['ortho', 'x', 'y', 'z', 'yx', 'xz', 'yz'])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### `plot_glass_brain`\n", "\n", "This is an example of a glass brain plot with a standard visual perception activation map from neurosynth (this also ships as an example with `niwidgets`:" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "8f5041a516c04abbb045303a0bcd48f5", "version_major": 2, "version_minor": 0 }, "text/html": [ "

Failed to display Jupyter Widget of type interactive.

\n", "

\n", " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", " that the widgets JavaScript is still loading. If this message persists, it\n", " likely means that the widgets JavaScript library is either not installed or\n", " not enabled. See the Jupyter\n", " Widgets Documentation for setup instructions.\n", "

\n", "

\n", " If you're reading this message in another frontend (for example, a static\n", " rendering on GitHub or NBViewer),\n", " it may mean that your frontend doesn't currently support widgets.\n", "

\n" ], "text/plain": [ "interactive(children=(FloatSlider(value=5.0, description='threshold', max=10.0, step=0.01), Dropdown(description='display_mode', options=('ortho', 'xz'), value='ortho'), Dropdown(description='Colormap:', index=73, options=('Accent', 'Blues', 'BrBG', 'BuGn', 'BuPu', 'CMRmap', 'Dark2', 'GnBu', 'Greens', 'Greys', 'OrRd', 'Oranges', 'PRGn', 'Paired', 'Pastel1', 'Pastel2', 'PiYG', 'PuBu', 'PuBuGn', 'PuOr', 'PuRd', 'Purples', 'RdBu', 'RdGy', 'RdPu', 'RdYlBu', 'RdYlGn', 'Reds', 'Set1', 'Set2', 'Set3', 'Spectral', 'Vega10', 'Vega20', 'Vega20b', 'Vega20c', 'Wistia', 'YlGn', 'YlGnBu', 'YlOrBr', 'YlOrRd', 'afmhot', 'autumn', 'binary', 'bone', 'brg', 'bwr', 'cool', 'coolwarm', 'copper', 'cubehelix', 'flag', 'gist_earth', 'gist_gray', 'gist_heat', 'gist_ncar', 'gist_rainbow', 'gist_stern', 'gist_yarg', 'gnuplot', 'gnuplot2', 'gray', 'hot', 'hsv', 'jet', 'nipy_spectral', 'ocean', 'pink', 'prism', 'rainbow', 'seismic', 'spectral', 'spring', 'summer', 'tab10', 'tab20', 'tab20b', 'tab20c', 'terrain', 'winter'), value='summer'), Output()), _dom_classes=('widget-interact',))" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from niwidgets import examplezmap\n", "import nilearn.plotting as nip\n", "test = NiftiWidget(examplezmap)\n", "test.nifti_plotter(plotting_func=nip.plot_glass_brain, threshold=(0.0, 10.0, 0.01),\n", " display_mode=['ortho','xz'])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### `plot_img`\n", "\n", "Another image slicer type plot from the nilearn package, this time with an example atlas (the CC400 atlas), and setting the colormap:" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "8b8c4fa8e6264dfb9d69b1d4c9a22f26", "version_major": 2, "version_minor": 0 }, "text/html": [ "

Failed to display Jupyter Widget of type interactive.

\n", "

\n", " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", " that the widgets JavaScript is still loading. If this message persists, it\n", " likely means that the widgets JavaScript library is either not installed or\n", " not enabled. See the Jupyter\n", " Widgets Documentation for setup instructions.\n", "

\n", "

\n", " If you're reading this message in another frontend (for example, a static\n", " rendering on GitHub or NBViewer),\n", " it may mean that your frontend doesn't currently support widgets.\n", "

\n" ], "text/plain": [ "interactive(children=(Dropdown(description='display_mode', options=('ortho', 'x', 'y', 'z'), value='ortho'), IntSlider(value=0, continuous_update=False, description='x', max=90, min=-90), IntSlider(value=0, continuous_update=False, description='y', max=90, min=-90), IntSlider(value=0, continuous_update=False, description='z', max=90, min=-90), Output()), _dom_classes=('widget-interact',))" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from niwidgets import NiftiWidget\n", "from niwidgets import exampleatlas\n", "atlas_widget = NiftiWidget(exampleatlas)\n", "atlas_widget.nifti_plotter(plotting_func=nip.plot_img, display_mode=['ortho', 'x', 'y', 'z'], colormap='hot')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Surface data\n", "\n", "If you have surface data, you can import the `SurfaceWidget` and use it in a similar fashion to the `NiftiWidget`. Import and define it in the same way:" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "51cfd92f17df4fc786205ee1beae45d3", "version_major": 2, "version_minor": 0 }, "text/html": [ "

Failed to display Jupyter Widget of type interactive.

\n", "

\n", " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", " that the widgets JavaScript is still loading. If this message persists, it\n", " likely means that the widgets JavaScript library is either not installed or\n", " not enabled. See the Jupyter\n", " Widgets Documentation for setup instructions.\n", "

\n", "

\n", " If you're reading this message in another frontend (for example, a static\n", " rendering on GitHub or NBViewer),\n", " it may mean that your frontend doesn't currently support widgets.\n", "

\n" ], "text/plain": [ "interactive(children=(Dropdown(description='Colormap:', index=73, options=('Accent', 'Blues', 'BrBG', 'BuGn', 'BuPu', 'CMRmap', 'Dark2', 'GnBu', 'Greens', 'Greys', 'OrRd', 'Oranges', 'PRGn', 'Paired', 'Pastel1', 'Pastel2', 'PiYG', 'PuBu', 'PuBuGn', 'PuOr', 'PuRd', 'Purples', 'RdBu', 'RdGy', 'RdPu', 'RdYlBu', 'RdYlGn', 'Reds', 'Set1', 'Set2', 'Set3', 'Spectral', 'Vega10', 'Vega20', 'Vega20b', 'Vega20c', 'Wistia', 'YlGn', 'YlGnBu', 'YlOrBr', 'YlOrRd', 'afmhot', 'autumn', 'binary', 'bone', 'brg', 'bwr', 'cool', 'coolwarm', 'copper', 'cubehelix', 'flag', 'gist_earth', 'gist_gray', 'gist_heat', 'gist_ncar', 'gist_rainbow', 'gist_stern', 'gist_yarg', 'gnuplot', 'gnuplot2', 'gray', 'hot', 'hsv', 'jet', 'nipy_spectral', 'ocean', 'pink', 'prism', 'rainbow', 'seismic', 'spectral', 'spring', 'summer', 'tab10', 'tab20', 'tab20b', 'tab20c', 'terrain', 'winter'), value='summer'), Output()), _dom_classes=('widget-interact',))" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "2624832a01314342a1366587a73d2508", "version_major": 2, "version_minor": 0 }, "text/html": [ "

Failed to display Jupyter Widget of type Figure.

\n", "

\n", " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", " that the widgets JavaScript is still loading. If this message persists, it\n", " likely means that the widgets JavaScript library is either not installed or\n", " not enabled. See the Jupyter\n", " Widgets Documentation for setup instructions.\n", "

\n", "

\n", " If you're reading this message in another frontend (for example, a static\n", " rendering on GitHub or NBViewer),\n", " it may mean that your frontend doesn't currently support widgets.\n", "

\n" ], "text/plain": [ "Figure(camera_center=[0.0, 0.0, 0.0], camera_fov=1.0, height=600, matrix_projection=[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], matrix_world=[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], meshes=[Mesh(color=array([[1., 1., 1.],\n", " [1., 1., 1.],\n", " [1., 1., 1.],\n", " ...,\n", " [1., 1., 1.],\n", " [1., 1., 1.],\n", " [1., 1., 1.]]), texture=None, triangles=array([[ 0, 1, 3],\n", " [ 4, 3, 1],\n", " [ 0, 91, 1],\n", " ...,\n", " [123307, 123906, 123895],\n", " [123906, 123907, 123895],\n", " [123885, 124986, 124987]], dtype=uint32), x=array([18.7413578 , 18.37849426, 19.00789833, ..., 17.78539658,\n", " 17.8218174 , 17.95105362]), y=array([-127.09669495, -127.08947754, -127.14855194, ..., 96.06409454,\n", " 96.46263123, 96.3392868 ]), z=array([-48.42454529, -48.42292786, -48.9959259 , ..., 44.24810028,\n", " 44.08300781, 44.18468475]))], style={'axes': {'color': 'black', 'label': {'color': 'black'}, 'ticklabel': {'color': 'black'}, 'visible': False}, 'background-color': 'white', 'box': {'visible': False}}, tf=None, width=600, xlim=[-100.0, 100.0], ylim=[-127.3917007446289, 127.3917007446289], zlim=[-100.0, 100.0])" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from niwidgets import SurfaceWidget\n", "from niwidgets.exampledata import examplesurface\n", "\n", "surface_widget = SurfaceWidget(examplesurface)\n", "surface_widget.surface_plotter()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If you want to plot additional data as overlays, you can pass those as either loaded `GiftiImages` (loaded using nibabel), or as file paths to a `.annot`, `.thickness`, `.curv`, `.sulc`, or `.gii` file.\n", "\n", "If you pass them in a dictionary (see e.g. `niwidgets.exampledata.exampleoverlays`), the keys of the dictionary are used for the Options in a dropdown menu:" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "scrolled": false }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "6b090722cb50426fbaaecce2a3da82f3", "version_major": 2, "version_minor": 0 }, "text/html": [ "

Failed to display Jupyter Widget of type interactive.

\n", "

\n", " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", " that the widgets JavaScript is still loading. If this message persists, it\n", " likely means that the widgets JavaScript library is either not installed or\n", " not enabled. See the Jupyter\n", " Widgets Documentation for setup instructions.\n", "

\n", "

\n", " If you're reading this message in another frontend (for example, a static\n", " rendering on GitHub or NBViewer),\n", " it may mean that your frontend doesn't currently support widgets.\n", "

\n" ], "text/plain": [ "interactive(children=(Dropdown(description='Overlay:', options=('Area', 'Curvature', 'Thickness', 'Annotation'), value='Area'), Dropdown(description='Colormap:', index=73, options=('Accent', 'Blues', 'BrBG', 'BuGn', 'BuPu', 'CMRmap', 'Dark2', 'GnBu', 'Greens', 'Greys', 'OrRd', 'Oranges', 'PRGn', 'Paired', 'Pastel1', 'Pastel2', 'PiYG', 'PuBu', 'PuBuGn', 'PuOr', 'PuRd', 'Purples', 'RdBu', 'RdGy', 'RdPu', 'RdYlBu', 'RdYlGn', 'Reds', 'Set1', 'Set2', 'Set3', 'Spectral', 'Vega10', 'Vega20', 'Vega20b', 'Vega20c', 'Wistia', 'YlGn', 'YlGnBu', 'YlOrBr', 'YlOrRd', 'afmhot', 'autumn', 'binary', 'bone', 'brg', 'bwr', 'cool', 'coolwarm', 'copper', 'cubehelix', 'flag', 'gist_earth', 'gist_gray', 'gist_heat', 'gist_ncar', 'gist_rainbow', 'gist_stern', 'gist_yarg', 'gnuplot', 'gnuplot2', 'gray', 'hot', 'hsv', 'jet', 'nipy_spectral', 'ocean', 'pink', 'prism', 'rainbow', 'seismic', 'spectral', 'spring', 'summer', 'tab10', 'tab20', 'tab20b', 'tab20c', 'terrain', 'winter'), value='summer'), Output()), _dom_classes=('widget-interact',))" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "3a05401222af4d7cbd4c2a98d4c1caf3", "version_major": 2, "version_minor": 0 }, "text/html": [ "

Failed to display Jupyter Widget of type Figure.

\n", "

\n", " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", " that the widgets JavaScript is still loading. If this message persists, it\n", " likely means that the widgets JavaScript library is either not installed or\n", " not enabled. See the Jupyter\n", " Widgets Documentation for setup instructions.\n", "

\n", "

\n", " If you're reading this message in another frontend (for example, a static\n", " rendering on GitHub or NBViewer),\n", " it may mean that your frontend doesn't currently support widgets.\n", "

\n" ], "text/plain": [ "Figure(camera_center=[0.0, 0.0, 0.0], camera_fov=1.0, height=600, matrix_projection=[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], matrix_world=[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], meshes=[Mesh(color=array([[1., 1., 1.],\n", " [1., 1., 1.],\n", " [1., 1., 1.],\n", " ...,\n", " [1., 1., 1.],\n", " [1., 1., 1.],\n", " [1., 1., 1.]]), texture=None, triangles=array([[ 0, 1, 3],\n", " [ 4, 3, 1],\n", " [ 0, 91, 1],\n", " ...,\n", " [123307, 123906, 123895],\n", " [123906, 123907, 123895],\n", " [123885, 124986, 124987]], dtype=uint32), x=array([18.7413578 , 18.37849426, 19.00789833, ..., 17.78539658,\n", " 17.8218174 , 17.95105362]), y=array([-127.09669495, -127.08947754, -127.14855194, ..., 96.06409454,\n", " 96.46263123, 96.3392868 ]), z=array([-48.42454529, -48.42292786, -48.9959259 , ..., 44.24810028,\n", " 44.08300781, 44.18468475]))], style={'axes': {'color': 'black', 'label': {'color': 'black'}, 'ticklabel': {'color': 'black'}, 'visible': False}, 'background-color': 'white', 'box': {'visible': False}}, tf=None, width=600, xlim=[-100.0, 100.0], ylim=[-127.3917007446289, 127.3917007446289], zlim=[-100.0, 100.0])" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from niwidgets import SurfaceWidget\n", "from niwidgets.exampledata import examplesurface\n", "from niwidgets.exampledata import exampleoverlays\n", "\n", "surface_widget = SurfaceWidget(examplesurface, overlayfiles=exampleoverlays)\n", "\n", "surface_widget.surface_plotter()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Streamlines\n", "\n", "If you have mrtrix or trackvis streamlines, you can display them using the `StreamlineWidget`. Instead of passing a streamlines file, one can also pass a nibabel streamline sequence to the widget." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "de66333d4cce48418133e6ef22f90f5a", "version_major": 2, "version_minor": 0 }, "text/html": [ "

Failed to display Jupyter Widget of type VBox.

\n", "

\n", " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", " that the widgets JavaScript is still loading. If this message persists, it\n", " likely means that the widgets JavaScript library is either not installed or\n", " not enabled. See the Jupyter\n", " Widgets Documentation for setup instructions.\n", "

\n", "

\n", " If you're reading this message in another frontend (for example, a static\n", " rendering on GitHub or NBViewer),\n", " it may mean that your frontend doesn't currently support widgets.\n", "

\n" ], "text/plain": [ "VBox(children=(Figure(camera_center=[0.0, 0.0, 0.0], camera_fov=1.0, height=500, matrix_projection=[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], matrix_world=[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], meshes=[Mesh(color=array([[ 0.5103893 , 0.7629744 , -0.3967025 ],\n", " [ 0.5103893 , 0.7629744 , -0.3967025 ],\n", " [ 0.5103893 , 0.7629744 , -0.3967025 ],\n", " ...,\n", " [-0.06500284, -0.4601881 , 0.8854386 ],\n", " [-0.06500284, -0.4601881 , 0.8854386 ],\n", " [-0.06500284, -0.4601881 , 0.8854386 ]], dtype=float32), lines=array([ 0, 1, 1, ..., 161141, 161141, 161142], dtype=uint32), texture=None, x=array([76.33768 , 76.1091 , 75.86626 , ..., 49.14276 , 49.224125,\n", " 49.276688], dtype=float32), y=array([49.301598, 48.87002 , 48.451088, ..., 45.552483, 45.69906 ,\n", " 45.840733], dtype=float32), z=array([28.900988 , 29.0082 , 29.132801 , ..., 0.87795854,\n", " 0.40690082, -0.0697186 ], dtype=float32))], style={'axes': {'color': 'red', 'label': {'color': 'white'}, 'ticklabel': {'color': 'white'}, 'visible': False}, 'background-color': 'white', 'box': {'visible': False}}, tf=None, xlim=[-0.497088223695755, 94.8163833618164], ylim=[-0.497088223695755, 94.8163833618164], zlim=[-0.497088223695755, 94.8163833618164]),))" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "ccdeeb65175d403491649ee1a498a14e", "version_major": 2, "version_minor": 0 }, "text/html": [ "

Failed to display Jupyter Widget of type interactive.

\n", "

\n", " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", " that the widgets JavaScript is still loading. If this message persists, it\n", " likely means that the widgets JavaScript library is either not installed or\n", " not enabled. See the Jupyter\n", " Widgets Documentation for setup instructions.\n", "

\n", "

\n", " If you're reading this message in another frontend (for example, a static\n", " rendering on GitHub or NBViewer),\n", " it may mean that your frontend doesn't currently support widgets.\n", "

\n" ], "text/plain": [ "interactive(children=(FloatSlider(value=43.99999313354492, continuous_update=False, description='threshold', max=97.0, min=13.999998092651367), Output()), _dom_classes=('widget-interact',))" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from niwidgets import StreamlineWidget\n", "from niwidgets.exampledata import streamlines\n", "\n", "sw = StreamlineWidget(filename=streamlines)\n", "style = {'axes': {'color': 'red',\n", " 'label': {'color': 'white'},\n", " 'ticklabel': {'color': 'white'},\n", " 'visible': False},\n", " 'background-color': 'white',\n", " 'box': {'visible': False}}\n", "sw.plot(display_fraction=0.5, width=500, height=500, style=style, percentile=80)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python [default]", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.4" } }, "nbformat": 4, "nbformat_minor": 2 }