Saving data from mne.Epochs

Greetings,

When running a script which contains the following line:

<<<
# Read epochs
myepochs = mne.Epochs(raw, events, event_id, tmin, tmax, proj=True,
        picks=picks, baseline=(None, 0), preload=True,
        reject=dict(grad=4000e-13, mag=4e-12, eog=150e-6))
outfile = myepochs.get_data()

outfile.save('subj_rest_raw_epoch.fif')

*I receive this error message:

*<<<
Traceback (most recent call last):
  File "resting_V3.py", line 55, in <module>
    outfile.save('subj_rest_raw_epoch.fif')
AttributeError: 'numpy.ndarray' object has no attribute 'save'

*Alternatively, I could forgo running epochs.get_data and just save
directly (epochs.save(...))*,

but I run into the same error except it specifies "Epochs" instead of
"numpy.ndarray" as the object with no 'save' attribute.

Is this error occurring because of a problem with my script, or might I
have something wrong with my installation of mne-python?

Thank you in advance.

::vincent
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20121217/d4cc7216/attachment.html

Hi Vincent,

the code you posted constructs an epochs object from which you get the data by calling .get_data().
The returned value however is not an epochs object anymore but a regular numpy array.
For saving your epochs say:

myepochs.save('subj_rest_raw_epoch.fif')

However make sure your mne-python version already supports this quite recent method.
In IPython try myepochs. <TAB> and see whether 'save' is being provided.
In case you don't use the current development master, there will be an official new relase before christmas.

I hope this helps.

Denis

Greetings,

When running a script which contains the following line:

<<<
# Read epochs
myepochs = mne.Epochs(raw, events, event_id, tmin, tmax, proj=True,
        picks=picks, baseline=(None, 0), preload=True,
        reject=dict(grad=4000e-13, mag=4e-12, eog=150e-6))
outfile = myepochs.get_data()

outfile.save('subj_rest_raw_epoch.fif')

I receive this error message:

<<<
Traceback (most recent call last):
  File "resting_V3.py", line 55, in <module>
    outfile.save('subj_rest_raw_epoch.fif')
AttributeError: 'numpy.ndarray' object has no attribute 'save'

Alternatively, I could forgo running epochs.get_data and just save directly (epochs.save(...)),

but I run into the same error except it specifies "Epochs" instead of "numpy.ndarray" as the object with no 'save' attribute.

Is this error occurring because of a problem with my script, or might I have something wrong with my installation of mne-python?

Thank you in advance.

::vincent

Hello all,

I am trying to epoch resting MEG data into 4 second events, remove EOG
artifacts, and save as a new file including only the good epochs. I've
upgraded to the latest nightly yesterday and attempted running this script,
but it fails to save with this error message: *

AttributeError: 'Epochs' object has no attribute 'save'*

Doesn't mne.epochs return an object which should be able to save as a fif
file?

Here is my full script in case it helps to look at:

*data_path = '/home/vrupp/data/restMEG/'
subj = raw_input('Subject ID:')
raw_fname = data_path + subj + '/' + subj + '_rest_raw_sss.fif'
event_id, tmin, tmax = 1, 0.0, 4.0

# Setup for reading the raw data
raw = fiff.Raw(raw_fname)

# Epoch data into 4s intervals
events = mne.make_fixed_length_events(raw, 1, start=0, stop=None,
        duration=4.)

# Set up pick list: (MEG-bad channels)
exclude = raw.info['bads']
picks = fiff.pick_types(raw.info, meg=True, eeg=False, stim=True, eog=True,
        exclude=exclude)

# Read epochs and remove bad epochs
epochs_outfile = mne.Epochs(raw, events, event_id, tmin, tmax, proj=True,
        picks=picks, baseline=(None, 0), preload=True,
        reject=dict(grad=4000e-13, mag=4e-12, eog=150e-6))

# Save output file
epochs_outfile.save(data_path + subj + '/' + subj + '_rest_raw_epoch.fif')*

Thanks very much for any help.

Best wishes,

Vincent Rupp

Hey Vincent,

Yes, you should be able to save epochs with 'epochs.save()'. Could you
double-check that "mne.__version__" is at '0.6.git'? That's the development
version, and it should have support for the '.save()' method. (I think the
most recent release version 0.5 also had it, incidentally.)

Eric

hi Vincent,

I suspect you're not actually running the last released version. To check

import mne
print mne.__version__

you should see 0.5 or more.

HTH
Alex

Hello all,

Thanks very much for the help! I was using 0.4 and had mistakenly assumed
MNE and mne-python were a part of the same installation package. Now the
script runs fine. Much obliged.

Best wishes,

Vincent Rupp