Skip to content

Commit

Permalink
Fix event polling issues related to #38
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-oreilly committed Aug 23, 2023
1 parent a2f734b commit 9fbef54
Showing 1 changed file with 50 additions and 15 deletions.
65 changes: 50 additions & 15 deletions examples/tractography.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,19 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"id": "e8c48085-2e35-4d32-87dc-5d552482b994",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[33mDEPRECATION: pyodbc 4.0.0-unsupported has a non-standard version number. pip 23.3 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of pyodbc or contact the author to suggest that they release a version with a conforming version number. Discussion can be found at https://github.com/pypa/pip/issues/12063\u001b[0m\u001b[33m\n",
"\u001b[0mNote: you may need to restart the kernel to use updated packages.\n"
]
}
],
"source": [
"#run if using Google Colab or not building from source\n",
"try:\n",
Expand All @@ -45,13 +54,15 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"id": "14ca07b7-2838-45e8-a802-a0c96ac59ce9",
"metadata": {},
"outputs": [],
"source": [
"from ipyniivue import Niivue\n",
"import ipywidgets as widgets"
"import ipywidgets as widgets\n",
"from time import sleep, time\n",
"from jupyter_ui_poll import ui_events"
]
},
{
Expand All @@ -65,7 +76,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 11,
"id": "a2651106-3f99-4bb0-afd3-9e68a4be021d",
"metadata": {
"tags": []
Expand Down Expand Up @@ -135,10 +146,25 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 12,
"id": "bd63fe41-444b-4ce7-a652-8d098a15eeff",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "5538dd2a7f9a491b8fecc875dcb9b5ca",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(VBox(children=(IntSlider(value=3, description='Length', max=80, min=1), FloatSlider(value=1.0, …"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Creating a NiiVue object\n",
"nv = Niivue(back_color=[0.8, 0.8, 1, 1], show_3D_crosshair=True)\n",
Expand All @@ -157,7 +183,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 13,
"id": "ad7e5f38-9208-4845-b24a-84ffca1ff31c",
"metadata": {
"tags": []
Expand All @@ -178,7 +204,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 14,
"id": "34864ab3-a459-4e51-b27c-3c7df293aedf",
"metadata": {
"tags": []
Expand All @@ -198,13 +224,22 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "68574d16-54fc-4a81-9729-8df3f6045295",
"metadata": {
"tags": []
},
"execution_count": 15,
"id": "797e35b7",
"metadata": {},
"outputs": [],
"source": [
"timeout = 10\n",
"start = time()\n",
"i = 1\n",
"with ui_events() as poll:\n",
" while True:\n",
" poll(1)\n",
" if len(nv.meshes):\n",
" break\n",
" if time() > start + timeout:\n",
" raise TimeoutError\n",
"\n",
"nv.set_mesh_property(nv.meshes[0].id, \"colormap\", \"blue\")\n",
"nv.set_clip_plane([-0.1, 270, 0])"
]
Expand All @@ -226,7 +261,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.9.7"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
Expand Down

0 comments on commit 9fbef54

Please sign in to comment.