getting a clear signal with eog

33 次查看(过去 30 天)
clear all
clc
% Load the data into a table
EOG = readtable('hamuortadanaşağı.txt');
% Plot the first column against the second column
figure;
subplot(211);
plot(EOG{:, 1});
subplot(212);
plot(EOG{:, 2});
for i=1:length(EOG)
if (EOG(i,1)<-0.01)
hor(i)=-1; %110;
elseif (EOG(i,1)>0.01)
hor(i)=1; %111;
elseif (EOG(i,1)>-0.01 && EOG(i,1)<0.01)
hor(i)=0; %000;
end
end
for i=1:length(EOG)
if (EOG(i,2)<-0.02)
ver(i)=-1; %010;
elseif (EOG(i,2)>0.02)
ver(i)=1; %011;
elseif (EOG(i,2)>-0.02 && EOG(i,2)<0.02)
ver(i)=0; %000;
end
end
figure, subplot(211);plot(EOG(:,1));
subplot(212);plot(hor);
figure, subplot(211);plot(EOG(:,2));
subplot(212);plot(ver);
HOW CAN I GET MORE CLEAN SIGNAL WITH THIS CODE
  3 个评论
William Rose
William Rose 2024-1-8
编辑:William Rose 2024-1-8
[edit: fix spelling error]
I see from reading your code that you create quantized versions of the horizontal and vertical extraoculogram signals. If the horizontal signal is less than -0.01, the quantized signal equals -1; if the raw signal is > +0.01, the quantized signal equals +1, and if the raw signal is in between, the quantized signal equals zero. You do the same thing with the vertical signal, except the thresholds are -0.02 and +0.02.
If the raw signal is smooth, and crosses the thresholds, then the quantized signal will have abrupt transitions. If the raw signal has a lot of noise, or non-eye-muscle contributions which exceed the thresholds, then the quantized signal may look "cleaner", or less noisy, than the original.
When you post the data file, please explain what you mean by "more clean" signal. Explain whether you are referring to cleaning the raw signal or the quantized signal. Specify if the horizontal or the vertical component is more in need of cleaning.
Ali Eren Çinar
Ali Eren Çinar 2024-1-8
I need more clean signal both horizantal and vertical

请先登录,再进行评论。

回答(2 个)

Star Strider
Star Strider 2024-1-8
One option I like for these sorts of signals is the Savitzky-Golay filter (sgolayfilt). I generally use a 3-degree polynomial, and then vary the frame length until I get the result I want. If you choose that approach, this should work as a prototype. I also devised an improved version of ‘hor’ and ‘ver’.
Try this —
clear all
clc
% Load the data into a table
EOG = readtable('hamuortadanaşağı.txt','VariableNamingRule','preserve');
VN = EOG.Properties.VariableNames;
L = size(EOG,1);
% Fs = 1E+3; % Supply Sampling Frequency
% t = linspace(0, L-1, L).'/Fs; % Time Vector
% Plot the first column against the second column
figure;
subplot(211);
plot(EOG{:, 1})
grid
subplot(212);
plot(EOG{:, 2})
grid
hor = sum([-(EOG{:,1} < -0.01) (EOG{:,1} > 0.01)], 2);
ver = sum([-(EOG{:,2} < -0.01) (EOG{:,2} > 0.01)], 2);
figure, subplot(211);plot(EOG{:,1})
grid
yline([-1 1]*0.01, ':k')
subplot(212);plot(hor)
grid
axis('padded')
figure, subplot(211);plot(EOG{:,2})
grid
yline([-1 1]*0.01, ':k')
subplot(212);plot(ver)
grid
axis('padded')
EOGf = mat2cell(sgolayfilt([EOG{:,1} EOG{:,2}], 3, 101), L, [1 1]); % Savitzky-Golay Filter
% Plot the first column against the second column
figure;
subplot(211);
plot(EOGf{:, 1})
grid
subplot(212);
plot(EOGf{:, 2})
grid
hor = sum([-(EOGf{:,1} < -0.01) (EOGf{:,1} > 0.01)], 2);
ver = sum([-(EOGf{:,2} < -0.01) (EOGf{:,2} > 0.01)], 2);
figure, subplot(211);plot(EOGf{:,1})
grid
yline([-1 1]*0.01, ':k')
subplot(212);plot(hor)
grid
axis('padded')
figure, subplot(211);plot(EOGf{:,2})
grid
yline([-1 1]*0.01, ':k')
subplot(212);plot(ver)
grid
axis('padded')
.
  2 个评论
Ali Eren Çinar
Ali Eren Çinar 2024-1-9
Thank you so much this is awesome but I want to get something too. So this is other recordings as well, I attached other EOG recordings in txt files. Now we are looking for code which doesn't cross each other when it goes to vertically and horizontally.And we want to arrange the origin to make it clear .In te first file which is 'hamuortadanaşağı.txt' We recorded the EOG signal according to this path. when the object comes in the screen center then it moves respectively
center to down
down to center
center to left
left to center,
center to up
up to center,
center to righ
right to center
Star Strider
Star Strider 2024-1-9
I do not understand what you want.
I plotted the filtered data from all the files here —
clear all
clc
files = dir('*.txt');
% Load the data into a table
for k = 1:numel(files)
filename = files(k).name;
EOG = readtable(filename,'VariableNamingRule','preserve');
VN = EOG.Properties.VariableNames;
L = size(EOG,1);
fprintf('\n\n\t\tFILENAME: %s, Length = %d\n', filename, L)
% Fs = 1E+3; % Supply Sampling Frequency
% t = linspace(0, L-1, L).'/Fs; % Time Vector
% % Plot the first column against the second column
% figure;
% subplot(211);
% plot(EOG{:, 1})
% grid
% subplot(212);
% plot(EOG{:, 2})
% grid
%
% figure
% plot(EOG{:,1}, EOG{:,2})
% grid
%
% hor = sum([-(EOG{:,1} < -0.01) (EOG{:,1} > 0.01)], 2);
% ver = sum([-(EOG{:,2} < -0.01) (EOG{:,2} > 0.01)], 2);
%
% figure, subplot(211);plot(EOG{:,1})
% grid
% yline([-1 1]*0.01, ':k')
% subplot(212);plot(hor)
% grid
% axis('padded')
%
% figure, subplot(211);plot(EOG{:,2})
% grid
% yline([-1 1]*0.01, ':k')
% subplot(212);plot(ver)
% grid
% axis('padded')
EOGf = array2table(sgolayfilt([EOG{:,1} EOG{:,2}], 3, 201)); % Savitzky-Golay Filter
EOGf.Properties.VariableNames = VN;
% % Plot the first column against the second column
% figure;
% subplot(211);
% plot(EOGf{:, 1})
% grid
% subplot(212);
% plot(EOGf{:, 2})
% grid
hor = sum([-(EOGf{:,1} < -0.01) (EOGf{:,1} > 0.01)], 2);
ver = sum([-(EOGf{:,2} < -0.01) (EOGf{:,2} > 0.01)], 2);
figure, subplot(211);plot(EOGf{:,1})
grid
yline([-1 1]*0.01, ':k')
subplot(212);plot(hor)
grid
axis('padded')
sgtitle('Horizontal')
figure, subplot(211);plot(EOGf{:,2})
grid
yline([-1 1]*0.01, ':k')
subplot(212);plot(ver)
grid
axis('padded')
sgtitle('Vertical')
figure
plot(EOGf{:,1}, EOGf{:,2})
grid
xlabel('Horizontal')
ylabel('Vertical')
title('Trajectory')
xline([-1 1]*0.01, ':k')
yline([-1 1]*0.01, ':k')
% Step = 50;
% TrajVectorH = EOGf{1:Step:end,1};
% TrajVectorV = EOGf{1:Step:end,2};
% dHor = gradient(TrajVectorH);
% dVer = gradient(TrajVectorV);
%
% figure
% quiver(TrajVectorH, TrajVectorV, dHor, dVer, 5)
% grid
% xlabel('Horizontal')
% ylabel('Vertical')
% title('Trajectory (‘quiver’)')
% xline([-1 1]*0.01, ':k')
% yline([-1 1]*0.01, ':k')
end
FILENAME: hamuortadanaşağı.txt, Length = 25053
FILENAME: hamuortadansağa.txt, Length = 28560
FILENAME: hamuortadansağa2.txt, Length = 28875
FILENAME: ortadanaşağı.txt, Length = 29008
FILENAME: ortadansağa.txt, Length = 26955
FILENAME: ortadansağagiden.txt, Length = 30095
FILENAME: sağdanbaşlayan.txt, Length = 25416
.

请先登录,再进行评论。


William Rose
William Rose 2024-1-9
That is a really nice answer and follow-up from @Star Strider.
For example, the lines
hor = sum([-(EOGf{:,1} < -0.01) (EOGf{:,1} > 0.01)], 2);
ver = sum([-(EOGf{:,2} < -0.01) (EOGf{:,2} > 0.01)], 2);
are ingenious.
I understand from your comment that each subject performed an eye-tracking task as indicated in the diagram below. The green and red dots represent the start and end of the task. Perhaps you expected that the EOG trajectory would resemble the diagram. None of the trajectories look like the diagram below. Are you seeking some kind of signal processing that would yield a trajectory similar to the diagram below?
Has the data which you posted already been subjected to high-pass filtering, in hardware or software? It looks like it has been. THis is not surprising, since it is common to include a high pass filter when recording electrical signals from the skin, such as EKG, EEG, EMG, and EOG. If so, what filtering was used (what cutoff frequency, etc.) The reason I am asking is that, if a high pass filter was used, with a time consant that is short compared to the task diration, then the signal will be brought back to the origin by the filter, even if the unfiltered EOG maintains a steady non-zero value. This would affect the EOG trajectory. If any software filtering was used, please post a file with raw vertical and horizontal EOGs (i.e., before filtering).
What was the sampling rate?
Did the subject track a target on a screen? If so, can you provide a plot of target position versus time that is syncronized with the EOG? Do the recordings include period at the start and end where the target is at the origin? If so, then you could take the mean EOG during those periods, and draw a straight line between those mean values, and subtract it off from the measured signal. This would yield a signal whose mean was zero during the initial and final periods.
Did the target move instaneously or gradually from the center to the periphery? This will determine whether you expect saccades or smooth pursuit (steps or ramps) in the EOG.

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by