-2

So I am working with a dataset that I need to get the sampling frequency in each column this is the function I am using

def downsample_happysongs():
    n = 8 # number of channels  
    sample_freq = 128  # sample frequency used in dataset
    data1 = data[1]['sect3']
    for col in data1.T:
        resample = mne.filter.filter_data(col, sample_freq, 0, 45, verbose=False)
        print(resample)
    


x = downsample_happysongs()



when I call x this is what I get in the command window:

[-111.53109882 -111.59736915 -111.60413325 ...  -84.77988125  -84.68113443
  -84.55278019]
[230.5291432  230.43227696 230.24191778 ... 218.66069654 218.5746243
 218.92582851]
[149.62316188 148.62975455 147.69649625 ... 174.86999009 176.0134802
 176.86924547]
[177.41376749 176.89590573 176.57376289 ... 190.36114417 190.79033535
 191.16269878]
[389.38819789 387.82521721 383.90228579 ... 403.54903327 405.7398386
 409.00497842]
[59.11960524 59.19479442 59.41908772 ... 75.69543276 75.28374616
 74.97868426]
[558.44580036 555.27798436 553.22270828 ... 560.03316664 561.74143485
 562.49424666]
[1646.21346585 1642.88844551 1636.81714726 ... 1528.20584784 1531.18983756
 1537.56433726]

My original data is a 1500x8 matrix and I needed to get the sampling frequency of each column then take the 8 columns and recreate a resampled matrix. When I check variable explorer in Spyder 'x' shows up as a NoneType. Not sure if my brain melted from looking at this for too long but I cant figure out how to fix it. Also I transposed my data since its a 1500x8 matrix and I didn't know how to iterate over columns so this is how I'm working on my data and if anyone has a suggestion for that then I'll take that but I plan on transposing again.

Thanks in advance!

  • 1
    Your function does not return anything, so it implicitly returns `None`. And that is what you bind to name `x` – buran Nov 24 '21 at 07:12

1 Answers1

2

You need to store the data (resample) into a list first, and return that list

def downsample_happysongs():
    n = 8 # number of channels  
    sample_freq = 128  # sample frequency used in dataset
    data1 = data[1]['sect3']
    ALL_RESAMPLE = []
    for col in data1.T:
        resample = mne.filter.filter_data(col, sample_freq, 0, 45, verbose=False)
        ALL_RESAMPLE.append(resample)
        print(resample)
    return ALL_RESAMPLE
    


x = downsample_happysongs()
Kurt Rojas
  • 319
  • 2
  • 12