{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Map from Volume to Vertex Data\n\n\nIn order to move from Volume data to Vertex data, you start with data from\nvoxels and then create a cortex.Volume object. Then, you get a mapper to go\nbetween voxels and vertices for the specific subject and transform you are\nworking with. Pass the voxel volume through the mapper and you get out a\nvertex mapping of that data. You can plot both of these as you normally would.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import cortex\nimport cortex.polyutils\nimport numpy as np\nnp.random.seed(1234)\nimport matplotlib.pyplot as plt\n\nsubject = 'S1'\nxfm = 'fullhead'\n\n# First create example voxel data for this subject and transform\nvoxel_data = np.random.randn(31, 100, 100)\nvoxel_vol = cortex.Volume(voxel_data, subject, xfm)\n\n# Then we have to get a mapper from voxels to vertices for this transform\nmapper = cortex.get_mapper(subject, xfm, 'line_nearest', recache=True)\n\n# Just pass the voxel data through the mapper to get vertex data\nvertex_map = mapper(voxel_vol)\n\n# You can plot both as you would normally plot Volume and Vertex data\ncortex.quickshow(voxel_vol)\nplt.show()\ncortex.quickshow(vertex_map)\nplt.show()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.1" } }, "nbformat": 4, "nbformat_minor": 0 }