.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/surface_analyses/plot_geodesic_distance.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_surface_analyses_plot_geodesic_distance.py: =========================== Plotting Geodesic Distances =========================== This plots the distances (in mm) between a vertex or set of vertices and all other vertices on a surface. These two operations take the exact same amount of time to run. To look at the distance to a single point, just supply the index of that vertex. To look at the distance to a set of points, supply a numpy array of all of the vertices in the area. In the case of a set of points, the geodesic distance measure will return the minimum distance to the set of points as a whole. The two hemispheres must be run separately. .. GENERATED FROM PYTHON SOURCE LINES 18-56 .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/surface_analyses/images/sphx_glr_plot_geodesic_distance_001.png :alt: plot geodesic distance :srcset: /auto_examples/surface_analyses/images/sphx_glr_plot_geodesic_distance_001.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/surface_analyses/images/sphx_glr_plot_geodesic_distance_002.png :alt: plot geodesic distance :srcset: /auto_examples/surface_analyses/images/sphx_glr_plot_geodesic_distance_002.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none /opt/hostedtoolcache/Python/3.9.12/x64/lib/python3.9/site-packages/scipy/sparse/linalg/_dsolve/linsolve.py:322: SparseEfficiencyWarning: splu requires CSC matrix format warn('splu requires CSC matrix format', SparseEfficiencyWarning) Failed to get connection ** (inkscape:5473): CRITICAL **: 01:32:28.085: dbus_g_proxy_new_for_name: assertion 'connection != NULL' failed ** (inkscape:5473): CRITICAL **: 01:32:28.085: dbus_g_proxy_call: assertion 'DBUS_IS_G_PROXY (proxy)' failed ** (inkscape:5473): CRITICAL **: 01:32:28.085: dbus_g_connection_register_g_object: assertion 'connection != NULL' failed Failed to get connection ** (inkscape:5477): CRITICAL **: 01:32:29.814: dbus_g_proxy_new_for_name: assertion 'connection != NULL' failed ** (inkscape:5477): CRITICAL **: 01:32:29.814: dbus_g_proxy_call: assertion 'DBUS_IS_G_PROXY (proxy)' failed ** (inkscape:5477): CRITICAL **: 01:32:29.814: dbus_g_connection_register_g_object: assertion 'connection != NULL' failed | .. code-block:: default import cortex import cortex.polyutils import numpy as np import matplotlib.pyplot as plt subject = "S1" # First we need to import the surfaces for this subject surfs = [cortex.polyutils.Surface(*d) for d in cortex.db.get_surf(subject, "fiducial")] # Then we will pick one vertex in each hemisphere to find distances to vert = 10000 dists = [s.geodesic_distance(vert) for s in surfs] # Now we can plot these distances onto a flatmap all_dists = np.hstack((dists[0], dists[1])) dist_map = cortex.Vertex(all_dists, subject, cmap="hot") cortex.quickshow(dist_map) plt.show() # Alternatively, you can find the minimum distance from a set of points to the # surface # Here, we use an example of an ROI all_eba = cortex.utils.get_roi_verts(subject, "EBA")["EBA"] # We have to then separate these vertices by hemisphere numl = surfs[0].pts.shape[0] eba_verts = [all_eba[all_eba < numl], all_eba[all_eba >= numl] - numl] # Now look at geodesic distances for each hemisphere separately dists = [s.geodesic_distance(verts) for s, verts in zip(surfs, eba_verts)] all_dists = np.hstack((dists[0], dists[1])) # And now plot these distances onto the cortical surface dist_map = cortex.Vertex(all_dists, subject, cmap="hot") cortex.quickshow(dist_map) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 14.953 seconds) .. _sphx_glr_download_auto_examples_surface_analyses_plot_geodesic_distance.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: plot_geodesic_distance.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_geodesic_distance.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_