system
(system)
March 31, 2018, 11:10pm
1
Hello MNE list,
We are getting an error related to the dtype of the data when running
the mne.io.Raw filter function.
To give some context of our process,
1. We are generating the raw objects from scratch. The data generating
the raw object are in the form of? dtype('float64')
2. So we end up with 3 channels 'eeg', 'eog' and 'stim'
[OUT]
Creating RawArray with float64 data, n_channels=1, n_times=116736
Range : 0 ... 116735 = 0.000 ... 227.998 secs
Ready.
Creating RawArray with float64 data, n_channels=1, n_times=116736
Range : 0 ... 116735 = 0.000 ... 227.998 secs
Ready.
228
Creating RawArray with float64 data, n_channels=1, n_times=116736
Range : 0 ... 116735 = 0.000 ... 227.998 secs
Ready.
3. We then append all channels into the raw ['eeg'] object.
4. Now when attempting to run the filter function (The code below is
also in the MNE example repo
http://mne-tools.github.io/stable/auto_examples/time_frequency/plot_time_frequency_global_field_power.html
'''
#?? bandpass filter and compute Hilbert
/raw.filter(fmin, fmax, n_jobs=1, l_trans_bandwidth=1.0,
h_trans_bandwidth=1.0, fir_design='firwin')/
'''
we are getting the following error:
[OUT]
TypeError: Arrays passed for filtering must have a dtype of np.float64
? Do you have any hints why the filter function is unable to process
the data?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20180331/8b4e1176/attachment.html
system
(system)
April 1, 2018, 5:25pm
2
can you share a full code snippet to replicate the pb even if the data is
just random numbers?
as we don't see what you typed it's quite hard to figure out what the pb
can be.
thanks
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20180401/05ce3f48/attachment.html
system
(system)
April 2, 2018, 1:04am
3
Here is the sample code with random data generated - based on the
tutorial
http://mne-tools.github.io/stable/auto_examples/time_frequency/plot_time_frequency_global_field_power.html
# coding: utf-8
# # case-study filtering
# In[712]:
get_ipython().run_line_magic('matplotlib', 'inline')
# In[2]:
import boto3
import io
import ast
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import ast
import datetime
import mne
import ast
import time
import sys
plt.style.use('ggplot')
mne.set_log_level('WARNING')
mne.set_log_level('INFO')
# ### generate random data
system
(system)
April 2, 2018, 1:22am
4
system
(system)
April 2, 2018, 7:20am
5
you are doing:
data_EEG.apply_hilbert(n_jobs=1, envelope=False)
which operates in place and so next time you want to filter
you have complex valued data.
you need to do
raw_hilbert = data_EEG.copy().apply_hilbert(n_jobs=1, envelope=False)
please close if you confirm.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20180402/c20755e6/attachment.html
system
(system)
April 2, 2018, 5:35pm
6
Thanks for your response, That does not resolve our typeerror.
system
(system)
April 2, 2018, 5:39pm
7
you need to do
raw_hilbert = data_EEG.copy().apply_hilbert(n_jobs=1, envelope=False)
I think this is a typo and Alex meant `envelope=True`, which will return
the amplitude at each time instance.
Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20180402/b75c4d17/attachment.html
system
(system)
April 2, 2018, 6:17pm
8
Alex is correct that the type error is coming from repeatedly calling
apply_hilbert on the same data. however you are also filtering the same
data repeatedly in a loop which is most likely not what you want.
the following code snippet will make a copy of data_EEG before at the
beginning of each loop, then filter and call apply_hilbert. It runs without
error although it throws warnings as your filters are too long for your
data.
system
(system)
April 2, 2018, 6:33pm
9
Thank you all for the clarification - that solution worked.