.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/example_distortion.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_example_distortion.py: .. _example_distortion: =================================== Example of morphological distortion in slam =================================== .. GENERATED FROM PYTHON SOURCE LINES 8-17 .. code-block:: default # Authors: # Guillaume Auzias # Julien Barrès # License: BSD (3-clause) # sphinx_gallery_thumbnail_number = 2 .. GENERATED FROM PYTHON SOURCE LINES 18-19 Importation of slam modules .. GENERATED FROM PYTHON SOURCE LINES 19-25 .. code-block:: default 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 .. GENERATED FROM PYTHON SOURCE LINES 26-27 Loading an example mesh and a smoothed copy of it .. GENERATED FROM PYTHON SOURCE LINES 27-31 .. code-block:: default mesh = sio.load_mesh("../examples/data/example_mesh.gii") mesh_s = sdg.laplacian_mesh_smoothing(mesh, nb_iter=50, dt=0.1) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none 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 .. GENERATED FROM PYTHON SOURCE LINES 32-33 Visualization of the original mesh .. GENERATED FROM PYTHON SOURCE LINES 33-36 .. code-block:: default visb_sc = splt.visbrain_plot(mesh=mesh, caption="original mesh") visb_sc.preview() .. image:: /auto_examples/images/sphx_glr_example_distortion_001.png :alt: example distortion :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 37-38 Visualization of the smoothed mesh .. GENERATED FROM PYTHON SOURCE LINES 38-41 .. code-block:: default visb_sc = splt.visbrain_plot(mesh=mesh_s, caption="smoothed mesh") visb_sc.preview() .. image:: /auto_examples/images/sphx_glr_example_distortion_002.png :alt: example distortion :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 42-43 Computation of the angle difference between each faces of mesh and mesh_s .. GENERATED FROM PYTHON SOURCE LINES 43-46 .. code-block:: default angle_diff = sdst.angle_difference(mesh, mesh_s) angle_diff .. rst-class:: sphx-glr-script-out Out: .. code-block:: none 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]]) .. GENERATED FROM PYTHON SOURCE LINES 48-51 .. code-block:: default face_angle_dist = np.sum(np.abs(angle_diff), 1) face_angle_dist .. rst-class:: sphx-glr-script-out Out: .. code-block:: none array([0.3776379 , 0.18968511, 0.46940683, ..., 0.1737103 , 0.20831988, 0.19565561]) .. GENERATED FROM PYTHON SOURCE LINES 52-53 Computation of the area difference between each faces of mesh and mesh_s .. GENERATED FROM PYTHON SOURCE LINES 53-56 .. code-block:: default area_diff = sdst.area_difference(mesh, mesh_s) area_diff .. rst-class:: sphx-glr-script-out Out: .. code-block:: none array([0.42263817, 0.20383547, 0.26206739, ..., 0.08069364, 0.08235209, 0.18712064]) .. GENERATED FROM PYTHON SOURCE LINES 57-58 Computation of the length difference between each edges of mesh and mesh_s .. GENERATED FROM PYTHON SOURCE LINES 58-60 .. code-block:: default edge_diff = sdst.edge_length_difference(mesh, mesh_s) edge_diff .. rst-class:: sphx-glr-script-out Out: .. code-block:: none TrackedArray([0.2547129 , 0.23347774, 0.18442651, ..., 0.25986046, 0.1005251 , 0.08211042]) .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 1.389 seconds) .. _sphx_glr_download_auto_examples_example_distortion.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: example_distortion.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: example_distortion.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_