Dataset ArithmeticΒΆ

This plots example volume data onto an example subject, S1, onto a flatmap using quickflat. In order for this to run, you have to have a flatmap for this subject in the pycortex filestore.

Once you have created a cortex.Volume object, you can manipulate it with normal arithmetic operators like +, -, , /, and *

  • plot dataset arithmetic
  • plot dataset arithmetic
  • plot dataset arithmetic

Out:

Generating a flatmap cache
Failed to get connection
** (inkscape:5116): CRITICAL **: 01:26:49.265: dbus_g_proxy_new_for_name: assertion 'connection != NULL' failed
** (inkscape:5116): CRITICAL **: 01:26:49.265: dbus_g_proxy_call: assertion 'DBUS_IS_G_PROXY (proxy)' failed
** (inkscape:5116): CRITICAL **: 01:26:49.265: dbus_g_connection_register_g_object: assertion 'connection != NULL' failed
Failed to get connection
** (inkscape:5119): CRITICAL **: 01:26:50.304: dbus_g_proxy_new_for_name: assertion 'connection != NULL' failed
** (inkscape:5119): CRITICAL **: 01:26:50.304: dbus_g_proxy_call: assertion 'DBUS_IS_G_PROXY (proxy)' failed
** (inkscape:5119): CRITICAL **: 01:26:50.304: dbus_g_connection_register_g_object: assertion 'connection != NULL' failed
Failed to get connection
** (inkscape:5122): CRITICAL **: 01:26:51.342: dbus_g_proxy_new_for_name: assertion 'connection != NULL' failed
** (inkscape:5122): CRITICAL **: 01:26:51.342: dbus_g_proxy_call: assertion 'DBUS_IS_G_PROXY (proxy)' failed
** (inkscape:5122): CRITICAL **: 01:26:51.342: dbus_g_connection_register_g_object: assertion 'connection != NULL' failed

import cortex
import numpy as np
np.random.seed(1234)
import matplotlib.pyplot as plt

subject = 'S1'
xfm = 'fullhead'

# Creating a random dataset that is the shape for this transform with one
# entry for each voxel
test_data = np.random.randn(31, 100, 100)

# This creates a Volume object for our test dataset for the given subject
# and transform
vol_data = cortex.Volume(test_data, subject, xfm, vmin=-2, vmax=2)
cortex.quickshow(vol_data)
plt.show()

# Now you can do arithmetic with the Volume
vol_plus = vol_data + 1
cortex.quickshow(vol_plus)
plt.show()

# You can also do multiplication
vol_mult = vol_data * 4
cortex.quickshow(vol_mult)
plt.show()

Total running time of the script: ( 0 minutes 18.572 seconds)

Gallery generated by Sphinx-Gallery