Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature extraction update #2

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Akashkharita
Copy link

No description provided.

env = compute_envelope(tr.data)

if envfilter == True:
sos = signal.butter(1, 0.01, 'lp', fs = tr.stats.sampling_rate, output = 'sos')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i see here that the bounds of the filter are hardcoded in the function. would you consider moving these frequencies out of the function as argument? they could belong to a dictionary so that they remain specific to each function but also general enough that users can play with these frequency bands without having the change the functions

@@ -55,6 +77,8 @@ def compute_hibert(tr, env):
auto = np.correlate(tr.data, tr.data, 'same') ## autocorrelation function

t = tr.times()

# family number 1: Based on waveforms.
all_attr[0,0] = t[-1] - t[0] # Duration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this duration? that seems to be just the window length

sos_5_70 = signal.butter(N = 2, Wn= [3,10], btype = 'bp', fs=tr.stats.sampling_rate, output='sos')
sos_50_100 = signal.butter(N = 2, Wn= [10,20], btype = 'bp', fs=tr.stats.sampling_rate, output='sos')
sos_5_100 = signal.butter(N = 2, Wn= [20,50], btype = 'bp', fs=tr.stats.sampling_rate, output='sos')
sos_0p1_1 = signal.butter(N = 2, Wn= [0.1,1], btype = 'bp', fs=tr.stats.sampling_rate, output='sos')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hardcoding frequency in these filters could be prone to bugs for other users.


ft = ft[0:len(ft)//2]
ft = abs(np.fft.fft(tr.data)) ## Discrete Fast Fourtier Transform
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could potentially save 50% of the calculation time by using the scipy fft. https://stackoverflow.com/questions/6363154/what-is-the-difference-between-numpy-fft-and-scipy-fftpack

Copy link
Contributor

@mdenolle mdenolle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a few more changes but you have made lots of good progress!!

all_attr = np.empty((1,NATT), dtype = float)

attributes = ['Duration', 'RappMaxMean', 'RappMaxMedian', 'AsDec','KurtoSig', 'KurtoEnv', 'SkewSig',
attributes = ['Window_Length', 'RappMaxMean', 'RappMaxMedian', 'AsDec','KurtoSig', 'KurtoEnv', 'SkewSig',
'SkewEnv', 'CorPeakNumber', 'Energy1/3Cor', 'Energy2/3Cor', 'int_ratio','E_0.1_1','E_1_3',
'E_3_10', 'E_10_20','E_20_50','Kurt_0.1_1','Kurt_1_3','Kurt_3_10','Kurt_10_20','Kurt_20_50',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these have the hard coded frequency name, i forgot to notice that. it may feel less explanatory, but maybe using E_f1_f2, E_f2_f3, ... would work

starttime = tr.stats.starttime


tr.trim(starttime, starttime + 239.95)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you trim after removing the instrumental response?

@mdenolle mdenolle self-requested a review May 30, 2023 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants