Note
Click here to download the full example code
Example of morphological distortion in slam¶
# Authors:
# Guillaume Auzias <guillaume.auzias@univ-amu.fr>
# Julien Barrès <julien.barres@etu.univ-amu.fr>
# License: BSD (3-clause)
# sphinx_gallery_thumbnail_number = 2
Importation of slam modules
import slam.distortion as sdst
import slam.differential_geometry as sdg
import slam.plot as splt
import slam.io as sio
import numpy as np
Loading an example mesh and a smoothed copy of it
mesh = sio.load_mesh("../examples/data/example_mesh.gii")
mesh_s = sdg.laplacian_mesh_smoothing(mesh, nb_iter=50, dt=0.1)
Out:
Smoothing mesh
Computing Laplacian
Computing mesh weights of type fem
-edge length threshold needed for 0 values = 0.0 %
-number of Nan in weights: 0 = 0.0 %
-number of Negative values in weights: 936 = 6.706792777300086 %
-nb Nan in Laplacian : 0
-nb Inf in Laplacian : 0
0
10
20
30
40
OK
Visualization of the original mesh
visb_sc = splt.visbrain_plot(mesh=mesh, caption="original mesh")
visb_sc.preview()
Visualization of the smoothed mesh
visb_sc = splt.visbrain_plot(mesh=mesh_s, caption="smoothed mesh")
visb_sc.preview()
Computation of the angle difference between each faces of mesh and mesh_s
angle_diff = sdst.angle_difference(mesh, mesh_s)
angle_diff
Out:
array([[-0.18881895, 0.12117287, 0.06764609],
[ 0.05797368, 0.03686888, -0.09484256],
[ 0.07230468, 0.16239874, -0.23470342],
...,
[-0.08685515, 0.03678422, 0.05007093],
[ 0.0635167 , -0.10415994, 0.04064324],
[ 0.05023476, -0.0978278 , 0.04759305]])
face_angle_dist = np.sum(np.abs(angle_diff), 1)
face_angle_dist
Out:
array([0.3776379 , 0.18968511, 0.46940683, ..., 0.1737103 , 0.20831988,
0.19565561])
Computation of the area difference between each faces of mesh and mesh_s
Out:
array([0.42263817, 0.20383547, 0.26206739, ..., 0.08069364, 0.08235209,
0.18712064])
Computation of the length difference between each edges of mesh and mesh_s
edge_diff = sdst.edge_length_difference(mesh, mesh_s)
edge_diff
Out:
TrackedArray([0.2547129 , 0.23347774, 0.18442651, ..., 0.25986046,
0.1005251 , 0.08211042])
Total running time of the script: ( 0 minutes 1.389 seconds)