MNE-Python -- RawArray Info Question

Dear all,

I am trying out some new preprocessing tricks recommended by some
collaborators, which involves bandstop filtering my data to the frequencies
of electrical artifact (60, 120, 180 Hz, etc), and subtracting the
resulting time courses from the true data. (Their claim is that this
preserves coherence.) To do so, I have been trying the RawArray function,
but am having trouble passing it an Info instance. Even using the following
code produces the error reproduced below. This is surprising, as I'm only
translating an instance of raw to a PANDAS dataframe, and then a Numpy
array. Any advice?

raw = mne.io.Raw('some_data.fif', preload=True)
raw_df = raw.as_data_frame()
raw_mat = raw_df.as_matrix()
new_raw = mne.io.RawArray(raw_mat, raw.info)

ValueError Traceback (most recent call
last)<ipython-input-162-10b3fdc10c23> in <module>() 1 raw_mat =
raw.as_data_frame() 2 raw_mat = raw_mat.as_matrix()----> 3
new_raw = mne.io.RawArray(raw_mat, raw.info)
/mne/io/array/array.pyc in __init__(self, data, info, verbose)
/mne/utils.pyc in verbose(function, *args, **kwargs) 549
return ret 550 else:--> 551 ret = function(*args,
**kwargs) 552 return ret 553
/usr/pubsw/packages/python/anaconda/lib/python2.7/site-packages/mne/io/array/array.pyc
in __init__(self, data, info, verbose) 39 40 if
len(data) != len(info['ch_names']):---> 41 raise
ValueError('len(data) does not match len(info["ch_names"])') 42
     assert len(info['ch_names']) == info['nchan'] 43
ValueError: len(data) does not match len(info["ch_names"])

Best,
Sam Zorowitz

Clinical Research Coordinator
Department of Psychiatry: Neurosciences
Division of Neurotherapeutics
Massachusetts General Hospital
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20141225/98c21b53/attachment.html

hi Sam,

I am trying out some new preprocessing tricks recommended by some
collaborators, which involves bandstop filtering my data to the frequencies
of electrical artifact (60, 120, 180 Hz, etc), and subtracting the resulting
time courses from the true data. (Their claim is that this preserves
coherence.) To do so, I have been trying the RawArray function, but am
having trouble passing it an Info instance. Even using the following code
produces the error reproduced below. This is surprising, as I'm only
translating an instance of raw to a PANDAS dataframe, and then a Numpy
array. Any advice?

you don't need to have a pandas dataframe as you already have a numpy
array in raw._data

so raw_mat is just raw._data

also a recommendation is to never use numpy matrices but just arrays.

HTH
Alex

I think you forgot to transpose your matrix before supplying it to RawArray
:slight_smile:

Thank you both for the help!
-Sam