how to save source estamates from sphere label generated by mne.label.grow_labels

Hi Alex,

sorry to keep on pestering but, in trying to grow my label i do the following and get the following result:

# read inverse solution
stc = mne.read_source_estimate(fname_meeg_stc)

# load the anatomical ROI
anat_label1 = mne.labels_from_parc(subject, parc='aparc',
                                  subjects_dir=data_path,
                                  regexp='superiortemporal-rh')[0][0]

# extract the anatomical time course for each label
stc_anat_label1 = stc.in_label(anat_label1)

# calculate center of mass and transform to mni coordinates
vtx, _, t_anat_label1 = stc_anat_label1.center_of_mass(subject)
mni_anat_label1 = mne.vertex_to_mni(vtx, 1, subject)[0]

#make 3mm radius sphere around vertex
anat_label1_sphere=mne.label.grow_labels(subject=subject, seeds=vtx, extents=3.0, hemis=1, subjects_dir=data_path, n_jobs=1)

# extract the vertex-sphere time course for label
stc_anat_label1_sphere=stc.in_label(anat_label1_sphere)

i get the following error:

/home/leitman/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/mne-0.7.1-py2.7.egg/mne/source_estimate.pyc in in_label(self, label)
   1089 """
   1090 # make sure label and stc are compatible
-> 1091 if label.subject is not None and self.subject is not None \
   1092 and label.subject != self.subject:
   1093 raise RuntimeError('label and stc must have same subject names, '

AttributeError: 'list' object has no attribute 'subject'

It does not seem that I can add the subject attribute mannually as there is no __dict__ object

so what should I do?

dave

Hey David,

The error is trying to tell you that the function is operating on an object
of type `list`, when you probably want to operate on a `Label`. Check out
the docs for `grow_labels` and you'll see that a list of labels is returned:

http://martinos.org/mne/stable/generated/mne.grow_labels.html#mne.grow_labels

Thus the returned `anat_label1_sphere` will be a list of Labels. The
`stc.in_label` method expects to operate on a single `Label`, not a `list`
(even if that `list` is full of `Label` objects):

http://martinos.org/mne/stable/generated/mne.SourceEstimate.html#mne.SourceEstimate.in_label

You'll thus probably have better luck with a line like:

stc_anat_label1_sphere=stc.in_label(anat_label1_sphere[0])

Checking types at the command line (and checking the reference / docstring
for methdos) can be your ally in these sorts of instances.

Eric