How to count the total number of blink?

조회 수: 2 (최근 30일)
nazmican
nazmican 2022년 12월 21일
편집: Bora Eryilmaz 2022년 12월 21일
Hi, I'm doing research on how count total number of blinks, is there any good resource for this task?
Thank You

채택된 답변

Bora Eryilmaz
Bora Eryilmaz 2022년 12월 21일
편집: Bora Eryilmaz 2022년 12월 21일
You can use a peak detection algorithm such as the islocalmax() command: https://www.mathworks.com/help/matlab/ref/islocalmax.html
x = randn(100,1);
plot(x)
hold on
level = 1.0;
yline(level, 'r')
% Only find peaks above the level.
I = (x < level);
x(I) = 0;
% Indices of all peaks above level.
J = islocalmax(x);
count = sum(J) % Number of peaks
count = 17
plot(find(J), x(J), 'ro')
% Indices of the peaks above level that are at least 5 x-units apart.
J = islocalmax(x, 'MinSeparation', 5);
count = sum(J) % Number of peaks
count = 11
plot(find(J), x(J), 'bx')
hold off
  댓글 수: 5
Bora Eryilmaz
Bora Eryilmaz 2022년 12월 21일
See updated code above.
nazmican
nazmican 2022년 12월 21일
Thank you

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2022년 12월 21일
Not sure what "detect" means to you. But if the red line is your threshold and signals above the threshold are a blink, then you can count them with bwlabel". If you want to know what indexes contains a blink signal, you can use regionprops.
signal = rand(1, 200); % Sample signal
plot(signal, 'b-');
grid on;
xlabel('Index');
ylabel('Signal');
threshold = 0.9;
yline(threshold, 'Color', 'r', 'LineWidth',2)
binarySignal = signal > threshold;
[~, numBlinks] = bwlabel(binarySignal);
% If you want indexes of the blink runs, then you can use regionprops
props = regionprops(binarySignal, 'PixelIdxList')
props = 12×1 struct array with fields:
PixelIdxList
% Print them out
for k = 1 : numel(props)
theseIndexes = props(k).PixelIdxList;
fprintf('For region #%d, it has indexes : ', k)
fprintf('%d ', theseIndexes)
fprintf('\n')
end
For region #1, it has indexes :
13
For region #2, it has indexes :
61
For region #3, it has indexes :
71
For region #4, it has indexes :
75
For region #5, it has indexes :
81
For region #6, it has indexes :
84 85
For region #7, it has indexes :
100
For region #8, it has indexes :
140 141
For region #9, it has indexes :
148 149
For region #10, it has indexes :
174
For region #11, it has indexes :
177
For region #12, it has indexes :
194
  댓글 수: 4
Bora Eryilmaz
Bora Eryilmaz 2022년 12월 21일
편집: Bora Eryilmaz 2022년 12월 21일
The code in this answer would require the Image Processing Toolbox.
Image Analyst
Image Analyst 2022년 12월 21일
Uh, that's not my code. You should contact the author for a fix.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by