-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EBR-23. Create Dicom Widget and add demo notebook
- Loading branch information
1 parent
9f917bc
commit 0c0e59d
Showing
3 changed files
with
396 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "ce105187-a7e9-4689-ae91-f6bda224845d", | ||
"metadata": {}, | ||
"source": [ | ||
"## TVB Dicom Widget" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "b36747f3-dc0a-43b2-8dc0-c38dba5f2f8d", | ||
"metadata": {}, | ||
"source": [ | ||
"---" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "b77e1d2e-1229-4c14-8ffa-8b26bb0aaacf", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"source": [ | ||
"### This notebook is dedicated to showcasing the Dicom widget using the NIFTI Parser from TVB\n", | ||
"#### *Note: This widget accepts 2 types of data: `numpy.ndarray` and `tvb.datatypes.structural.StructuralMRI`.*" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "bee554c9-bf38-4ad4-8d7a-f8b8e109cb45", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from tvbwidgets.api import DicomWidget\n", | ||
"from tvb.adapters.uploaders.nifti.parser import NIFTIParser\n", | ||
"\n", | ||
"from bokeh.io import output_notebook\n", | ||
"output_notebook() # tell Bokeh to display the widget inside the notebook" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "cb911cd0-e624-473c-97c1-24bef090ece4", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"source": [ | ||
"#### Read and parse NIFTI data" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "21d549a1-aa69-4964-9d6a-074a1ebf12fe", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"parser = NIFTIParser(data_file='path_to_nii_file')\n", | ||
"data = parser.parse()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "e1a32181-61b4-4178-b315-9ab5dd10e99a", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"source": [ | ||
"#### Display the widget" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "2bd3dce7-657b-440d-9dcc-f8f494dbd92e", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"widget = DicomWidget(data)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"id": "e97e9bbb-9d8f-4f74-8fa4-766c5a491939", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"application/vnd.bokehjs_exec.v0+json": "", | ||
"text/html": [ | ||
"<script id=\"adee33fa-41aa-4009-80e6-9f6dff04c1f7\">\n", | ||
" (function() {\n", | ||
" const xhr = new XMLHttpRequest()\n", | ||
" xhr.responseType = 'blob';\n", | ||
" xhr.open('GET', \"http://localhost:53131/autoload.js?bokeh-autoload-element=adee33fa-41aa-4009-80e6-9f6dff04c1f7&bokeh-absolute-url=http://localhost:53131&resources=none\", true);\n", | ||
" xhr.onload = function (event) {\n", | ||
" const script = document.createElement('script');\n", | ||
" const src = URL.createObjectURL(event.target.response);\n", | ||
" script.src = src;\n", | ||
" document.body.appendChild(script);\n", | ||
" };\n", | ||
" xhr.send();\n", | ||
" })();\n", | ||
"</script>" | ||
] | ||
}, | ||
"metadata": { | ||
"application/vnd.bokehjs_exec.v0+json": { | ||
"server_id": "22277419a6d447b993dc7b83cc4c3b30" | ||
} | ||
}, | ||
"output_type": "display_data" | ||
} | ||
], | ||
"source": [ | ||
"widget.show_widget()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "52b6f692-753f-4d95-91df-9a4e33ad391c", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"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.9.18" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.