{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Plot Volume Data\n\n\nThis plots example volume data onto an example subject, S1, onto a flatmap\nusing quickflat. In order for this to run, you have to have a flatmap for\nthis subject in the pycortex filestore.\n\nThe cortex.Volume object is instantiated with a numpy array of the same size\nas the scan for this subject and transform. Instead of the random test data,\nyou can replace this with any numpy array of the correct dimensionality.\n\nBy changing the parameters vmin and vmax, you get thresholded data, as shown\nin the colorbar for the figure.\n\nIf you have NaN values within your array, those voxels show up transparent\non the brain.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import cortex\nimport numpy as np\nnp.random.seed(1234)\nimport matplotlib.pyplot as plt\n\nsubject = 'S1'\nxfm = 'fullhead'\n\n# Creating a random dataset that is the shape for this transform with one\n# entry for each voxel\ntest_data = np.random.randn(31, 100, 100)\n\n# This creates a Volume object for our test dataset for the given subject\n# and transform\nvol_data = cortex.Volume(test_data, subject, xfm)\ncortex.quickshow(vol_data)\nplt.show()\n\n# Can also alter the minimum and maximum values shown on the colorbar\nvol_data_thresh = cortex.Volume(test_data, subject, xfm, vmin=-1, vmax=1)\ncortex.quickshow(vol_data_thresh)\nplt.show()\n\n# If you have NaN values, those voxels show up transparent on the brain\ntest_data[10:15, :, :] = np.nan\nvol_data_nan = cortex.Volume(test_data, subject, xfm)\ncortex.quickshow(vol_data_nan)\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 }