[Mne_analysis] Concatenating raw instances with Raw.append

Eric Larson larson.eric.d at gmail.com
Thu Jul 11 20:42:43 EDT 2013
Search archives:

Hey Kambiz,

This problem has to do with the use of class methods. Generally you should
use class methods (e.g., Raw.append()) on instantiated objects, not by
accessing them through the class name. What I mean is that you'd generally
do this:

raw0 = mne.fiff.Raw(fname0)
raw1 = mne.fiff.Raw(fname1)
raw = raw0.append(raw1)

Note how the append() method is called from the instantiated Raw instance
"raw0", not by calling mne.fiff.Raw.append(). So you'd want to do any of
the following:

raw = raws[0].append(raws[1:])
raw = raws[0].append(raws[1])
raw = mne.fiff.concatenate_raw(raws)

I find the last use case the most intuitive, so it's generally what I use.

In mne-python, classes (e.g., Raw, Epochs, SourceEstimate) and their
methods can be differentiated from normal functions (e.g.,
concatenate_raws) by the use of uppercase letters at the beginning of the
name. So if you ever find yourself trying to use a method within a
capital-letter namespace (e.g., mne.Epochs.add_proj), it's probably not the
ideal way to accomplish what you're going for.

Eric



On Thu, Jul 11, 2013 at 5:16 PM, Kambiz Tavabi <ktavabi at uw.edu> wrote:

> Hi all,
> According to the mne-python reference the input argument to
> mne.fiff.Raw.append may be a list of Raw instances. As such, could someone
> explain to me why the following doesn't work:
>
> In: raws = [fiff.Raw(f) for f in file_list]
> In: print raws
> Out: [<Raw  |  n_channels x n_times : 392 x 1302000>, <Raw  |  n_channels
> x n_times : 392 x 724000>]
>
> In: raw = mne.fiff.Raw.append(raws)
> Out: TypeError: unbound method append() must be called with Raw instance
> as first argument (got list instance instead)
>
> When I ask for type(raws) I get <type 'list'>, so how is it not a list of
> Raw instances that satisfies append?
>
> cheers
> Kambiz
>
> _______________________________________________
> 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/20130711/c79c61f4/attachment.html 


More information about the Mne_analysis mailing list