.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/utils/plot_voxel_distance_from_surface.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` 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. .. GENERATED FROM PYTHON SOURCE LINES 10-28 .. image-sg:: /auto_examples/utils/images/sphx_glr_plot_voxel_distance_from_surface_001.png :alt: plot voxel distance from surface :srcset: /auto_examples/utils/images/sphx_glr_plot_voxel_distance_from_surface_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none | .. code-block:: Python 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 3.581 seconds) .. _sphx_glr_download_auto_examples_utils_plot_voxel_distance_from_surface.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_voxel_distance_from_surface.ipynb ` .. 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-zip :download:`Download zipped: plot_voxel_distance_from_surface.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_