Hi Vaggelis,
To extract specific frequency bands like the mu and beta bands from the EEG signals, you can decompose the given EEG signal into its constituent frequency bands using wavelet analysis. By visualizing each band separately, analysis of the frequency bands can be performed. To do the same, the ‘wavedec’ function in MATLAB can be used to perform wavelet decomposition and ‘wrcoef’ can be further performed to reconstruct corresponding frequency band signals representing the various frequency bands like Alpha, beta, gamma, etc. A sample MATLAB code for the same is as follows:
% Sample EEG data
fs = 256;
eegData = randn(1, fs*10); % Example EEG data
% plot the EEG signal
figure;
subplot(6,1,1);
p=plot(eegData);
title('EEG Signal')
% wavelet decomposition
waveletFunction = 'db8';
[C,L] = wavedec(eegData,8,waveletFunction);
% extracting the details and approximation coefficients
cD1 = detcoef(C,L,1);
cD2 = detcoef(C,L,2);
cD3 = detcoef(C,L,3);
cD4 = detcoef(C,L,4);
cD5 = detcoef(C,L,5); %GAMMA
cD6 = detcoef(C,L,6); %BETA
cD7 = detcoef(C,L,7); %ALPHA
cD8 = detcoef(C,L,8); %THETA
cA8 = appcoef(C,L,waveletFunction,8); %DELTA
% Reconstructing the Signal components
D1 = wrcoef('d',C,L,waveletFunction,1);
D2 = wrcoef('d',C,L,waveletFunction,2);
D3 = wrcoef('d',C,L,waveletFunction,3);
D4 = wrcoef('d',C,L,waveletFunction,4);
D5 = wrcoef('d',C,L,waveletFunction,5); %GAMMA
D6 = wrcoef('d',C,L,waveletFunction,6); %BETA
D7 = wrcoef('d',C,L,waveletFunction,7); %ALPHA
D8 = wrcoef('d',C,L,waveletFunction,8); %THETA
A8 = wrcoef('a',C,L,waveletFunction,8); %DELTA
% plotting the frequency bands
Gamma = D5;
subplot(6,1,2);
plot(1:1:length(Gamma),Gamma);title('GAMMA');
Beta = D6;
subplot(6,1,3);
plot(1:1:length(Beta), Beta); title('BETA');
Alpha = D7;
subplot(6,1,4);
plot(1:1:length(Alpha),Alpha); title('ALPHA');
Theta = D8;
subplot(6,1,5);
plot(1:1:length(Theta),Theta);title('THETA');
D8 = detrend(D8,0);
Delta = A8;
subplot(6,1,6);
plot(1:1:length(Delta),Delta);title('DELTA');
The visualization of the above code is the EEG signal decomposed into corresponding frequency bands is as follows:

For more information regarding the functions, refer the following documentations:
- Extract frequency bands of an EEG signal and performing analysis: https://www.mathworks.com/matlabcentral/answers/127932-how-to-extract-frequency-sub-bands-of-an-eeg-signal-using-wavelet-packet-transform
- Wavedec: https://www.mathworks.com/help/wavelet/ref/wavedec.html
- Detcoef: https://www.mathworks.com/help/wavelet/ref/detcoef.html
- Appcoef: https://www.mathworks.com/help/wavelet/ref/appcoef.html
- Wrcoef: https://www.mathworks.com/help/wavelet/ref/wrcoef.html
Hope this helps!
