Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions examples/example_curvature.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,11 @@
)
angular_error_1 = 180 * angular_error_1 / np.pi


#############################################################################
# VISUALIZATION USING EXTERNAL TOOLS
# VISUALIZATION USING INTERNAL TOOLS
#############################################################################

import slam.plot as splt

vertices = mesh.vertices
Expand All @@ -161,10 +163,12 @@
[0, np.cos(theta), -np.sin(theta)],
[0, np.sin(theta), np.cos(theta)]])
vertices_translate = np.dot(rot_x, vertices_translate.T).T
rot_z = np.array([[np.cos(theta), -np.sin(theta),0],
[np.sin(theta), np.cos(theta),0],
[0, 0, 1],])
rot_z = np.array([[np.cos(theta), -np.sin(theta), 0],
[np.sin(theta), np.cos(theta), 0],
[0, 0, 1], ])
vertices_translate = np.dot(rot_z, vertices_translate.T).T

# Plot Mean Curvature
display_settings = {}
display_settings['colorbar_label'] = 'Mean Curvature'
mesh_data = {}
Expand All @@ -180,6 +184,7 @@
display_settings=display_settings)
Fig.show()

# Plot Gaussian Curvature
mesh_data['title'] = 'example_mesh.gii Gaussian Curvature'
intensity_data['values'] = gaussian_curv
display_settings['colorbar_label'] = 'Gaussian Curvature'
Expand All @@ -189,6 +194,7 @@
display_settings=display_settings)
Fig.show()

# Plot Shape Index
mesh_data['title'] = 'example_mesh.gii Shape Index'
intensity_data['values'] = shapeIndex
display_settings['colorbar_label'] = 'Shape Index'
Expand All @@ -198,6 +204,7 @@
display_settings=display_settings)
Fig.show()

# Plot Curvedness
mesh_data['title'] = 'example_mesh.gii Curvedness'
intensity_data['values'] = curvedness
display_settings['colorbar_label'] = 'Curvedness'
Expand All @@ -207,6 +214,7 @@
display_settings=display_settings)
Fig.show()

# Plot Quadric K Mean Absolute Change
mesh_data['vertices'] = quadric.vertices
mesh_data['faces'] = quadric.faces
mesh_data['title'] = 'Quadric K Mean Absolute Change'
Expand All @@ -218,6 +226,7 @@
display_settings=display_settings)
Fig.show()

# Plot Quadric Angular Error 0
mesh_data['title'] = 'Quadric Angular Error 0'
intensity_data['values'] = angular_error_0
display_settings['colorbar_label'] = 'Angular Error 0'
Expand All @@ -227,7 +236,8 @@
display_settings=display_settings)
Fig.show()

mesh_data['title'] = ('Quadric Angular Error 1')
# Plot Quadric Angular Error 1
mesh_data['title'] = 'Quadric Angular Error 1'
intensity_data['values'] = angular_error_1
display_settings['colorbar_label'] = 'Angular Error 1'
Fig = splt.mes3d_projection(
Expand Down
62 changes: 57 additions & 5 deletions examples/example_distortion.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,65 @@
edge_diff = sdst.edge_length_difference(mesh, mesh_s)
edge_diff


#############################################################################
# VISUALIZATION USING EXTERNAL TOOLS
# VISUALIZATION USING INTERNAL TOOLS
#############################################################################

import slam.plot as splt

# # Visualization of the original mesh
# visb_sc = splt.visbrain_plot(mesh=mesh, caption="original mesh")
# visb_sc.preview()
vertices = mesh.vertices
# center the vertices
vertices = vertices - np.mean(vertices, axis=0)
vertices_translate = np.copy(vertices)
# rotate the vertices
theta = np.pi / 2
rot_x = np.array([[1, 0, 0],
[0, np.cos(theta), -np.sin(theta)],
[0, np.sin(theta), np.cos(theta)]])
vertices_translate = np.dot(rot_x, vertices_translate.T).T
rot_z = np.array([[np.cos(theta), -np.sin(theta), 0],
[np.sin(theta), np.cos(theta), 0],
[0, 0, 1],])
vertices_translate = np.dot(rot_z, vertices_translate.T).T
display_settings = {}
mesh_data = {}
mesh_data['vertices'] = vertices_translate
mesh_data['faces'] = mesh.faces
mesh_data['title'] = 'example_mesh.gii Original Mesh'
intensity_data = None
Fig = splt.mes3d_projection(
mesh_data=mesh_data,
intensity_data=intensity_data,
display_settings=display_settings)
Fig.show()

# ############################################################################
# # Visualization of the smoothed mesh
# visb_sc = splt.visbrain_plot(mesh=mesh_s, caption="smoothed mesh")
# visb_sc.preview()

vertices = mesh_s.vertices
# center the vertices
vertices = vertices - np.mean(vertices, axis=0)
vertices_translate = np.copy(vertices)
# rotate the vertices
theta = np.pi / 2
rot_x = np.array([[1, 0, 0],
[0, np.cos(theta), -np.sin(theta)],
[0, np.sin(theta), np.cos(theta)]])
vertices_translate = np.dot(rot_x, vertices_translate.T).T
rot_z = np.array([[np.cos(theta), -np.sin(theta), 0],
[np.sin(theta), np.cos(theta), 0],
[0, 0, 1],])
vertices_translate = np.dot(rot_z, vertices_translate.T).T
display_settings = {}
mesh_data = {}
mesh_data['vertices'] = vertices_translate
mesh_data['faces'] = mesh_s.faces
mesh_data['title'] = 'example_mesh.gii Smoothed Mesh'
intensity_data = None
Fig = splt.mes3d_projection(
mesh_data=mesh_data,
intensity_data=intensity_data,
display_settings=display_settings)
Fig.show()
2 changes: 1 addition & 1 deletion examples/example_texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@
intensity_data,
display_settings,
)

fig.show()
#os.makedirs(PATH, exist_ok=True)
#fig.write_image(SAVE_DIR, width=1600, height=900)
84 changes: 73 additions & 11 deletions examples/example_topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,81 @@
print(mesh.is_watertight)
print(mesh_closed.is_watertight)


print('close mesh')
broken_vertices_mesh_closed = stop.broken_vertices(mesh_closed)
print(np.count_nonzero(broken_vertices_mesh_closed))
print('open mesh')
broken_vertices_open_mesh = stop.broken_vertices(open_mesh)
print(np.count_nonzero(broken_vertices_open_mesh))

#############################################################################
# VISUALIZATION USING EXTERNAL TOOLS
# VISUALIZATION USING INTERNAL TOOLS
#############################################################################
# import slam.plot as splt
# from vispy.scene import Line
# from visbrain.objects import VispyObj, SourceObj
#

import slam.plot as splt

vertices = mesh_closed.vertices
# center the vertices
vertices = vertices - np.mean(vertices, axis=0)
vertices_translate = np.copy(vertices)
# rotate the vertices
theta = np.pi / 2
rot_x = np.array([[1, 0, 0],
[0, np.cos(theta), -np.sin(theta)],
[0, np.sin(theta), np.cos(theta)]])
vertices_translate = np.dot(rot_x, vertices_translate.T).T
rot_z = np.array([[np.cos(theta), -np.sin(theta), 0],
[np.sin(theta), np.cos(theta), 0],
[0, 0, 1], ])
vertices_translate = np.dot(rot_z, vertices_translate.T).T

# Plot Mean Curvature
display_settings = {}
display_settings['colorbar_label'] = 'Broken Vertices'
mesh_data = {}
mesh_data['vertices'] = vertices_translate
mesh_data['faces'] = mesh_closed.faces
mesh_data['title'] = 'Mesh Close'
intensity_data = {}
intensity_data['values'] = broken_vertices_mesh_closed
intensity_data["mode"] = "vertex"
Fig = splt.mes3d_projection(
mesh_data=mesh_data,
intensity_data=intensity_data,
display_settings=display_settings)
Fig.show()



vertices = open_mesh.vertices
# center the vertices
vertices = vertices - np.mean(vertices, axis=0)
vertices_translate = np.copy(vertices)
# rotate the vertices
theta = np.pi / 2
rot_x = np.array([[1, 0, 0],
[0, np.cos(theta), -np.sin(theta)],
[0, np.sin(theta), np.cos(theta)]])
vertices_translate = np.dot(rot_x, vertices_translate.T).T
rot_z = np.array([[np.cos(theta), -np.sin(theta), 0],
[np.sin(theta), np.cos(theta), 0],
[0, 0, 1], ])
vertices_translate = np.dot(rot_z, vertices_translate.T).T
display_settings = {}
display_settings['colorbar_label'] = 'Broken Vertices'
mesh_data = {}
mesh_data['vertices'] = vertices_translate
mesh_data['faces'] = open_mesh.faces
mesh_data['title'] = 'Mesh Close'
intensity_data = {}
intensity_data['values'] = broken_vertices_open_mesh
intensity_data["mode"] = "vertex"
Fig = splt.mes3d_projection(
mesh_data=mesh_data,
intensity_data=intensity_data,
display_settings=display_settings)
Fig.show()
# ###############################################################################
# # show the result
# # WARNING : BrainObj should be added first before
Expand Down Expand Up @@ -222,9 +290,3 @@
# visb_sc5 = splt.visbrain_plot(mesh=mesh_closed, caption="closed mesh")
# visb_sc5.preview()

print('close mesh')
broken_vertices = stop.broken_vertices(mesh_closed)
print(np.count_nonzero(broken_vertices))
print('open mesh')
broken_vertices = stop.broken_vertices(open_mesh)
print(np.count_nonzero(broken_vertices))
4 changes: 3 additions & 1 deletion examples/example_vertex_voronoi.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@
print(vert_vor.shape)
print(np.sum(vert_vor) - mesh.area)


#############################################################################
# VISUALIZATION USING EXTERNAL TOOLS
# VISUALIZATION USING INTERNAL TOOLS
#############################################################################

import slam.plot as splt
###############################################################################
# Visualization
Expand Down
9 changes: 0 additions & 9 deletions examples/test.gii

This file was deleted.

2 changes: 1 addition & 1 deletion slam/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,4 @@ def mes3d_projection(mesh_data, intensity_data=None, display_settings=None):
},
)

return fig
return fig
Loading