0% found this document useful (0 votes)
58 views

Code

The document loads EEG data and performs discrete wavelet transforms and reconstructions on the data. It decomposes the signal into different frequency bands (levels 3-5) using the 'db4' wavelet. It then plots the Fourier transform of one frequency band (level 4) for different types of tasks to highlight the alpha frequency range.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

Code

The document loads EEG data and performs discrete wavelet transforms and reconstructions on the data. It decomposes the signal into different frequency bands (levels 3-5) using the 'db4' wavelet. It then plots the Fourier transform of one frequency band (level 4) for different types of tasks to highlight the alpha frequency range.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

%for baseline

load ankit.mat
s=data{26};
actual=s{4};
ls=length(actual(:,16));
[cA1,cD1]=dwt(actual(:,16),'db4');
% A1=upcoef('a',cA1,'db4',1,ls);
% D1=upcoef('d',cD1,'db4',1,ls);
A0=idwt(cA1,cD1,'db4',ls);
[C,L]=wavedec(actual(:,16),5,'db4');
% cA4= appcoef(C,L,'db4',4);
% cA3= appcoef(C,L,'db4',3);
% cA2= appcoef(C,L,'db4',2);
% cA1= appcoef(C,L,'db4',1);
% cD4= detcoef(C,L,4);
% cD3= detcoef(C,L,3);
% cD2= detcoef(C,L,2);
% cD1= detcoef(C,L,1);
% D5= wrcoef('d',C,L,'db4',5);
D4= wrcoef('d',C,L,'db4',4);
% D3= wrcoef('d',C,L,'db4',3);
% D2= wrcoef('d',C,L,'db4',2);
% D1= wrcoef('d',C,L,'db4',1);
%
A3= wrcoef('a',C,L,'db4',3);
% A4= wrcoef('d',C,L,'db4',4);
% A5= wrcoef('d',C,L,'db4',5);
% A0 = waverec(C,L,'db4');
% subplot(2,1,1);
% %hold on;
% plot(actual(:,10));
% title('Original Signal');
D4(isnan(D4))=0;
Fs=512;
L=length(D4);
NFFT = 2^nextpow2(L);
Y = fft(D4,L);
f = Fs/2*linspace(0,1,NFFT/2+1);
%subplot(2,1,2);
hold on;
plot(f,2*abs(Y(1:NFFT/2+1,1)));
axis([0 22 0 10000])
title('Plot highlighting the alpha-region of the wave');
xlabel('Frequency (Hz)');
ylabel('|Y(f)|');
%-------------------------------------------------------------------%for arithmatic simple
s=data{6};
actual=s{4};
ls=length(actual(:,16));
[cA1,cD1]=dwt(actual(:,16),'db4');
% A1=upcoef('a',cA1,'db4',1,ls);
% D1=upcoef('d',cD1,'db4',1,ls);
% A0=idwt(cA1,cD1,'db4',ls);
[C,L]=wavedec(actual(:,16),5,'db4');

%
%
%
%
%
%
%
%
%

cA4= appcoef(C,L,'db4',4);
cA3= appcoef(C,L,'db4',3);
cA2= appcoef(C,L,'db4',2);
cA1= appcoef(C,L,'db4',1);
cD4= detcoef(C,L,4);
cD3= detcoef(C,L,3);
cD2= detcoef(C,L,2);
cD1= detcoef(C,L,1);
D5= wrcoef('d',C,L,'db4',5);
D4= wrcoef('d',C,L,'db4',4);
% D3= wrcoef('d',C,L,'db4',3);
% D2= wrcoef('d',C,L,'db4',2);
% D1= wrcoef('d',C,L,'db4',1);
%
A3= wrcoef('a',C,L,'db4',3);
% A4= wrcoef('d',C,L,'db4',4);
% A5= wrcoef('d',C,L,'db4',5);
% A0 = waverec(C,L,'db4');
% hold on;
% plot(actual(:,10));
% title('Original Signal');
D4(isnan(D4))=0;
Fs=512;
L=length(D4);
NFFT = 2^nextpow2(L);
Y = fft(D4,L);
f = Fs/2*linspace(0,1,NFFT/2+1);
%subplot(2,1,2);
hold on;
plot(f,2*abs(Y(1:NFFT/2+1)),'color','red');
axis([0 22 0 10000])
title('Plot highlighting the alpha-region of the wave');
xlabel('Frequency (Hz)');
ylabel('|Y(f)|');
%----------------------------------------------------------------------%arithmatic complex
s=data{11};
actual=s{4};
ls=length(actual(:,16));
[cA1,cD1]=dwt(actual(:,16),'db4');
% A1=upcoef('a',cA1,'db4',1,ls);
% D1=upcoef('d',cD1,'db4',1,ls);
% A0=idwt(cA1,cD1,'db4',ls);
[C,L]=wavedec(actual(:,16),5,'db4');
% cA4= appcoef(C,L,'db4',4);
% cA3= appcoef(C,L,'db4',3);
% cA2= appcoef(C,L,'db4',2);
% cA1= appcoef(C,L,'db4',1);
% cD4= detcoef(C,L,4);
% cD3= detcoef(C,L,3);
% cD2= detcoef(C,L,2);
% cD1= detcoef(C,L,1);
% D5= wrcoef('d',C,L,'db4',5);
D4= wrcoef('d',C,L,'db4',4);
% D3= wrcoef('d',C,L,'db4',3);

% D2= wrcoef('d',C,L,'db4',2);
% D1= wrcoef('d',C,L,'db4',1);
%
A3= wrcoef('a',C,L,'db4',3);
% A4= wrcoef('d',C,L,'db4',4);
% A5= wrcoef('d',C,L,'db4',5);
% A0 = waverec(C,L,'db4');
% subplot(2,1,1);
%
plot(actual(:,i));
%
title('Original Signal');
D4(isnan(D4))=0;
Fs=512;
L=length(D4);
NFFT = 2^nextpow2(L);
Y = fft(D4,L);
f = Fs/2*linspace(0,1,NFFT/2+1);
hold on;
plot(f,2*abs(Y(1:NFFT/2+1)),'color','green');
axis([0 22 0 10000]);
title('Plot highlighting the alpha-region of the wave');
xlabel('Frequency (Hz)');
ylabel('|Y(f)|');
%-----------------------------------------------------------------------%movement
s=data{21};
actual=s{4};
ls=length(actual(:,16));
[cA1,cD1]=dwt(actual(:,16),'db4');
% A1=upcoef('a',cA1,'db4',1,ls);
% D1=upcoef('d',cD1,'db4',1,ls);
% A0=idwt(cA1,cD1,'db4',ls);
[C,L]=wavedec(actual(:,16),5,'db4');
% cA4= appcoef(C,L,'db4',4);
% cA3= appcoef(C,L,'db4',3);
% cA2= appcoef(C,L,'db4',2);
% cA1= appcoef(C,L,'db4',1);
% cD4= detcoef(C,L,4);
% cD3= detcoef(C,L,3);
% cD2= detcoef(C,L,2);
% cD1= detcoef(C,L,1);
% D5= wrcoef('d',C,L,'db4',5);
D4= wrcoef('d',C,L,'db4',4);
% D3= wrcoef('d',C,L,'db4',3);
% D2= wrcoef('d',C,L,'db4',2);
% D1= wrcoef('d',C,L,'db4',1);
%
A3= wrcoef('a',C,L,'db4',3);
% A4= wrcoef('d',C,L,'db4',4);
% A5= wrcoef('d',C,L,'db4',5);
% A0 = waverec(C,L,'db4');
% plot(actual(:,10));
% title('Original Signal');
D4(isnan(D4))=0;
Fs=512;
L=length(D4);
NFFT = 2^nextpow2(L);

Y = fft(D4,L);
f = Fs/2*linspace(0,1,NFFT/2+1);
hold on;
plot(f,2*abs(Y(1:NFFT/2+1)),'color','yellow');
axis([0 22 0 10000])
hold off;
title('Plot highlighting the alpha-region of the wave');
xlabel('Frequency (Hz)');
ylabel('|Y(f)|');
%----------------------------------------------------------------------%rotation
s=data{16};
actual=s{4};
ls=length(actual(:,16));
[cA1,cD1]=dwt(actual(:,16),'db4');
A1=upcoef('a',cA1,'db4',1,ls);
D1=upcoef('d',cD1,'db4',1,ls);
A0=idwt(cA1,cD1,'db4',ls);
[C,L]=wavedec(actual(:,16),5,'db4');
cA4= appcoef(C,L,'db4',4);
cA3= appcoef(C,L,'db4',3);
cA2= appcoef(C,L,'db4',2);
cA1= appcoef(C,L,'db4',1);
cD4= detcoef(C,L,4);
cD3= detcoef(C,L,3);
cD2= detcoef(C,L,2);
cD1= detcoef(C,L,1);
D5= wrcoef('d',C,L,'db4',5);
D4= wrcoef('d',C,L,'db4',4);
D3= wrcoef('d',C,L,'db4',3);
D2= wrcoef('d',C,L,'db4',2);
D1= wrcoef('d',C,L,'db4',1);
A3= wrcoef('a',C,L,'db4',3);
A4= wrcoef('d',C,L,'db4',4);
A5= wrcoef('d',C,L,'db4',5);
A0 = waverec(C,L,'db4');
% hold on;
% plot(actual(:,10));
% title('Original Signal');
D4(isnan(D4))=0;
Fs=512;
L=length(D4);
NFFT = 2^nextpow2(L);
Y = fft(D4,L);
f = Fs/2*linspace(0,1,NFFT/2+1);
hold on;
plot(f,2*abs(Y(1:NFFT/2+1)),'color','black');
axis([0 22 0 10000])
title('Plot highlighting the alpha-region of the wave');
xlabel('Frequency (Hz)');
ylabel('|Y(f)|');

You might also like