SHARE
TWEET

Untitled

a guest Jan 22nd, 2020 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # As with most functions, you can pass arguments to a
  2. # gumpy function that will be forwarded to the backend.
  3. # In this example the decomposition levels are mandatory, and the
  4. # mother wavelet that should be passed is optional
  5. level = 6
  6. wavelet = 'db4'
  7.  
  8. # now we can retrieve the dwt for the different channels
  9. #data_class1 format: (c3, c4, cz, c3, c4, cz)
  10. mean_coeff_C3_c1 = gumpy.signal.dwt(data_class1[0], level=level, wavelet=wavelet) #c3 class 1 (left hand)
  11. mean_coeff_C4_c1 = gumpy.signal.dwt(data_class1[1], level=level, wavelet=wavelet) #c4 class 1 (left hand)
  12.  
  13. mean_coeff_C3_c2 = gumpy.signal.dwt(data_class1[3], level=level, wavelet=wavelet) #c3 class 2 (right hand)
  14. mean_coeff_C4_c2 = gumpy.signal.dwt(data_class1[4], level=level, wavelet=wavelet) #c4 class 2 (right hand)
  15.  
  16. # gumpy's signal.dwt function returns the approximation of the
  17. # coefficients as first result, and all the coefficient details as list
  18. # as second return value (this is contrast to the backend, which returns
  19. # the entire set of coefficients as a single list)
  20. approximation_C3_c1 = mean_coeff_C3_c1[0] # left hand
  21. approximation_C4_c1 = mean_coeff_C4_c1[0] # left hand
  22.  
  23. # as mentioned in the comment above, the list of details are in the second
  24. # return value of gumpy.signal.dwt. Here we save them to additional variables
  25. # to improve clarity
  26. details_C3_c1 = mean_coeff_C3_c1[1] #left hand
  27. details_C4_c1 = mean_coeff_C4_c1[1] #left hand
  28. #details_c3_c2 = mean_coeff_ch0_c2[1] #right hand
  29. #details_c4_c2 = mean_coeff_ch1_c2[1] #right hand
  30.  
  31. # gumpy exhibits a function to plot the dwt results. You must pass three lists,
  32. # i.e. the labels of the data, the approximations, as well as the detailed coeffs,
  33. # so that gumpy can automatically generate appropriate titles and labels.
  34. # you can pass an additional class string that will be incorporated into the title.
  35. # the function returns a matplotlib axis object in case you want to further
  36. # customize the plot.
  37. gumpy.plot.dwt(
  38.     [approximation_C3_c1, approximation_C4_c1],
  39.     [details_C3_c1, details_C4_c1],
  40.     ['C3, c1', 'C4, c1'],
  41.     level, grazb_data.sampling_freq, 'Class: Left')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top