Hi all,
I have mat files containing data of the PET/CT scans. I use an upload function to load mat files. Then based on the user inputted threshold values function suppose to create a figure and should display the figure using graph. Please note that all the images are as nd array. I tried almost all the methods and I am kind of new to dash.
My original layout worked like this:
html.Div(
[
dcc.Graph(
id="image-display-graph",
figure=fig
)
],
style={
"grid-column": "1",
"grid-row": "2",
"background-color": DISPLAY_BG_COLOR,
},
),
And the callback I was doing:
@app.callback(
Output('image-display-graph', 'figure'),
Input('btn_clicks', 'n_clicks'),
State('hut', 'value'),
State('suvt', 'value'),
State('upload_file', 'filename')
)
And the function to get the segmented figure I was doing:
def make_seg_image(filename, hu, suvt, btn_clicks):
data = read_mat(os.path.join('D:\data', filename))
if 'pt_image' in data:
ct_image = data['ct_image']
pt_image = data['pt_image']
mid_slice_pt = np.round(np.array(pt_image.shape) / 2).astype(int)
pt_slice = pt_image[:, :, mid_slice_pt[2]]
mid_slice_ct = np.round(np.array(ct_image.shape) / 2).astype(int)
ct_slice = ct_image[:, :, mid_slice_ct[2]]
# ct_segmentation
threshold_ct_img = ct_slice > hu
# Apply PET image to CT bone mask
pet_mask = np.multiply(pt_slice, threshold_ct_img)
pt_image_suvt = pet_mask > suvt
fig = px.imshow(pt_image_suvt, animation_frame=0, facet_col=1, binary_string=True)
return fig
But I am continuously getting callback errors