preprocessing the digital signal with digital filtets

3 visualizzazioni (ultimi 30 giorni)
I have been given a Brain-computer-interface BCI dataset, namely AVI_SSVEP_Dataset.
The dataset has 7 different BCI target frequencies for each target on screen.
I need to preprocess digital signal with digital filters and classify each EEG epoch or each EEG trial. For this purpose I am asked to divide the data into two groups train and test data as 66% train and 33% test for each frequency. Afterwards I am required to create and train a machine learning model to predict the unseen test data correctly.
First you can extract 7 SNR at target frequencies as your features. SNR is measured as the signal at the frequency to the noise energy at the neighboring frequencies.
Training the model with these features you can obtain a machine learning model (using Matlab classification learner) for prediction of the test signals. Once you predict these signal labels, you can check predictions with actual true labels and compute accuracy of the model.
How can i perform this task can anyone help me

Risposte (1)

Balavignesh
Balavignesh il 28 Mag 2024
Hi Ali,
As per my understanding, you would like to train a machine learning model for classification following a series of steps such as preprocessing the EEG data, extracting features and dividing the dataset into training and test sets.
You could load the '.mat' files using the 'load' function and apply a digital filter to keep the EEG signals within the desired frequency band. In this case, I am using a bandpass filter between 0.1 Hz and 30 Hz.
data = load('Sub1_1_multitarget.mat');
fs = 256; % Example sampling frequency
[b, a] = butter(4, [0.1 30]/(fs/2), 'bandpass');
filteredSignal = filter(b, a, data.EEG);
To calculate the 'SNR' at 7 target frequencies for each 'EEG' epoch, you could use a method like Fast Fourier Transform (FFT) to get the power spectral density (PSD) and then calculate 'SNR' by comparing the power at the target frequency to the average power in the neighbouring frequencies. I am not sure about what target frequencies you are considering and how you are calculating the 'SNR'. So, I will leave it to you for those implementations.
targetFrequencies = [/* list of target frequencies */];
snrFeatures = zeros(size(data.EEG, 1), length(targetFrequencies)); % Initialize SNR features matrix
for i = 1:size(data.EEG, 1)
epoch = filteredSignal(i, :);
psd = abs(fft(epoch)).^2;
% Calculate SNR for each target frequency
for j = 1:length(targetFrequencies)
% Assuming you have a function `calculateSNR` that calculates SNR at a given frequency
snrFeatures(i, j) = calculateSNR(psd, targetFrequencies(j), fs);
end
end
You could use the 'cvpartition' function to divide the data set into 66% training and 33% test sets.
cv = cvpartition(size(snrFeatures, 1), 'HoldOut', 0.33);
idxTrain = cv.training;
idxTest = cv.test;
X_train = snrFeatures(idxTrain, :);
Y_train = data.labels(idxTrain);
X_test = snrFeatures(idxTest, :);
Y_test = data.labels(idxTest);
I am using a simple 'SVM' model for training. You could explore different models using MATLAB's Classification Learner App.
model = fitcsvm(X_train, Y_train); % Example using SVM
Y_pred = predict(model, X_test);
accuracy = sum(Y_pred == Y_test) / length(Y_test);
This should give you a brief picture. You can adjust the preprocessing, feature extraction, and model training steps according to the specific requirements of your dataset and project.
Kindly have a look at the following documentation links to have more information on:
Hope that helps!

Categorie

Scopri di più su EEG/MEG/ECoG in Help Center e File Exchange

Prodotti


Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by