Commit 7c950ddf authored by Can Pervane's avatar Can Pervane

Added time column to the datframe that has the time signals of each waveform.

Depending on the length of the filter coefficient the starting and end time of the time series will change. This is automatically calculated from the filter coefficient length.
A higher value of the number of coefficients will generate a more accurate filter, but it will chop a bigger portion away of the raw data. Where as a small value of number of coefficient will reduce the accuracy of the filters but it will chop less potion of the raw data.

The default value of the number of coefficient is 4001, which gives a very accurate filter response. and it chops the first and last 8 seconds of the raw data.
parent 52d9e221
......@@ -37,26 +37,28 @@ def extractWaves(session, n=4001, samplingRate=256, wave='all'):
:return: 0 if success, 1 if it failed
:rtype: int
# Create a dictionary of filter coefficients, the keys are waveforms
b = {}
if (wave == 'all'):
waves = ['delta', 'theta', 'alpha', 'beta', 'gamma']
for i in waves:
b[i] = FIR(n,samplingRate, wave)
b[i] = FIR(n,samplingRate, i)
b[wave] = FIR(n,samplingRate, wave)
if not hasattr(session, "waves"):
# create a dictionary of pandas dataframes
session.waves = {}
chop = int((n-1)/2)
columns = [col for col in session.raw.columns if col not in ignore_columns]
for key in b:
df = pd.DataFrame()
for col in columns:
# apply filter, via convolution
df = pd.DataFrame()
s = pd.Series(np.convolve(session.raw[col], b[key], mode='valid'))
df["_".join([col,wave])] = s
df[col] = s
df['time'] = session.raw['time'][chop:-chop].reset_index(drop=True)
session.waves[key] = df
return 0
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment