-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
In all the given examples, the volume and the slicer are global variables. It would be useful to be able to declare these variables in a callback. It would allow the user to select the file to vizualize during the session. The code below doesn't work: the slicer are well designed but the images remain completely blank.
def layout(slicer0, slicer1, slicer2):
layout = html.Div([
html.Div(
[
html.Center(html.H3("Axial")),
slicer0.graph,
html.Br(),
slicer0.slider,
*slicer0.stores,
]
),
html.Div(
[
html.Center(html.H3("Coronal")),
slicer1.graph,
html.Br(),
slicer1.slider,
*slicer1.stores,
]
),
html.Div(
[
html.Center(html.H3("Sagittal")),
slicer2.graph,
html.Br(),
slicer2.slider,
*slicer2.stores,
]
),
], style={
"display": "grid",
"gridTemplateColumns": "50% 50%",
},
)
return layout
app = dash.Dash(
__name__,
meta_tags=[{
"name": "viewport",
"content": "width=device-width, initial-scale=1"
}]
)
app.layout = html.Div([
dbc.Button("Apply", id="display_ct"),
html.Div(id="frame_ct_display"),
])
@app.callback(
[Output("frame_ct_display", "children")],
[Input("display_ct","n_clicks"),]
)
def display_ct(n_clicks):
if n_clicks is None:
raise PreventUpdate
vol = imageio.volread("imageio:stent.npz")
slicer0 = VolumeSlicer(app, vol, axis=0)
slicer1 = VolumeSlicer(app, vol, axis=1)
slicer2 = VolumeSlicer(app, vol, axis=2)
return [layout(slicer0, slicer1, slicer2)]
if __name__ == '__main__':
app.run_server(debug=True, dev_tools_props_check=False)
Metadata
Metadata
Assignees
Labels
No labels