How to count the total number of blink?
Show older comments
Hi, I'm doing research on how count total number of blinks, is there any good resource for this task?
Thank You

Accepted Answer
More Answers (1)
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')
% 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
4 Comments
nazmican
on 21 Dec 2022
Bora Eryilmaz
on 21 Dec 2022
Edited: Bora Eryilmaz
on 21 Dec 2022
The code in this answer would require the Image Processing Toolbox.
Image Analyst
on 21 Dec 2022
Uh, that's not my code. You should contact the author for a fix.
Categories
Find more on Subspace Methods in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
