Skip to content

Commit 77961e0

Browse files
authored
rename to dash_slicer and VolumeSlicer (#10)
1 parent 88e2e7b commit 77961e0

File tree

12 files changed

+53
-39
lines changed

12 files changed

+53
-39
lines changed

README.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
# dash-3d-viewer
1+
# dash_slicer
2+
3+
A volume slicer for Dash
24

3-
A tool to make it easy to build slice-views on 3D image data, in Dash apps.
45

56
The API is currently a WIP.
67

@@ -10,9 +11,23 @@ The API is currently a WIP.
1011
Eventually, this would be pip-installable. For now, use the developer workflow.
1112

1213

13-
## Usage
14+
## Usage example
15+
16+
```py
17+
import dash
18+
import dash_html_components as html
19+
from dash_slicer import VolumeSlicer
20+
import imageio
21+
22+
app = dash.Dash(__name__)
23+
24+
vol = imageio.volread("imageio:stent.npz")
25+
slicer = VolumeSlicer(app, vol)
26+
app.layout = html.Div([slicer.graph, slicer.slider, *slicer.stores])
1427

15-
TODO, see the examples.
28+
if __name__ == "__main__":
29+
app.run_server()
30+
```
1631

1732

1833
## License

dash_3d_viewer/__init__.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

dash_slicer/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""
2+
dash_slicer - a volume slicer for Dash
3+
"""
4+
5+
6+
from .slicer import VolumeSlicer # noqa: F401
7+
8+
9+
__version__ = "0.0.1"
10+
version_info = tuple(map(int, __version__.split(".")))

dash_3d_viewer/slicer.py renamed to dash_slicer/slicer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from .utils import img_array_to_uri, get_thumbnail_size_from_shape, shape3d_to_size2d
88

99

10-
class DashVolumeSlicer:
10+
class VolumeSlicer:
1111
"""A slicer to show 3D image data in Dash.
1212
1313
Parameters:
@@ -81,8 +81,8 @@ def __init__(
8181
raise TypeError("scene_id must be a string")
8282
self.scene_id = scene_id
8383
# Get unique id scoped to this slicer object
84-
DashVolumeSlicer._global_slicer_counter += 1
85-
self.context_id = "slicer_" + str(DashVolumeSlicer._global_slicer_counter)
84+
VolumeSlicer._global_slicer_counter += 1
85+
self.context_id = "slicer_" + str(VolumeSlicer._global_slicer_counter)
8686

8787
# Prepare slice info
8888
info = {
File renamed without changes.

examples/slicer_with_1_plus_2_views.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
import dash
1717
import dash_html_components as html
18-
from dash_3d_viewer import DashVolumeSlicer
18+
from dash_slicer import VolumeSlicer
1919
import imageio
2020

2121

@@ -28,13 +28,13 @@
2828
ori = 110, 120, 140
2929

3030

31-
slicer1 = DashVolumeSlicer(
31+
slicer1 = VolumeSlicer(
3232
app, vol1, axis=1, origin=ori, reverse_y=False, scene_id="scene1"
3333
)
34-
slicer2 = DashVolumeSlicer(
34+
slicer2 = VolumeSlicer(
3535
app, vol1, axis=0, origin=ori, reverse_y=False, scene_id="scene1"
3636
)
37-
slicer3 = DashVolumeSlicer(
37+
slicer3 = VolumeSlicer(
3838
app, vol2, axis=0, origin=ori, spacing=spacing, reverse_y=False, scene_id="scene1"
3939
)
4040

examples/slicer_with_1_view.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44

55
import dash
66
import dash_html_components as html
7-
from dash_3d_viewer import DashVolumeSlicer
7+
from dash_slicer import VolumeSlicer
88
import imageio
99

1010

1111
app = dash.Dash(__name__)
1212

1313
vol = imageio.volread("imageio:stent.npz")
14-
slicer = DashVolumeSlicer(app, vol)
14+
slicer = VolumeSlicer(app, vol)
1515

1616
app.layout = html.Div([slicer.graph, slicer.slider, *slicer.stores])
1717

1818

1919
if __name__ == "__main__":
20-
app.run_server(debug=False)
20+
app.run_server(debug=True)

examples/slicer_with_2_views.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
import dash
66
import dash_html_components as html
7-
from dash_3d_viewer import DashVolumeSlicer
7+
from dash_slicer import VolumeSlicer
88
import imageio
99

1010

1111
app = dash.Dash(__name__)
1212

1313
vol = imageio.volread("imageio:stent.npz")
14-
slicer1 = DashVolumeSlicer(app, vol, axis=1)
15-
slicer2 = DashVolumeSlicer(app, vol, axis=2)
14+
slicer1 = VolumeSlicer(app, vol, axis=1)
15+
slicer2 = VolumeSlicer(app, vol, axis=2)
1616

1717
app.layout = html.Div(
1818
style={

examples/slicer_with_3_views.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77
import dash
88
import dash_html_components as html
99
import dash_core_components as dcc
10-
from dash_3d_viewer import DashVolumeSlicer
10+
from dash_slicer import VolumeSlicer
1111
from skimage.measure import marching_cubes
1212
import imageio
1313

1414
app = dash.Dash(__name__)
1515

1616
# Read volumes and create slicer objects
1717
vol = imageio.volread("imageio:stent.npz")
18-
slicer1 = DashVolumeSlicer(app, vol, reverse_y=False, axis=0)
19-
slicer2 = DashVolumeSlicer(app, vol, reverse_y=False, axis=1)
20-
slicer3 = DashVolumeSlicer(app, vol, reverse_y=False, axis=2)
18+
slicer1 = VolumeSlicer(app, vol, reverse_y=False, axis=0)
19+
slicer2 = VolumeSlicer(app, vol, reverse_y=False, axis=1)
20+
slicer3 = VolumeSlicer(app, vol, reverse_y=False, axis=2)
2121

2222
# Calculate isosurface and create a figure with a mesh object
2323
verts, faces, _, _ = marching_cubes(vol, 300, step_size=2)
@@ -68,4 +68,4 @@
6868

6969

7070
if __name__ == "__main__":
71-
app.run_server(debug=False)
71+
app.run_server(debug=True)

examples/use_components.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
import dash
77
import dash_html_components as html
88
from dash.dependencies import Input, Output, State
9-
from dash_3d_viewer import DashVolumeSlicer
9+
from dash_slicer import VolumeSlicer
1010
import imageio
1111

1212

1313
app = dash.Dash(__name__)
1414

1515
vol = imageio.volread("imageio:stent.npz")
16-
slicer = DashVolumeSlicer(app, vol)
16+
slicer = VolumeSlicer(app, vol)
1717

1818
# We can access the components, and modify them
1919
slicer.slider.value = 0

0 commit comments

Comments
 (0)