Identify 'Presses' From Continuous Data

1 view (last 30 days)
Hi everyone,
I'm using a force transducer to measure finger presses. This device gives me continuous data across 10 channels (one column for each finger) and I want to identify where any presses reach a threshold.
Currently, I index using my threshold and receive a logical matrix of 1s and 0s, where 1 is above threshold. How can I identify these as presses, where a channel may reach threshold once, descend to below threshold, and then exceed the threshold again, which would count as 2 presses? Currently participants are only required to make one press per finger, and I'd like to punish them on any trials where they make any additional presses.
Thanks in advance,
Rhys

Accepted Answer

Jon
Jon on 10 Feb 2020
Let's say you call your continuous data from one channel x (you can generalize this later to a matrix over the 10 channels).
Lets find all the points that are over the specified threshold and call these isPress
isPress = x>threshold
Now you want to find all the instances where it goes from not being pressed to being pressed. You can do this using diff
transition = diff(isPress) % will be 1 when goes to press level and -1 when it goes back to normal
You can count how many positive transitions, which is the number of times the key is pressed using
numPress = sum(transition==1)
I assume that when you say "I'd like to punish them on any trials where they make any additional presses". That this only means taking away points, or something like that. I certainly wouldn't want to help with any experiment that actually involved physical or any other form of actual "punishment"
  1 Comment
Rhys Yewbrey
Rhys Yewbrey on 11 Feb 2020
This is brilliant, thank you Jon. Working as intended.
You're correct, we're deducting points for excessive numbers of presses. Any other kind of punishment wouldn't make it past ethics I'm afraid!
Thanks again,
Rhys

Sign in to comment.

More Answers (0)

Categories

Find more on Wireless Communications 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!