我想在带有 Raspbian 的 Raspberry pi 3 上使用 Octave 库在 Python 中对 .wav 文件信号进行峰值检测,但 octave.findpeaks 函数存在问题。我遇到了这个错误:findpeaks:参数“MeanPeakHeight”与解析器的任何有效参数都不匹配 我已经安装了所有关于 Octave 的包,所以这就是我不明白的原因。这是我的程序的一部分:
import matplotlib.pyplot as plt
import numpy as np
from scipy.io import wavfile as wav
from scipy.signal import find_peaks_cwt, butter, lfilter
from pylab import *
import os
from operator import truediv
from easygui import *
from oct2py import octave
"High and Low Frequency for the filter"
low = 100
high = 50
list_file = []
octave.eval("pkg load signal")
def display_wav(wav_file):
samplerate, beat = wav.read('/home/pi/heartbeat_project/heartbeat_songs/%s' %wav_file)
beat_resize = np.fromfile(open('/home/pi/heartbeat_project/heartbeat_songs/%s' %wav_file),np.int16)[4*samplerate:float(beat.shape[0])-4*samplerate]
beat_resize = beat_resize / (2.**15)
timeArray = arange(0,float(beat_resize.shape[0]),1)
timeArray = timeArray / samplerate
ylow = butter_lowpass_filter(samplerate, 5, low, beat_resize)
y = butter_highpass_filter(samplerate, 5, high, ylow)
peaks, indexes = octave.findpeaks(np.array(y),'DoubleSided','MeanPeakHeight',np.std(y))