-2

所以我正在使用一个数据集,我需要在每一列中获取采样频率这是我正在使用的函数

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()



当我调用 x 这是我在命令窗口中得到的:

[-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]

我的原始数据是一个 1500x8 矩阵,我需要获取每列的采样频率,然后取 8 列并重新创建一个重新采样的矩阵。当我在 Spyder 中检查变量资源管理器时,'x' 显示为 NoneType。不知道我的大脑是否因为看这个太久而融化了,但我不知道如何解决它。另外我转置了我的数据,因为它是一个 1500x8 矩阵,我不知道如何迭代列,所以这就是我处理数据的方式,如果有人对此有建议,那么我会接受,但我计划再次转置。

提前致谢!

4

1 回答 1

2

您需要先将数据(重新采样)存储到列表中,然后返回该列表

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()
于 2021-11-24T07:13:30.457 回答