.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/datasets/plot_volume_to_vertex.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_datasets_plot_volume_to_vertex.py: ============================== Map from Volume to Vertex Data ============================== In order to move from Volume data to Vertex data, you start with data from voxels and then create a cortex.Volume object. Then, you get a mapper to go between voxels and vertices for the specific subject and transform you are working with. Pass the voxel volume through the mapper and you get out a vertex mapping of that data. You can plot both of these as you normally would. .. GENERATED FROM PYTHON SOURCE LINES 12-37 .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/datasets/images/sphx_glr_plot_volume_to_vertex_001.png :alt: plot volume to vertex :srcset: /auto_examples/datasets/images/sphx_glr_plot_volume_to_vertex_001.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/datasets/images/sphx_glr_plot_volume_to_vertex_002.png :alt: plot volume to vertex :srcset: /auto_examples/datasets/images/sphx_glr_plot_volume_to_vertex_002.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Failed to get connection ** (inkscape:5131): CRITICAL **: 01:26:57.515: dbus_g_proxy_new_for_name: assertion 'connection != NULL' failed ** (inkscape:5131): CRITICAL **: 01:26:57.515: dbus_g_proxy_call: assertion 'DBUS_IS_G_PROXY (proxy)' failed ** (inkscape:5131): CRITICAL **: 01:26:57.515: dbus_g_connection_register_g_object: assertion 'connection != NULL' failed Generating a flatmap cache Failed to get connection ** (inkscape:5134): CRITICAL **: 01:26:59.615: dbus_g_proxy_new_for_name: assertion 'connection != NULL' failed ** (inkscape:5134): CRITICAL **: 01:26:59.615: dbus_g_proxy_call: assertion 'DBUS_IS_G_PROXY (proxy)' failed ** (inkscape:5134): CRITICAL **: 01:26:59.615: dbus_g_connection_register_g_object: assertion 'connection != NULL' failed | .. code-block:: default import cortex import cortex.polyutils import numpy as np np.random.seed(1234) import matplotlib.pyplot as plt subject = 'S1' xfm = 'fullhead' # First create example voxel data for this subject and transform voxel_data = np.random.randn(31, 100, 100) voxel_vol = cortex.Volume(voxel_data, subject, xfm) # Then we have to get a mapper from voxels to vertices for this transform mapper = cortex.get_mapper(subject, xfm, 'line_nearest', recache=True) # Just pass the voxel data through the mapper to get vertex data vertex_map = mapper(voxel_vol) # You can plot both as you would normally plot Volume and Vertex data cortex.quickshow(voxel_vol) plt.show() cortex.quickshow(vertex_map) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 7.047 seconds) .. _sphx_glr_download_auto_examples_datasets_plot_volume_to_vertex.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_volume_to_vertex.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_volume_to_vertex.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_