Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EBR-23. Create Dicom Widget #69

Merged
merged 3 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
162 changes: 162 additions & 0 deletions notebooks/DicomWidget.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
{
"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\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": [
"import numpy as np\n",
"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 input data"
]
},
{
"cell_type": "markdown",
"id": "5c445018-d57c-45e1-a8fc-8cce82c8ba70",
"metadata": {},
"source": [
"#### Either read and parse the data using the NIFTI Parser from TVB \n",
"(Uncomment the 2 lines and replace `path_to_nii_file` with the correct path to your file)"
]
},
{
"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": "07185a9d-f8a4-4ea9-97cc-54fcc523b765",
"metadata": {},
"source": [
"#### Or use an existent numpy.ndarray/ TVB StructuralMRI object"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c03cbb47-cbec-454c-8935-61cc00894a21",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# create demo array just to demonstrate the usage of the API\n",
"data = np.random.rand(255,255,255)"
]
},
{
"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": null,
"id": "e97e9bbb-9d8f-4f74-8fa4-766c5a491939",
"metadata": {},
"outputs": [],
"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 requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ plotly-resampler
pyunicore==0.15.2
traitlets>=5.7.1
toml
bokeh
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
Loading