-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtestStrength.m
More file actions
165 lines (102 loc) · 3.98 KB
/
testStrength.m
File metadata and controls
165 lines (102 loc) · 3.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
function strengthAll = testStrength()
clear all;
pathNames2013();
% pathNames2();
nbHands = input('1 or 2 hands: ');
%------------------------------ --------------------------------------------
%% GRAPHICS
% First blank screen
blankScreen = dotsDrawableText();
blankScreen.isVisible = true;
% Ready prompts: RH
readypromptRH = dotsDrawableText();
readypromptRH.string = 'With your dominant hand, squeeze the device as strong as possible';
readypromptRH.color = [40 40 40];
% Ready prompts: LH
readypromptLH = dotsDrawableText();
readypromptLH.string = 'With your non-dominant hand, squeeze the device as strong as possible';
readypromptLH.color = [40 40 40];
readypromptLH.fontSize = 42;
readypromptLH.typefaceName = 'Calibri';
readypromptLH.isVisible = true;
% Stop prompts
stopprompt = dotsDrawableText();
stopprompt.string = 'STOP';
stopprompt.color = [40 40 40];
stopprompt.fontSize = 42;
stopprompt.typefaceName = 'Calibri';
stopprompt.isVisible = true;
% get a drawing window
sc=dotsTheScreen.theObject;
sc.reset('displayIndex', 2);
%dotsTheScreen.reset();
dotsTheScreen.openWindow();
% Display firt screen
dotsDrawable.drawFrame({blankScreen});
%--------------------------------------------------------------------------
%% DYNAMOMETER
if nbHands ==2
strengthAll = zeros(2,2);
else
strengthAll = zeros(1,2);
end
for h= 1: nbHands
% 1 - Open dynamometer
% create dynamometer object
d(h) = dynamometer(h);
% start recording
d(h).start;
tic
pause(3);
% TWO GRIP TESTS PER HAND
for i = 1:2
% 2 - Look for pressure
% SWITCH THE SCREEN: Instructions
switch h
case 1
dotsDrawable.drawFrame({readypromptRH});
case 2
dotsDrawable.drawFrame({readypromptLH});
end
% DETECT PRESSURE
valthreshold = 10;
strength = 0;
while strength <valthreshold
pause(0.05)
strength = d(h).read;
end
%% Change to blank screen
% 3 - Collect data from dynamometer for 1 second
% SWITCH THE SCREEN
dotsDrawable.drawFrame({blankScreen});
% READ FOR 1 SECOND
% trial duration
T = 5; % arbitrary long time in s
dt = 0.03 ; % display refresh lag
% time loop
timeStart =toc;
f = zeros(50,1);
for j=1:round(T/dt)
pause(dt);
timeNow = toc - timeStart;
% update internal buffer and return last value
f(j) = d(h).read;
% make sure it doesn't go beyond 1 second
if timeNow>1;
break
end
end
% stop recording and get the buffer
strengthAll(h,i) = max(f);
% SWITCH THE SCREEN: STOP
dotsDrawable.drawFrame({stopprompt});
pause(2);
end
if nbHands == 1 && h==1 || nbHands == 2 && h==2
clear d
% close the OpenGL drawing window
dotsTheScreen.closeWindow();
end
end
save('strengthAll.mat','strengthAll');
end