0

I have a 3D volume matrix with pressure values describing the acoustic field generated by an ultrasound transducer.

Goal: plot the data with isosurfaces value on hover.

Method: use the go.Isosurfaces from plotly.graph_objects library.

Problem: instead of showing the correct value of the isosurface on hover it shows the opposite in the colorbar. eg: ~in the centre of the volume the maximum pressure occurs but the isosurface value is low; at the limits of the volume the pressure is minimum but the isosurface shows max pressure. See figs below: fig with isosurface at centre of the volume; fig with hover at the limits of the volume

Here is an excerpt of the code, where pmax_derated is the 3D matrix:

z1 = range(0, 51)
x1 = range(0, 29) 
y1 = range(0, 45) 
surf_count=50
isomin=np.min(pmax_derated)
isomax=np.max(pmax_derated)
  
X, Y, Z = np.meshgrid(x1, y1, z1)
  
values = np.transpose(pmax_derated,(1,2,0)) #orientation changes to match the coordinates

title_colorbar='Peak Pressure (Pa)'

fig = go.Figure(data=[            
        go.Isosurface(
            x=X.flatten(),
            y=Y.flatten(),
            z=Z.flatten(),
            value=values.flatten(order='C'),
            isomin=isomin,
            isomax=isomax,
            surface_fill=0.3,
            surface_count=2,
            surface_pattern = "odd",
            caps=dict(x_show=False, y_show=False, z_show=False),
            slices_z=dict(show=True, locations=[21]),
            slices_y=dict(show=True, locations=[24]),
            slices_x=dict(show=True, locations=[11]),
            colorscale='jet',
            colorbar_title=title_colorbar,
            name="Acoustic field",
            contour = dict(show=True, width=5, color='aliceblue'),
            )
        ])

fig.update_layout(scene = dict(
                    xaxis_title='height',
                    yaxis_title='width',
                    zaxis_title='depth',
                    #camera=camera
                    ),
    title_text=title)
fig.show()

I don't understand what is the problem, the data is correct, as it can be seen from the colorbar. I've looked for the properties of go.Isosurface but have not found an error, or a property that is ultimately wrong. Does anyone have any idea? Thank you in advance!

0 Answers0