This presentation is the property of its rightful owner.
1 / 26

# 鼾音訊號測量計畫 PowerPoint PPT Presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

## 鼾音訊號測量計畫

• 訊號的簡介

• 臨床應用

• 量測部位與方法

• 訊號特徵

• 訊號處理流程

• 鼾聲量得訊號

10Hz

TL082

60Hz

1kHz

MSP430F5438A

• 第一部分作業為訊號加窗

### Triangular

n1=length(signal_1);

window1=hamming(n1)'; % Hamming window

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)

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

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)

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

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)

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

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)

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

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)

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');

• 第二部分用各種濾波器對訊號做濾波

備註:各濾波器的階數皆已調到最理想的狀態，但有些濾波的結果仍不甚明顯

### Butterworth帶拒濾波

[h_low,f_low]=freqz(b0,a0,512,fs);

[h_high,f_high]=freqz(b1,a1,256,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('butterworthLowpass')

subplot(432)

plot(f_high,abs(h_high))

xlabel('Frequence(Hz)')

ylabel('H(w)')

title('butterworthHighpass')

subplot(433)

plot(f_stop,abs(h_stop))

xlabel('Frequence(Hz)')

ylabel('H(w)')

title('butterworthStoppass')

%% 原始訊號讀取

clc

clear all

close all

[FILENAME,PATHNAME] =

uigetfile ('*.wav');

if FILENAME

fullname = [PATHNAME,FILENAME];

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

ell濾波器

[n_low_ell,Wn_low_ell]=ellipord(1000/NR,1800/NR,1,60);

[b_low_ell,a_low_ell]=ellip(n_low_ell,1,60,Wn_low_ell,'low');

SignalData_IIR_low_ell=filter(b_low_ell,a_low_ell,SignalData_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,SignalData_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,SignalData_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,fs);

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

[n_low_cheI,Wn_low_cheI]=cheb1ord(1000/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_cheI,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_high_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_cheI,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,SignalData_detrend);

[h_low_cheI,f_low_cheI]=freqz(b_low_cheI,a_low_cheI,256,fs);

[h_high_cheI,f_high_cheI]=freqz(b_high_cheI,a_high_cheI,256,fs);

[h_stop_cheI,f_stop_cheI]=freqz(b_stop_cheI,a_stop_cheI,256,fs);

figure(1)

subplot(437)

plot(f_low_cheI,abs(h_low_cheI))

xlabel('Frequence(Hz)')

ylabel('H(w)')

title('ChebyshevILowpass')

subplot(438)

plot(f_high_cheI,abs(h_high_cheI))

xlabel('Frequence(Hz)')

ylabel('H(w)')

title('ChebyshevIHighpass')

subplot(439)

plot(f_stop_cheI,abs(h_stop_cheI))

xlabel('Frequence(Hz)')

ylabel('H(w)')

title('ChebyshevIStoppass')

### ChebyshevI濾波器

[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('ChebyshevIILowpass')

subplot(4,3,11)

plot(f_high_cheII,abs(h_high_cheII))

xlabel('Frequence(Hz)')

ylabel('H(w)')

title('ChebyshevIIHighpass')

subplot(4,3,12)

plot(f_stop_cheII,abs(h_stop_cheII))

xlabel('Frequence(Hz)')

ylabel('H(w)')

title('ChebyshevIIStoppass')

### 加窗與傅立葉轉換

n1=length(y);

window1=hamming(n1)'; % Hamming window

%

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強度頻譜')