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

Eric Larson larson.eric.d at gmail.com
Tue Jan 14 13:14:19 EST 2014
Search archives:

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



On Tue, Jan 14, 2014 at 10:03 AM, David Leitman
<leitman at mail.med.upenn.edu>wrote:

> 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
>
>
>
>
> ----- Original Message -----
> From: "Alexandre Gramfort" <alexandre.gramfort at telecom-paristech.fr>
> To: "David I Leitman" <leitman at mail.med.upenn.edu>
> Sent: Tuesday, January 14, 2014 5:32:40 AM
> Subject: Re: [Mne_analysis] how to save source estamates from epoched data
> set with multiple events
>
> > thanks I have been using this example as a base but I was curious about
> the
> > following:
> > 1. can stc.extract_label_time_course  work on a epoched data . fif file
> > containing all my event condtions
>
> no. You will need individual STCs and lose track of event conditions.
> Maybe we could do better ...
>
> > 2.  lets say I want to extract  as a time course just the vertices with
> the
> > center of mass or perhaps an roi reflecting this vertices and a small
> number
> > of neighboring vertices instead of the mean of a whole anatomic roi
> label.
> > how could I do that?
>
> you can grow labels given a seed but you'll need to define a label.
>
> stc.data contains the time course of all vertices in the label. It's a
> plain
> numpy array so you can manipulate it as you want.
>
> > 3 ) with np.save can I also ad a vector that corresponds to the event
> type
> > that each epoch represents?
>
> to save multiple arrays in one file use scipy.io.savemat (to write a
> matlab file)
>
> HTH
> Alex
> _______________________________________________
> Mne_analysis mailing list
> Mne_analysis at nmr.mgh.harvard.edu
> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
>
>
> The information in this e-mail is intended only for the person to whom it
> is
> addressed. If you believe this e-mail was sent to you in error and the
> e-mail
> contains patient information, please contact the Partners Compliance
> HelpLine at
> http://www.partners.org/complianceline . If the e-mail was sent to you in
> error
> but does not contain patient information, please contact the sender and
> properly
> dispose of the e-mail.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20140114/13061af4/attachment.html 


More information about the Mne_analysis mailing list