Skip to content

Commit

Permalink
EBR-23. Create Dicom Widget and add demo notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
romina1601 committed Apr 3, 2024
1 parent 9f917bc commit 0c0e59d
Show file tree
Hide file tree
Showing 3 changed files with 396 additions and 0 deletions.
159 changes: 159 additions & 0 deletions notebooks/DicomWidget.ipynb
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
}
1 change: 1 addition & 0 deletions tvbwidgets/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from .ui.connectivity_ipy.connectivity_widget import ConnectivityWidget
from .ui.connectivity_react.connectivity_widget import ConnectivityWidgetReact
from .ui.dicom_widget import DicomWidget
from .ui.phase_plane_widget import PhasePlaneWidget
from .ui.storage_widget import StorageWidget
from .ui.head_widget import HeadBrowser, HeadWidget, HeadWidgetConfig
Expand Down
Loading

0 comments on commit 0c0e59d

Please sign in to comment.