.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/surface_analyses/plot_subsurfaces.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_surface_analyses_plot_subsurfaces.py: ============================= Plot and Use Subsurface Tools ============================= Subsurfaces can be used for efficient operations on subsets of cortical surface .. GENERATED FROM PYTHON SOURCE LINES 9-24 .. code-block:: Python import tempfile import matplotlib.pyplot as plt import numpy as np import cortex.polyutils subject = 'S1' left, right = cortex.db.get_surf(subject, 'fiducial') left_surface = cortex.polyutils.Surface(left[0], left[1]) right_surface = cortex.polyutils.Surface(right[0], right[1]) .. GENERATED FROM PYTHON SOURCE LINES 25-26 create subsurface .. GENERATED FROM PYTHON SOURCE LINES 26-33 .. code-block:: Python center = 125000 radius = 7 patch = left_surface.get_geodesic_patch(center, radius=radius) subsurface = left_surface.create_subsurface(vertex_mask=patch['vertex_mask']) .. GENERATED FROM PYTHON SOURCE LINES 34-35 plot data on subsurface .. GENERATED FROM PYTHON SOURCE LINES 35-42 .. code-block:: Python data = subsurface.geodesic_distance([0]) + 20 dataset = cortex.Vertex(subsurface.lift_subsurface_data(data), subject, cmap='viridis') cortex.quickshow(dataset) plt.title('example subsurface data') plt.show() .. image-sg:: /auto_examples/surface_analyses/images/sphx_glr_plot_subsurfaces_001.png :alt: example subsurface data :srcset: /auto_examples/surface_analyses/images/sphx_glr_plot_subsurfaces_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none Background RRGGBBAA: ffffff00 Area 0:0:1960.5:1024 exported to 1960 x 1024 pixels (96 dpi) .. GENERATED FROM PYTHON SOURCE LINES 43-45 plot subsurface as gif .. GENERATED FROM PYTHON SOURCE LINES 45-51 .. code-block:: Python f, path = tempfile.mkstemp() path = path + '.gif' # subsurface.plot_subsurface_rotating_gif(path=path) .. GENERATED FROM PYTHON SOURCE LINES 52-53 .. image:: ../../example_subsurface.gif .. GENERATED FROM PYTHON SOURCE LINES 56-58 create many patches .. GENERATED FROM PYTHON SOURCE LINES 58-76 .. code-block:: Python patches = left_surface.get_geodesic_patches( seeds=np.arange(0, 150000, 1000), radius=8, ) dataset = cortex.Vertex( patches['vertex_masks'].sum(0), subject, cmap='viridis', vmin=-1, vmax=1, ) cortex.quickshow(dataset) plt.title('patches') plt.show() .. image-sg:: /auto_examples/surface_analyses/images/sphx_glr_plot_subsurfaces_002.png :alt: patches :srcset: /auto_examples/surface_analyses/images/sphx_glr_plot_subsurfaces_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none Background RRGGBBAA: ffffff00 Area 0:0:1960.5:1024 exported to 1960 x 1024 pixels (96 dpi) .. GENERATED FROM PYTHON SOURCE LINES 77-78 create geodesic strip patch .. GENERATED FROM PYTHON SOURCE LINES 78-95 .. code-block:: Python patch = left_surface.get_geodesic_strip_patch(v0=70000, v1=125000, radius=5) dataset = cortex.Vertex(patch['vertex_mask'], subject, vmin=-1, vmax=1, cmap='viridis') cortex.quickshow(dataset) plt.title('strip patch') plt.show() dataset = cortex.Vertex(patch['coordinates'][0, :], subject, cmap='viridis') cortex.quickshow(dataset) plt.title('first coordinate, distance along central geodesic axis') plt.show() dataset = cortex.Vertex(patch['coordinates'][1, :], subject, cmap='viridis', vmin=-5, vmax=5) cortex.quickshow(dataset) plt.title('second coordinate, distance from central geodesic axis') plt.show() .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/surface_analyses/images/sphx_glr_plot_subsurfaces_003.png :alt: strip patch :srcset: /auto_examples/surface_analyses/images/sphx_glr_plot_subsurfaces_003.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/surface_analyses/images/sphx_glr_plot_subsurfaces_004.png :alt: first coordinate, distance along central geodesic axis :srcset: /auto_examples/surface_analyses/images/sphx_glr_plot_subsurfaces_004.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/surface_analyses/images/sphx_glr_plot_subsurfaces_005.png :alt: second coordinate, distance from central geodesic axis :srcset: /auto_examples/surface_analyses/images/sphx_glr_plot_subsurfaces_005.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none Background RRGGBBAA: ffffff00 Area 0:0:1960.5:1024 exported to 1960 x 1024 pixels (96 dpi) Background RRGGBBAA: ffffff00 Area 0:0:1960.5:1024 exported to 1960 x 1024 pixels (96 dpi) Background RRGGBBAA: ffffff00 Area 0:0:1960.5:1024 exported to 1960 x 1024 pixels (96 dpi) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 19.551 seconds) .. _sphx_glr_download_auto_examples_surface_analyses_plot_subsurfaces.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_subsurfaces.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_subsurfaces.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_