Skip to content

Add 3 new demos using dicom #24

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

Merged
merged 13 commits into from
Feb 14, 2021
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
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
command: |
. venv/bin/activate
pip install --upgrade pip
pip install black==20.8b1
pip install -r requirements.txt --quiet
pip install -r tests/requirements.txt --quiet

Expand Down
10 changes: 10 additions & 0 deletions demos/data/citations.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Pancreas MRI:
Citation: Tatum, J., Kalen, J., Ileva, lilia, L, R., S, K., N, P., Jacobs, P., Sanders, C., A, J., Difilippantonio, S., L, T., hollingshead, melinda, J, P., Y, E., Clunie, D., Y, L., Suloway, C., Smith, K., U, W., … Doroshow, J. (n.d.). Imaging characterization of a metastatic patient derived model of adenocarcinoma pancreas: PDMR-292921-168-R. The Cancer Imaging Archive. https://doi.org/10.7937/TCIA.2020.PCAK-8Z10

Brain MRI:
URL: https://wiki.cancerimagingarchive.net/display/Public/Brain-Tumor-Progression
Citation: Schmainda KM, Prah M (2018). Data from Brain-Tumor-Progression. The Cancer Imaging Archive. http://doi.org/10.7937/K9/TCIA.2018.15quzvnb

Lung CT:
URL: https://wiki.cancerimagingarchive.net/pages/viewpage.action?pageId=70224216#70224216bcab02c187174a288dbcbf95d26179e8
Citation: Li, P., Wang, S., Li, T., Lu, J., HuangFu, Y., & Wang, D. (2020). A Large-Scale CT and PET/CT Dataset for Lung Cancer Diagnosis [Data set]. The Cancer Imaging Archive. https://doi.org/10.7937/TCIA.2020.NNC2-0461
Binary file added demos/data/ct_lung/1-01.dcm
Binary file not shown.
Binary file added demos/data/ct_lung/1-02.dcm
Binary file not shown.
Binary file added demos/data/ct_lung/1-03.dcm
Binary file not shown.
Binary file added demos/data/ct_lung/1-04.dcm
Binary file not shown.
Binary file added demos/data/ct_lung/1-05.dcm
Binary file not shown.
Binary file added demos/data/ct_lung/1-06.dcm
Binary file not shown.
Binary file added demos/data/ct_lung/1-07.dcm
Binary file not shown.
Binary file added demos/data/ct_lung/1-08.dcm
Binary file not shown.
Binary file added demos/data/ct_lung/1-09.dcm
Binary file not shown.
Binary file added demos/data/ct_lung/1-10.dcm
Binary file not shown.
Binary file added demos/data/ct_lung/1-11.dcm
Binary file not shown.
Binary file added demos/data/ct_lung/1-12.dcm
Binary file not shown.
Binary file added demos/data/ct_lung/1-13.dcm
Binary file not shown.
Binary file added demos/data/ct_lung/1-14.dcm
Binary file not shown.
Binary file added demos/data/ct_lung/1-15.dcm
Binary file not shown.
Binary file added demos/data/ct_lung/1-16.dcm
Binary file not shown.
Binary file added demos/data/ct_lung/1-17.dcm
Binary file not shown.
Binary file added demos/data/ct_lung/1-18.dcm
Binary file not shown.
Binary file added demos/data/ct_lung/1-19.dcm
Binary file not shown.
Binary file added demos/data/ct_lung/1-20.dcm
Binary file not shown.
Binary file added demos/data/ct_lung/1-21.dcm
Binary file not shown.
Binary file added demos/data/ct_lung/1-22.dcm
Binary file not shown.
Binary file added demos/data/ct_lung/1-23.dcm
Binary file not shown.
Binary file added demos/data/ct_lung/1-24.dcm
Binary file not shown.
Binary file added demos/data/ct_lung/1-25.dcm
Binary file not shown.
Binary file added demos/data/ct_lung/1-26.dcm
Binary file not shown.
Binary file added demos/data/ct_lung/1-27.dcm
Binary file not shown.
Binary file added demos/data/ct_lung/1-28.dcm
Binary file not shown.
Binary file added demos/data/ct_lung/1-29.dcm
Binary file not shown.
Binary file added demos/data/ct_lung/1-30.dcm
Binary file not shown.
Binary file added demos/data/mri_brain/1-01.dcm
Binary file not shown.
Binary file added demos/data/mri_brain/1-02.dcm
Binary file not shown.
Binary file added demos/data/mri_brain/1-03.dcm
Binary file not shown.
Binary file added demos/data/mri_brain/1-04.dcm
Binary file not shown.
Binary file added demos/data/mri_brain/1-05.dcm
Binary file not shown.
Binary file added demos/data/mri_brain/1-06.dcm
Binary file not shown.
Binary file added demos/data/mri_brain/1-07.dcm
Binary file not shown.
Binary file added demos/data/mri_brain/1-08.dcm
Binary file not shown.
Binary file added demos/data/mri_brain/1-09.dcm
Binary file not shown.
Binary file added demos/data/mri_brain/1-10.dcm
Binary file not shown.
Binary file added demos/data/mri_brain/1-11.dcm
Binary file not shown.
Binary file added demos/data/mri_brain/1-12.dcm
Binary file not shown.
Binary file added demos/data/mri_brain/1-13.dcm
Binary file not shown.
Binary file added demos/data/mri_brain/1-14.dcm
Binary file not shown.
Binary file added demos/data/mri_brain/1-15.dcm
Binary file not shown.
Binary file added demos/data/mri_brain/1-16.dcm
Binary file not shown.
Binary file added demos/data/mri_brain/1-17.dcm
Binary file not shown.
Binary file added demos/data/mri_brain/1-18.dcm
Binary file not shown.
Binary file added demos/data/mri_brain/1-19.dcm
Binary file not shown.
Binary file added demos/data/mri_brain/1-20.dcm
Binary file not shown.
Binary file added demos/data/mri_brain/1-21.dcm
Binary file not shown.
Binary file added demos/data/mri_brain/1-22.dcm
Binary file not shown.
Binary file added demos/data/mri_brain/1-23.dcm
Binary file not shown.
Binary file added demos/data/mri_brain/1-24.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-01.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-02.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-03.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-04.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-05.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-06.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-07.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-08.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-09.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-10.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-11.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-12.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-13.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-14.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-15.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-16.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-17.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-18.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-19.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-20.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-21.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-22.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-23.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-24.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-25.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-26.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-27.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-28.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-29.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-30.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-31.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-32.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-33.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-34.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-35.dcm
Binary file not shown.
Binary file added demos/data/mri_pancreas/1-36.dcm
Binary file not shown.
16 changes: 16 additions & 0 deletions demos/dicom-ct-lung/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Visualizing MRi volumes from dicom files

![Image demo](./demo.jpg)

## Instructions

See instructions from [README.md](../../README.md) to create a virtual environment and install the dependencies.


## Acknowledgements

Dataset: [Lung CT](https://wiki.cancerimagingarchive.net/pages/viewpage.action?pageId=70224216#70224216bcab02c187174a288dbcbf95d26179e8)

```
Citation: Li, P., Wang, S., Li, T., Lu, J., HuangFu, Y., & Wang, D. (2020). A Large-Scale CT and PET/CT Dataset for Lung Cancer Diagnosis [Data set]. The Cancer Imaging Archive. https://doi.org/10.7937/TCIA.2020.NNC2-0461
```
38 changes: 38 additions & 0 deletions demos/dicom-ct-lung/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import os

import dash
import dash_html_components as html
import itk

import dash_vtk
from dash_vtk.utils import to_volume_state

# Place a DICOM series (a set of per-file slices) in a directory. ITK sorts, sets spatial metadata, etc.
demo_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
itk_image = itk.imread(os.path.join(demo_dir, "data", "ct_lung"))

# Convert itk.Image to vtkImageData
vtk_image = itk.vtk_image_from_image(itk_image)
volume_state = to_volume_state(vtk_image)


vtk_view = dash_vtk.View(
dash_vtk.VolumeRepresentation(
children=[
dash_vtk.VolumeController(),
dash_vtk.Volume(state=volume_state),
]
)
)

app = dash.Dash(__name__)
server = app.server

app.layout = html.Div(
style={"height": "calc(100vh - 50px)", "width": "100%"},
children=[html.Div(vtk_view, style={"height": "100%", "width": "100%"})],
)


if __name__ == "__main__":
app.run_server(debug=True)
Binary file added demos/dicom-ct-lung/demo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions demos/dicom-ct-lung/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# If you skipped `pip install -e ../../`, the package below will be retrieved from pypi:
dash-vtk
dash-bootstrap-components
vtk
numpy
itk==5.2rc1
18 changes: 18 additions & 0 deletions demos/dicom-mri-brain/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Visualizing CT Scans as volume from dicom files

![Image demo](./demo.jpg)

## Instructions

See instructions from [README.md](../../README.md) to create a virtual environment and install the dependencies.


## Acknowledgements

The datasets used here include:

[Brain MRI](https://wiki.cancerimagingarchive.net/display/Public/Brain-Tumor-Progression)

```
Citation: Schmainda KM, Prah M (2018). Data from Brain-Tumor-Progression. The Cancer Imaging Archive. http://doi.org/10.7937/K9/TCIA.2018.15quzvnb
```
40 changes: 40 additions & 0 deletions demos/dicom-mri-brain/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import os

import dash
import dash_html_components as html
import dash_bootstrap_components as dbc
import itk

import dash_vtk
from dash_vtk.utils import to_volume_state


def dcm_to_volume(dir_path):
itk_image = itk.imread(dir_path)
vtk_image = itk.vtk_image_from_image(itk_image)
volume_state = to_volume_state(vtk_image)

return volume_state


# Place a DICOM series (a set of per-file slices) in a directory. ITK sorts, sets spatial metadata, etc.
demo_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
volume_state = dcm_to_volume(os.path.join(demo_dir, "data", "mri_brain"))

app = dash.Dash(__name__)
server = app.server

vtk_view = dash_vtk.View(
dash_vtk.VolumeRepresentation(
[dash_vtk.VolumeController(), dash_vtk.Volume(state=volume_state)]
)
)

app.layout = html.Div(
style={"height": "calc(100vh - 50px)", "width": "100%"},
children=[html.Div(style={"height": "100%", "width": "100%"}, children=vtk_view)],
)


if __name__ == "__main__":
app.run_server(debug=True)
Binary file added demos/dicom-mri-brain/demo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions demos/dicom-mri-brain/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# If you skipped `pip install -e ../../`, the package below will be retrieved from pypi:
dash-vtk
dash-bootstrap-components
vtk
numpy
itk==5.2rc1
17 changes: 17 additions & 0 deletions demos/dicom-mri-pancreas/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Visualizing MRi volumes from dicom files

![Image demo](./demo.jpg)

## Instructions

See instructions from [README.md](../../README.md) to create a virtual environment and install the dependencies.


## Acknowledgements

The datasets used here include:

[Pancreas MRI](https://wiki.cancerimagingarchive.net/display/Public/Imaging+characterization+of+a+metastatic+patient+derived+model+of+adenocarcinoma+pancreas%3A+PDMR-292921-168-R)
```
Citation: Tatum, J., Kalen, J., Ileva, lilia, L, R., S, K., N, P., Jacobs, P., Sanders, C., A, J., Difilippantonio, S., L, T., hollingshead, melinda, J, P., Y, E., Clunie, D., Y, L., Suloway, C., Smith, K., U, W., … Doroshow, J. (n.d.). Imaging characterization of a metastatic patient derived model of adenocarcinoma pancreas: PDMR-292921-168-R. The Cancer Imaging Archive. https://doi.org/10.7937/TCIA.2020.PCAK-8Z10
```
40 changes: 40 additions & 0 deletions demos/dicom-mri-pancreas/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import os

import dash
import dash_html_components as html
import dash_bootstrap_components as dbc
import itk

import dash_vtk
from dash_vtk.utils import to_volume_state


def dcm_to_volume(dir_path):
itk_image = itk.imread(dir_path)
vtk_image = itk.vtk_image_from_image(itk_image)
volume_state = to_volume_state(vtk_image)

return volume_state


# Place a DICOM series (a set of per-file slices) in a directory. ITK sorts, sets spatial metadata, etc.
demo_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
volume_state = dcm_to_volume(os.path.join(demo_dir, "data", "mri_pancreas"))

app = dash.Dash(__name__)
server = app.server

vtk_view = dash_vtk.View(
dash_vtk.VolumeRepresentation(
[dash_vtk.VolumeController(), dash_vtk.Volume(state=volume_state)]
)
)

app.layout = html.Div(
style={"height": "calc(100vh - 50px)", "width": "100%"},
children=[html.Div(style={"height": "100%", "width": "100%"}, children=vtk_view)],
)


if __name__ == "__main__":
app.run_server(debug=True)
Binary file added demos/dicom-mri-pancreas/demo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions demos/dicom-mri-pancreas/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# If you skipped `pip install -e ../../`, the package below will be retrieved from pypi:
dash-vtk
dash-bootstrap-components
vtk
numpy
itk==5.2rc1
4 changes: 3 additions & 1 deletion demos/pyvista-terrain-following-mesh/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ def updateWarp(factor=1):
],
colorMapPreset="erdc_blue2green_muted",
colorDataRange=color_range,
property={"edgeVisibility": True,},
property={
"edgeVisibility": True,
},
)
],
)
Expand Down
5 changes: 4 additions & 1 deletion demos/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
-r ./volume-rendering/requirements.txt
-r ./usage-vtk-cfd/requirements.txt
-r ./usage-algorithm/requirements.txt
-r ./synthetic-volume-rendering/requirements.txt
-r ./synthetic-volume-rendering/requirements.txt
-r ./dicom-ct-lung/requirements.txt
-r ./dicom-mri-brain/requirements.txt
-r ./dicom-mri-pancreas/requirements.txt
6 changes: 5 additions & 1 deletion demos/slice-rendering/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@
children=[
html.Div(
style={"height": "20%", "display": "flex", "align-items": "center"},
children=[html.Br(), controls, html.Br(),],
children=[
html.Br(),
controls,
html.Br(),
],
),
html.Div(slice_view, style={"height": "80%"}),
],
Expand Down
5 changes: 4 additions & 1 deletion demos/usage-algorithm/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@
dbc.Col(
width=8,
children=[
html.Div(vtk_view, style={"height": "100%", "width": "100%"},)
html.Div(
vtk_view,
style={"height": "100%", "width": "100%"},
)
],
),
],
Expand Down
24 changes: 20 additions & 4 deletions demos/usage-vtk-cfd/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,20 +115,36 @@ def getSeedState(self):
children=[
dash_vtk.GeometryRepresentation(
id="bike-rep",
children=[dash_vtk.Mesh(id="bike", state=viz.getBikeMesh(),)],
children=[
dash_vtk.Mesh(
id="bike",
state=viz.getBikeMesh(),
)
],
),
dash_vtk.GeometryRepresentation(
id="tubes-rep",
colorMapPreset="erdc_rainbow_bright",
colorDataRange=viz.getColorRange(),
children=[dash_vtk.Mesh(id="tubes-mesh", state=viz.getTubesMesh("p"),)],
children=[
dash_vtk.Mesh(
id="tubes-mesh",
state=viz.getTubesMesh("p"),
)
],
),
dash_vtk.GeometryRepresentation(
id="seed-rep",
property={"color": [0.8, 0, 0], "representation": 0, "pointSize": 8,},
property={
"color": [0.8, 0, 0],
"representation": 0,
"pointSize": 8,
},
children=[
dash_vtk.Algorithm(
id="seed-line", vtkClass="vtkLineSource", state=viz.getSeedState(),
id="seed-line",
vtkClass="vtkLineSource",
state=viz.getSeedState(),
)
],
),
Expand Down
5 changes: 4 additions & 1 deletion demos/volume-rendering/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@

vtk_view = dash_vtk.View(
dash_vtk.VolumeRepresentation(
children=[dash_vtk.VolumeController(), dash_vtk.Volume(state=volume_state),]
children=[
dash_vtk.VolumeController(),
dash_vtk.Volume(state=volume_state),
]
)
)

Expand Down
5 changes: 4 additions & 1 deletion tests/test_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ def take_snapshot(dash_duo, name):
names = [
"usage",
"demos.pyvista-terrain-following-mesh.app",
"demos.slice-rendering.app",
"demos.pyvista-point-cloud.app",
"demos.dicom-ct-lung.app",
"demos.dicom-mri-brain.app",
"demos.dicom-mri-pancreas.app",
"demos.slice-rendering.app",
"demos.volume-rendering.app",
"demos.usage-vtk-cfd.app",
"demos.usage-algorithm.app",
Expand Down