.. 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_utils_plot_voxel_distance_from_surface.py: =============================== Voxel distance from surface =============================== The utility function `get_vox_dist` returns the distance from each voxel in some space to the nearest vertex on the given surface. This function is used for generating ROI masks, cortical masks, etc. .. image:: /auto_examples/utils/images/sphx_glr_plot_voxel_distance_from_surface_001.png :alt: plot voxel distance from surface :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none | .. code-block:: default import cortex import matplotlib.pyplot as plt # get distance to nearest point on the mid-cortical (fiducial) surface from each # voxel in the functional space for subject 'S1' and the transform 'fullhead' dist, argdist = cortex.get_vox_dist(subject='S1', xfmname='fullhead', surface='fiducial') # dist contains the distance from each voxel to the nearest vertex # dist.shape = (31, 100, 100) <-- the same size as the functional volume # argdist contains the index of the nearest vertex to each voxel # argdist.shape = (31, 100, 100) <-- the same size as the functional volume # let's visualize the distance field using the mosaic function cortex.mosaic(dist, cmap=plt.cm.plasma) plt.colorbar(label='mm from surface') .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 4.244 seconds) .. _sphx_glr_download_auto_examples_utils_plot_voxel_distance_from_surface.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_voxel_distance_from_surface.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_voxel_distance_from_surface.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_