Skip to content

Commit

Permalink
Update example notebook (#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamltyson authored Jan 3, 2024
1 parent 3003fda commit 77ba2f8
Showing 1 changed file with 25 additions and 30 deletions.
55 changes: 25 additions & 30 deletions examples/notebook_workflow.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,56 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Using `brainrender` in jupyter notebooks\n",
"# Using Notebooks\n",
"\n",
"There's three ways that you can render a `brainrender` scene in Jupyter:\n",
"`brainrender` can be used with Jupyter notebooks in two ways:\n",
"\n",
"1. You can have it pop up in a new window (recommended)\n",
"2. You can have embedded in the notebook\n",
"3. You can have it embedded a a ipywidget\n",
"1. you can **embed** a window with your rendered scene\n",
"2. you can have your scene be rendered in a **pop-up** window.\n",
"\n",
"Note that option 2 and 3 don't support all of `brainrender`'s functionality.\n",
"As such option 1 is recommended.\n",
"\n",
"If you get an error while running this notebook, restart the kernel and run only one\n",
"of the three rendering options. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from brainrender import Scene\n",
"from vedo import embedWindow, Plotter, show # <- this will be used to render an embedded scene \n",
"from itkwidgets import view"
"## Rendering your scene in a separate window\n",
"\n",
"If you want your scene to be rendered in a new window, then set this option before you create \n",
"your `Scene`.\n",
"\n",
"```python\n",
"import vedo\n",
"vedo.settings.default_backend= 'vtk'\n",
"```\n",
"After this everything will work exactly the same as usual, and you will have access to all of brainrender's features. \n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Render as popup"
"### To visualise primary visual cortex in the Allen Adult Mouse Brain Atlas:"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"embedWindow(None) # <- this will make your scene popup\n",
"import vedo\n",
"vedo.settings.default_backend= 'vtk'\n",
"\n",
"from brainrender import Scene\n",
"popup_scene = Scene(atlas_name='allen_mouse_50um', title='popup')\n",
"\n",
"popup_scene = Scene(title='popup')\n",
"\n",
"popup_scene.add_brain_region('MOs')\n",
"popup_scene.add_brain_region('VISp')\n",
"\n",
"popup_scene.render() # press 'Esc' to close!!"
"popup_scene.render() # press 'Esc' to close"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Embedded scene"
"## Embedding the scene\n",
"\n"
]
},
{
Expand Down Expand Up @@ -119,7 +114,7 @@
"metadata": {
"file_extension": ".py",
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -133,7 +128,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
"version": "3.10.13"
},
"mimetype": "text/x-python",
"name": "python",
Expand Down

0 comments on commit 77ba2f8

Please sign in to comment.