Filtering .csv file
14 views (last 30 days)
Show older comments
Hello,
I am using Galvanic Skin Response (GSR) to measure the skin conductance whose reponse is displayed on Neulog. The samping rate is 20samples/second for the duration of 10 seconds. The data is saved in form of CSV file. I have displayed the signal using following code.
dataset = xlsread('rohit calm 1.csv', 'rohit calm 1', 'A8:B209');
y=dataset(:,2);
x= dataset(:,1);
plot(x,y)
xlabel ('X Time(seconds)')
ylabel('Y / GSR Amplitude(uS)')
grid on
Now I don't know how to apply filter to this as I am new to Matlab. I need to process the signal to eliminate artifacts from my signal. How can i apply filter to my .csv file? I would be delighted to any help.
1 Comment
Vladimir Calderón
on 13 Sep 2021
In brief:
filter slow component (low pass)
and detect onsets of the phasic componentes (fast increase-slow decrease)
Answers (1)
Anurag Ojha
on 25 Oct 2023
Edited: Anurag Ojha
on 25 Oct 2023
Hi Sonali ,
As per my understanding, you want to know how to apply filters in order to eliminate artifacts from your signal.
In order to eliminate disturbance, you can use the Butterworth Filter. It is used to define a low-pass filter, which is applied to remove high-frequency noise and retain the lower-frequency components of interest.
We need to use “butter” in combination with “filtfilt”, which is used to ensure that the filtering process does not introduce phase distortions into the data, which can be critical when working with physiological signals like GSR.
Here is a sample code to apply “Butterworth filter” to a signal :
% Load your dataset
dataset = xlsread('rohitcalm1.csv', 'rohit calm 1', 'A8:B209');
y = dataset(:, 2);
x = dataset(:, 1);
% Define filter parameters
order = 4; % Filter order (you can adjust this)
cutoff_freq = 2; % Cutoff frequency in Hz
% Design the low-pass Butterworth filter
[b, a] = butter(order, cutoff_freq / (20 / 2)); % 20 is the sampling rate
% Apply the filter to your GSR data
filtered_data = filtfilt(b, a, y);
% Plot the filtered data
plot(x, y, 'b', x, filtered_data, 'r');
xlabel('Time (seconds)');
ylabel('GSR Amplitude (uS)');
legend('Original', 'Filtered');
grid on;
Please refer to following MATLAB documentation to explore more:
- https://www.mathworks.com/help/signal/ref/butter.html
- https://www.mathworks.com/help/signal/ref/filtfilt.html
I hope this helps to resolve your query.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!