Filtering .csv file

13 ビュー (過去 30 日間)
Sonali Sahansra
Sonali Sahansra 2020 年 2 月 18 日
編集済み: Anurag Ojha 2023 年 10 月 25 日
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 件のコメント
Vladimir Calderón
Vladimir Calderón 2021 年 9 月 13 日
In brief:
filter slow component (low pass)
and detect onsets of the phasic componentes (fast increase-slow decrease)

サインインしてコメントする。

回答 (1 件)

Anurag Ojha
Anurag Ojha 2023 年 10 月 25 日
編集済み: Anurag Ojha 2023 年 10 月 25 日
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:
I hope this helps to resolve your query.

Community Treasure Hunt

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

Start Hunting!

Translated by