Wednesday, July 2, 2014

Day 32: Reading and writing volume names to fif file

Notebook

Today I added functionality to read and write segmentation information into .fif files. This is handy for distinguishing
between multiple source spaces, each corresponding to a particular subcortical volume.

For an idea of the changes needed in the MNE code, check out the latest commit to my pull request.

Below is a verification that everything worked.

In [21]:
import mne
from mne.datasets import spm_face

mne.set_log_level(False)

data_path = spm_face.data_path()

# setup the cortical surface space
src_fname = data_path + '/MEG/spm/combined-src.fif'
src = mne.setup_source_space('spm', overwrite=True)
The add_dist parameter to mne.setup_source_space currently defaults to False, but the default will change to True in release 0.9. Specify the parameter explicitly to avoid this warning.

In [22]:
# add two subcortical volumes
src = mne.source_space.add_subcortical_volumes(src, ['Left-Amygdala', 'Right-Amygdala'])
mne.write_source_spaces(src_fname, src)
/home/alan/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/lib/shape_base.py:834: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return c.reshape(shape)
/home/alan/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/lib/shape_base.py:834: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return c.reshape(shape)
/home/alan/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/lib/shape_base.py:834: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return c.reshape(shape)

In [23]:
# display volume names
src[2]['seg_name'], src[3]['seg_name']
Out[23]:
('Left-Amygdala', 'Right-Amygdala')
In [24]:
# read saved version of combined source space
src_read = mne.read_source_spaces(src_fname)
In [25]:
# display volume names
src_read[2]['seg_name'], src_read[3]['seg_name']
Out[25]:
(u'Left-Amygdala', u'Right-Amygdala')

No comments:

Post a Comment