[Mne_analysis] Question about copy/inplace operations

Andre Sevenius sevenius.nilsen at gmail.com
Sun Oct 28 12:19:37 EDT 2018
Search archives:

        External Email - Use Caution        

Hi all,
This might seem like an easy question, but I've tried everything.
I want to test out different filters on the same data, say 1-5hz, 5-10hz,
etc. So I have a function that implements whatever filters I want from a
list.  This function returns all instances of raw sent to it, with filters
applied.
However, when I use raw.filter - operations happen in place, and when I try
the next filter (5-10hz), it's applying that to 1-5hz filtered data. The
same happens if I use mne.filter.filter_data(copy=True).
The same also happens if I use raw2=raw.copy() or even
raw2=copy.deepcopy(raw.copy()), before applying filters with either
raw2.filter or raw2=mne.filter.filter_data. The original raw object also
gets filtered.
Preload is set to true, and I've even tried setting raw._data =
mne.filter.filter_data(copy=True), but it still has retroactive effect!
Clearly, I must be misunderstanding something here, but how do I make a
copy of some data/raw object that I can manipulate without having to
manually use arrays?

my function goes like this:
def filter(data, params): #data is a raw object
  temp = copy.deepcopy(data.copy())
  temp._data=mne.filter.filter_data(temp.get_data(), params, copy=True)
  return copy.deepcopy(temp)

and I call it by:
temp = filter(data,params)

Thank you,
André
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20181028/99bb91c2/attachment.html 


More information about the Mne_analysis mailing list