下載/瀏覽Download
Download
Report
Transcript 下載/瀏覽Download
鼾音訊號測量計畫
執導老師:侯春茹 老師
組員:金雍庭
胡庭恩
林承葦
賴彥亨
目錄
• 訊號的簡介
▫ 臨床應用
▫ 量測部位與方法
▫ 訊號特徵
• 訊號處理流程
• 鼾聲量得訊號
訊號處理流程
• 第一部分作業為訊號加窗
鼾聲測量訊號
軟顎部位的鼾聲頻率大多分布在 150 Hz~300 Hz 之間,
舌根部位之頻率大多分布在 500 Hz~750 Hz
原始訊號
原始訊號取小段
窗型函數
Hamming
Rectangular
Hanning
Blackman
Triangular
n1=length(signal_1);
window1=hamming(n1)'; % Hamming window
addwindow1=(signal_1).*window1; % 原始訊號乘上 Hamming window
u1=fft(addwindow1,L);
u1_2=u(1:(length(u1)/2))
u_mag1=abs(u1_2);
u_ang1=angle(u1_2);
figure(4)
subplot(2,2,1)
plot(window1); % Hamming window的頻譜圖
title('Hamming window')
axis tight
subplot(2,2,2)
plot(addwindow1);
title('原始訊號乘上 Hamming window')
axis tight
subplot(2,2,3)
plot(fy_2,u_mag1)
title('強度頻譜')
subplot(2,2,4)
plot(fy_2,u_ang1)
title('相位頻譜')
print('-f4', '-djpeg', '-r300', 'fig4');
window2=rectwin(n1); % Rectangular window
addwindow2=(signal_1).*rectwin(n1)'; % 原始訊號乘上 Rectangular window
u2=fft(addwindow2,L);
u2_2=u(1:(length(u2)/2))
u_mag2=abs(u2_2);
u_ang2=angle(u2_2);
figure(5)
subplot(2,2,1)
plot(window2); % Rectangular window的頻譜圖
title('Rectangular window')
axis tight
subplot(2,2,2)
plot(addwindow2);
title('原始訊號乘上 Rectangular window')
axis tight
subplot(2,2,3)
plot(fy_2,u_mag2)
title('強度頻譜')
subplot(2,2,4)
plot(fy_2,u_ang2)
title('相位頻譜')
print('-f5', '-djpeg', '-r300', 'fig5');
window3=hanning(n1); % Hann window
addwindow3=(signal_1).*hanning(n1)'; % 原始訊號乘上 Hanning window
u3=fft(addwindow3,L);
u3_2=u(1:(length(u3)/2))
u_mag3=abs(u3_2);
u_ang3=angle(u3_2);
figure(6)
subplot(2,2,1)
plot(window3); % Hanning window的頻譜圖
title('Hanning window')
axis tight
subplot(2,2,2)
plot(addwindow3);
title('原始訊號乘上 Hanning window')
axis tight
subplot(2,2,3)
plot(fy_2,u_mag3)
title('強度頻譜')
subplot(2,2,4)
plot(fy_2,u_ang3)
title('相位頻譜')
print('-f6', '-djpeg', '-r300', 'fig6');
window4=blackmanharris(n1); % Blackman window
addwindow4=(signal_1).*blackmanharris(n1)'; % 原始訊號乘上 Blackman window
u4=fft(addwindow4,L);
u4_2=u(1:(length(u4)/2))
u_mag4=abs(u4_2);
u_ang4=angle(u4_2);
figure(7)
subplot(2,2,1)
plot(window4); % Blackman window的頻譜圖
title('Blackman window')
axis tight
subplot(2,2,2)
plot(addwindow4);
title('原始訊號乘上 Blackman window')
axis tight
subplot(2,2,3)
plot(fy_2,u_mag4)
title('強度頻譜')
subplot(2,2,4)
plot(fy_2,u_ang4)
title('相位頻譜')
print('-f7', '-djpeg', '-r300', 'fig7');
window5=triang(n1); % Triangular window
addwindow5=(signal_1).*triang(n1)'; % 原始訊號乘上 Triangular window
u5=fft(addwindow5,L);
u5_2=u(1:(length(u5)/2))
u_mag5=abs(u5_2);
u_ang5=angle(u5_2);
figure(8)
subplot(2,2,1)
plot(window5); % Triangular window的頻譜圖
title('Triangular window')
axis tight
subplot(2,2,2)
plot(addwindow5);
title('原始訊號乘上 Triangular window')
axis tight
subplot(2,2,3)
plot(fy_2,u_mag5)
title('強度頻譜')
subplot(2,2,4)
plot(fy_2,u_ang5)
title('相位頻譜')
print('-f8', '-djpeg', '-r300', 'fig8');
• 第二部分用各種濾波器對訊號做濾波
備註:各濾波器的階數皆已調到最理想的狀態,但有些濾波的結果仍不甚明顯
濾波結果
Butter worth低通濾波前後
Butter worth高通濾波前後
Butterworth帶拒濾波
%% 原始訊號讀取
clc
clear all
close all
[FILENAME,PATHNAME] =
uigetfile ('*.wav');
if FILENAME
fullname = [PATHNAME,FILENAME];
[SignalData,fs] = wavread(fullname);
end
%%
signal_1=detrend(SignalData);
SignalData_detrend=
signal_1(8735000:8815000);
T=1/fs;
N=length(SignalData_detrend);
u=fft(signal_1);
NR=fs/2;%低通
[n,Wn]=buttord(1000/NR,1800/NR,1,60);
[b0,a0]=butter(n,Wn,'low');
y=filter(b0,a0,SignalData_detrend);
figure(6)
plot(y)
[n,Wn]=buttord(10/NR,0.5/NR,1,60);
%高通
[b1,a1]=butter(n,Wn,'high');
y=filter(b1,a1,SignalData_detrend);
[b2,a2]=butter(2,[57 63]./NR,'stop');
%帶拒
y=filter(b2,a2,SignalData_detrend);
[h_low,f_low]=freqz(b0,a0,512,
fs);
[h_high,f_high]=freqz(b1,a1,25
6,fs);
[h_stop,f_stop]=freqz(b2,a2,512
,fs);
figure(1)
subplot(431)
plot(f_low,abs(h_low))
xlabel('Frequence(Hz)')
ylabel('H(w)')
title('butterworth Lowpass')
subplot(432)
plot(f_high,abs(h_high))
xlabel('Frequence(Hz)')
ylabel('H(w)')
title('butterworth Highpass')
subplot(433)
plot(f_stop,abs(h_stop))
xlabel('Frequence(Hz)')
ylabel('H(w)')
title('butterworth Stoppass')
ell濾波器
[n_low_ell,Wn_low_ell]=ellipord(1000/NR,1800/NR,1,6
0);
[b_low_ell,a_low_ell]=ellip(n_low_ell,1,60,Wn_low_ell,'l
ow');
SignalData_IIR_low_ell=filter(b_low_ell,a_low_ell,Signa
lData_detrend);
[n_high_ell,Wn_high_ell]=ellipord(10/NR,0.5/NR,1,60);
[b_high_ell,a_high_ell]=ellip(n_high_ell,1,60,Wn_high_
ell,'high');
SignalData_IIR_high_ell=filter(b_high_ell,a_high_ell,Si
gnalData_detrend);
[b_stop_ell,a_stop_ell]=ellip(3,1,60,[57 63]./NR,'stop');
SignalData_IIR_stop_ell=filter(b_stop_ell,a_stop_ell,Sig
nalData_detrend);
[h_low_ell,f_low_ell]=freqz(b_low_ell,a_low_ell,256,fs);
[h_high_ell,f_high_ell]=freqz(b_high_ell,a_high_ell,256,
fs);
[h_stop_ell,f_stop_ell]=freqz(b_stop_ell,a_stop_ell,256,f
s);
figure(1)
subplot(434)
plot(f_low_ell,abs(h_low_ell))
xlabel('Frequence(Hz)')
ylabel('H(w)')
title('Elliptic Lowpass')
subplot(435)
plot(f_high_ell,abs(h_high_ell))
xlabel('Frequence(Hz)')
ylabel('H(w)')
title('Elliptic Highpass')
subplot(436)
plot(f_stop_ell,abs(h_stop_ell))
xlabel('Frequence(Hz)')
ylabel('H(w)')
title('Elliptic Stoppass')
ChebyshevI濾波器
[n_low_cheI,Wn_low_cheI]=cheb1ord(10
00/NR,1800/NR,1,60);
[b_low_cheI,a_low_cheI]=cheby1(n_low
_cheI,1,Wn_low_cheI,'low');
SignalData_IIR_low_cheI=filter(b_low_c
heI,a_low_cheI,SignalData_detrend);
[n_high_cheI,Wn_high_cheI]=cheb1ord(
10/NR,0.5/NR,1,60);
[b_high_cheI,a_high_cheI]=cheby1(n_hi
gh_cheI,1,Wn_high_cheI,'high');
SignalData_IIR_high_cheI=filter(b_high
_cheI,a_high_cheI,SignalData_detrend);
figure(123)
freqz(b_high_cheI,a_high_cheI,256,fs);
[fy,sfft]=fft_me(SignalData_IIR_high_ch
eI,fs)
figure(124)
plot(fy,abs(sfft))
[b_stop_cheI,a_stop_cheI]=cheby1(3,1,[57 63]./NR,'stop');
SignalData_IIR_stop_cheI=filter(b_stop_cheI,a_stop_cheI,Sig
nalData_detrend);
[h_low_cheI,f_low_cheI]=freqz(b_low_cheI,a_low_cheI,256,f
s);
[h_high_cheI,f_high_cheI]=freqz(b_high_cheI,a_high_cheI,2
56,fs);
[h_stop_cheI,f_stop_cheI]=freqz(b_stop_cheI,a_stop_cheI,25
6,fs);
figure(1)
subplot(437)
plot(f_low_cheI,abs(h_low_cheI))
xlabel('Frequence(Hz)')
ylabel('H(w)')
title('ChebyshevI Lowpass')
subplot(438)
plot(f_high_cheI,abs(h_high_cheI))
xlabel('Frequence(Hz)')
ylabel('H(w)')
title('ChebyshevI Highpass')
subplot(439)
plot(f_stop_cheI,abs(h_stop_cheI))
xlabel('Frequence(Hz)')
ylabel('H(w)')
title('ChebyshevI Stoppass')
ChebyshevII濾波器
[n_low_cheII,Wn_low_cheII]=cheb2ord(1000/NR,1800/NR,1,60);
[b_low_cheII,a_low_cheII]=cheby2(n_low_cheII,60,Wn_low_cheII,'low');
SignalData_IIR_low_cheII=filter(b_low_cheII,a_low_cheII,SignalData_detrend);
[n_high_cheII,Wn_high_cheII]=cheb2ord(10/NR,0.5/NR,1,60);
[b_high_cheII,a_high_cheII]=cheby2(n_high_cheII,60,Wn_high_cheII,'high');
SignalData_IIR_high_cheII=filter(b_high_cheII,a_high_cheII,SignalData_IIR_low_cheII);
[b_stop_cheII,a_stop_cheII]=cheby2(3,60,[57 63]./NR,'stop');
SignalData_IIR_stop_cheII=filter(b_stop_cheII,a_stop_cheII,SignalData_IIR_high_cheII);
[h_low_cheII,f_low_cheII]=freqz(b_low_cheII,a_low_cheII,256,fs);
[h_high_cheII,f_high_cheII]=freqz(b_high_cheII,a_high_cheII,256,fs);
[h_stop_cheII,f_stop_cheII]=freqz(b_stop_cheII,a_stop_cheII,256,fs);
figure(1)
subplot(4,3,10)
plot(f_low_cheII,abs(h_low_cheII))
xlabel('Frequence(Hz)')
ylabel('H(w)')
title('ChebyshevII Lowpass')
subplot(4,3,11)
plot(f_high_cheII,abs(h_high_cheII))
xlabel('Frequence(Hz)')
ylabel('H(w)')
title('ChebyshevII Highpass')
subplot(4,3,12)
plot(f_stop_cheII,abs(h_stop_cheII))
xlabel('Frequence(Hz)')
ylabel('H(w)')
title('ChebyshevII Stoppass')
加窗與傅立葉轉換
n1=length(y);
window1=hamming(n1)'; % Hamming window
addwindow1=(y).*window1; % 原始訊號乘上 Hamming
window
%
u=fft(addwindow1);
fd=1/(N*T); % 頻率間隔
m=0:(N-1); % 頻率點數
fy=m.*fd;
fy_2=fy(1:(length(fy)/2));
u_2=u(1:(length(u)/2));
k=fs*(0:length(u)-1)/length(u);
u_mag=abs(u_2);
u_ang=angle(u_2);
figure(4)
plot(fy_2,u_mag)
title(‘butterworth強度頻譜')