Add contours to a 3D Time-Series Image in Plotly

I have a requirement to add contours for each slice of a 3D Time-series image in Plotly. I tried something similar to below, which shows the image slices in a time series similar to this, however it doesn’t show any contours

study_uid = request.POST.get('study_uid')
img = get_image(study_uid, workspace_path)
cntrs = get_contours(study_uid, workspace_path)

# create the plotly time series from the 3D Image
figure = go.Figure(pex.imshow(ret_img, animation_frame=0, binary_string=True, labels=dict(animation_frame="slice")))
# TRYING TO ADD THE CONTOURS TO THE TIME SERIES IMAGE HERE
figure.add_trace(go.Contour(z=contours, showscale=False, contours=dict(coloring='lines'), line_width=2))

figure.update_layout(autosize=True, width=725, height=725)
div = opy.plot(figure, auto_open=False, output_type='div', auto_play=False)

Here the img and cntrs have the same structure; as in a 3D-image array. Basically each slice of the 3D image can have a different respective contour which is available in the cntrs .

What would be the best approach to go about this?

Thanks in advance!