@decidables/detectable-elements 0.2.16 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/README.md +150 -14
- package/lib/detectableElements.esm.js +4245 -3504
- package/lib/detectableElements.esm.js.map +1 -1
- package/lib/detectableElements.esm.min.js +833 -530
- package/lib/detectableElements.esm.min.js.map +1 -1
- package/lib/detectableElements.umd.js +4233 -3491
- package/lib/detectableElements.umd.js.map +1 -1
- package/lib/detectableElements.umd.min.js +833 -530
- package/lib/detectableElements.umd.min.js.map +1 -1
- package/package.json +4 -4
- package/src/components/detectable-control.js +8 -6
- package/src/components/detectable-response.js +24 -0
- package/src/components/index.js +4 -3
- package/src/components/roc-space.js +15 -11
- package/src/components/sdt-model.js +101 -98
- package/src/components/sdt-parameters.js +163 -0
- package/src/equations/dc2far.js +28 -7
- package/src/equations/dc2hr.js +29 -7
- package/src/equations/facr2far.js +19 -3
- package/src/equations/hfa2ppv.js +19 -3
- package/src/equations/hm2hr.js +19 -3
- package/src/equations/hmfacr2acc.js +31 -5
- package/src/equations/hrfar2c.js +29 -5
- package/src/equations/hrfar2d.js +29 -5
- package/src/equations/mcr2fomr.js +19 -3
- package/src/examples/double-interactive.js +1 -1
- package/src/examples/human.js +221 -89
- package/src/examples/interactive.js +226 -88
- package/src/examples/model.js +222 -97
- package/src/examples/multiple.js +1 -1
package/src/examples/human.js
CHANGED
|
@@ -4,21 +4,126 @@ import SDTMath from '@decidables/detectable-math';
|
|
|
4
4
|
import SDTExample from './sdt-example';
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
|
-
|
|
7
|
+
SDTExampleHuman element
|
|
8
8
|
<sdt-example-human>
|
|
9
9
|
*/
|
|
10
10
|
export default class SDTExampleHuman extends SDTExample {
|
|
11
|
+
static get properties() {
|
|
12
|
+
return {
|
|
13
|
+
trials: {
|
|
14
|
+
attribute: 'trials',
|
|
15
|
+
type: Number,
|
|
16
|
+
reflect: true,
|
|
17
|
+
},
|
|
18
|
+
duration: {
|
|
19
|
+
attribute: 'duration',
|
|
20
|
+
type: Number,
|
|
21
|
+
reflect: true,
|
|
22
|
+
},
|
|
23
|
+
coherence: {
|
|
24
|
+
attribute: 'coherence',
|
|
25
|
+
type: Number,
|
|
26
|
+
reflect: true,
|
|
27
|
+
},
|
|
28
|
+
payoff: {
|
|
29
|
+
attribute: 'payoff',
|
|
30
|
+
type: Number,
|
|
31
|
+
reflect: true,
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
h: {
|
|
35
|
+
attribute: false,
|
|
36
|
+
type: Number,
|
|
37
|
+
reflect: false,
|
|
38
|
+
},
|
|
39
|
+
m: {
|
|
40
|
+
attribute: false,
|
|
41
|
+
type: Number,
|
|
42
|
+
reflect: false,
|
|
43
|
+
},
|
|
44
|
+
fa: {
|
|
45
|
+
attribute: false,
|
|
46
|
+
type: Number,
|
|
47
|
+
reflect: false,
|
|
48
|
+
},
|
|
49
|
+
cr: {
|
|
50
|
+
attribute: false,
|
|
51
|
+
type: Number,
|
|
52
|
+
reflect: false,
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
hr: {
|
|
56
|
+
attribute: false,
|
|
57
|
+
type: Number,
|
|
58
|
+
reflect: false,
|
|
59
|
+
},
|
|
60
|
+
far: {
|
|
61
|
+
attribute: false,
|
|
62
|
+
type: Number,
|
|
63
|
+
reflect: false,
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
d: {
|
|
67
|
+
attribute: false,
|
|
68
|
+
type: Number,
|
|
69
|
+
reflect: false,
|
|
70
|
+
},
|
|
71
|
+
c: {
|
|
72
|
+
attribute: false,
|
|
73
|
+
type: Number,
|
|
74
|
+
reflect: false,
|
|
75
|
+
},
|
|
76
|
+
s: {
|
|
77
|
+
attribute: false,
|
|
78
|
+
type: Number,
|
|
79
|
+
reflect: false,
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
constructor() {
|
|
85
|
+
super();
|
|
86
|
+
|
|
87
|
+
this.trials = 10;
|
|
88
|
+
this.duration = 2000;
|
|
89
|
+
this.coherence = 0.5;
|
|
90
|
+
this.payoff = 0;
|
|
91
|
+
|
|
92
|
+
this.h = 0;
|
|
93
|
+
this.m = 0;
|
|
94
|
+
this.fa = 0;
|
|
95
|
+
this.cr = 0;
|
|
96
|
+
|
|
97
|
+
this.hr = 0.5;
|
|
98
|
+
this.far = 0.5;
|
|
99
|
+
|
|
100
|
+
this.d = 0;
|
|
101
|
+
this.c = 0;
|
|
102
|
+
this.s = SDTMath.s.DEFAULT;
|
|
103
|
+
|
|
104
|
+
this.count = 0;
|
|
105
|
+
|
|
106
|
+
this.detectableControl = null;
|
|
107
|
+
this.detectableResponse = null;
|
|
108
|
+
this.detectableTable = null;
|
|
109
|
+
this.rdkTask = null;
|
|
110
|
+
this.rocSpace = null;
|
|
111
|
+
this.sdtModel = null;
|
|
112
|
+
this.sdtParameters = null;
|
|
113
|
+
}
|
|
114
|
+
|
|
11
115
|
connectedCallback() {
|
|
12
116
|
super.connectedCallback();
|
|
13
117
|
|
|
14
118
|
this.count = 1;
|
|
15
119
|
|
|
16
120
|
this.detectableControl = this.querySelector('detectable-control');
|
|
17
|
-
this.rdkTask = this.querySelector('rdk-task');
|
|
18
121
|
this.detectableResponse = this.querySelector('detectable-response');
|
|
19
122
|
this.detectableTable = this.querySelector('detectable-table');
|
|
123
|
+
this.rdkTask = this.querySelector('rdk-task');
|
|
20
124
|
this.rocSpace = this.querySelector('roc-space');
|
|
21
125
|
this.sdtModel = this.querySelector('sdt-model');
|
|
126
|
+
this.sdtParameters = this.querySelector('sdt-parameters');
|
|
22
127
|
|
|
23
128
|
if (this.rocSpace) {
|
|
24
129
|
if (this.rocSpace.hasAttribute('history')) {
|
|
@@ -26,70 +131,35 @@ export default class SDTExampleHuman extends SDTExample {
|
|
|
26
131
|
}
|
|
27
132
|
}
|
|
28
133
|
|
|
29
|
-
if (this.detectableControl
|
|
134
|
+
if (this.detectableControl) {
|
|
30
135
|
this.detectableControl.addEventListener('detectable-control-trials', (event) => {
|
|
31
|
-
|
|
32
|
-
this.rdkTask.trials = event.detail.trials;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (this.detectableResponse) {
|
|
36
|
-
this.detectableResponse.trialTotal = event.detail.trials;
|
|
37
|
-
}
|
|
136
|
+
this.trials = event.detail.trials;
|
|
38
137
|
});
|
|
39
|
-
}
|
|
40
138
|
|
|
41
|
-
if (this.detectableControl && this.detectableControl.hasAttribute('duration')) {
|
|
42
139
|
this.detectableControl.addEventListener('detectable-control-duration', (event) => {
|
|
43
|
-
|
|
44
|
-
this.rdkTask.duration = event.detail.duration;
|
|
45
|
-
this.rdkTask.wait = event.detail.duration;
|
|
46
|
-
this.rdkTask.iti = event.detail.duration;
|
|
47
|
-
}
|
|
140
|
+
this.duration = event.detail.duration;
|
|
48
141
|
});
|
|
49
|
-
}
|
|
50
142
|
|
|
51
|
-
if (this.detectableControl && this.detectableControl.hasAttribute('coherence')) {
|
|
52
143
|
this.detectableControl.addEventListener('detectable-control-coherence', (event) => {
|
|
53
|
-
|
|
54
|
-
this.rdkTask.coherence = event.detail.coherence;
|
|
55
|
-
}
|
|
144
|
+
this.coherence = event.detail.coherence;
|
|
56
145
|
});
|
|
57
|
-
}
|
|
58
146
|
|
|
59
|
-
if (this.detectableControl && this.detectableControl.hasAttribute('payoff')) {
|
|
60
147
|
this.detectableControl.addEventListener('detectable-control-payoff', (event) => {
|
|
61
|
-
|
|
62
|
-
this.detectableResponse.hPayoff = event.detail.payoff;
|
|
63
|
-
this.detectableResponse.mPayoff = -event.detail.payoff + 0; // Get rid of -0
|
|
64
|
-
this.detectableResponse.faPayoff = -(100 - event.detail.payoff) + 0; // Get rid of -0
|
|
65
|
-
this.detectableResponse.crPayoff = (100 - event.detail.payoff);
|
|
66
|
-
}
|
|
67
|
-
if (this.detectableTable) {
|
|
68
|
-
this.detectableTable.hPayoff = event.detail.payoff;
|
|
69
|
-
this.detectableTable.mPayoff = -event.detail.payoff + 0; // Get rid of -0
|
|
70
|
-
this.detectableTable.faPayoff = -(100 - event.detail.payoff) + 0; // Get rid of -0
|
|
71
|
-
this.detectableTable.crPayoff = (100 - event.detail.payoff);
|
|
72
|
-
}
|
|
148
|
+
this.payoff = event.detail.payoff;
|
|
73
149
|
});
|
|
74
|
-
}
|
|
75
150
|
|
|
76
|
-
if (this.detectableControl && this.detectableControl.hasAttribute('run')) {
|
|
77
151
|
this.detectableControl.addEventListener('detectable-control-run', (/* event */) => {
|
|
78
152
|
if (this.rdkTask) {
|
|
79
153
|
this.rdkTask.running = true;
|
|
80
154
|
}
|
|
81
155
|
});
|
|
82
|
-
}
|
|
83
156
|
|
|
84
|
-
if (this.detectableControl && this.detectableControl.hasAttribute('pause')) {
|
|
85
157
|
this.detectableControl.addEventListener('detectable-control-pause', (/* event */) => {
|
|
86
158
|
if (this.rdkTask) {
|
|
87
159
|
this.rdkTask.running = false;
|
|
88
160
|
}
|
|
89
161
|
});
|
|
90
|
-
}
|
|
91
162
|
|
|
92
|
-
if (this.detectableControl && this.detectableControl.hasAttribute('reset')) {
|
|
93
163
|
this.detectableControl.addEventListener('detectable-control-reset', (/* event */) => {
|
|
94
164
|
if (this.rdkTask) {
|
|
95
165
|
this.rdkTask.reset();
|
|
@@ -99,53 +169,37 @@ export default class SDTExampleHuman extends SDTExample {
|
|
|
99
169
|
this.detectableResponse.reset();
|
|
100
170
|
}
|
|
101
171
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
this.detectableTable.cr = 0;
|
|
107
|
-
}
|
|
172
|
+
this.h = 0;
|
|
173
|
+
this.m = 0;
|
|
174
|
+
this.fa = 0;
|
|
175
|
+
this.cr = 0;
|
|
108
176
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
this.rocSpace.hr = 0.5;
|
|
115
|
-
this.rocSpace.far = 0.5;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
177
|
+
this.hr = 0.5;
|
|
178
|
+
this.far = 0.5;
|
|
179
|
+
|
|
180
|
+
this.d = 0;
|
|
181
|
+
this.c = 0;
|
|
118
182
|
|
|
119
|
-
if (this.
|
|
120
|
-
this.
|
|
121
|
-
this.
|
|
183
|
+
if (this.rocSpace && this.rocSpace.hasAttribute('history')) {
|
|
184
|
+
this.count += 1;
|
|
185
|
+
this.rocSpace.set(0.5, 0.5, `point${this.count}`, this.count);
|
|
122
186
|
}
|
|
123
187
|
});
|
|
124
188
|
}
|
|
125
189
|
|
|
126
|
-
if (this.rdkTask) {
|
|
127
|
-
if (this.detectableResponse) {
|
|
128
|
-
this.detectableResponse.trialTotal = this.rdkTask.trials;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
190
|
if (this.rdkTask) {
|
|
133
191
|
this.rdkTask.addEventListener('rdk-trial-start', (event) => {
|
|
134
192
|
if (this.detectableResponse) {
|
|
135
193
|
this.detectableResponse.start(event.detail.signal, event.detail.trial);
|
|
136
194
|
}
|
|
137
195
|
});
|
|
138
|
-
}
|
|
139
196
|
|
|
140
|
-
if (this.rdkTask) {
|
|
141
197
|
this.rdkTask.addEventListener('rdk-trial-end', (/* event */) => {
|
|
142
198
|
if (this.detectableResponse) {
|
|
143
199
|
this.detectableResponse.stop();
|
|
144
200
|
}
|
|
145
201
|
});
|
|
146
|
-
}
|
|
147
202
|
|
|
148
|
-
if (this.rdkTask) {
|
|
149
203
|
this.rdkTask.addEventListener('rdk-block-end', (/* event */) => {
|
|
150
204
|
if (this.detectableControl) {
|
|
151
205
|
this.detectableControl.complete();
|
|
@@ -155,31 +209,109 @@ export default class SDTExampleHuman extends SDTExample {
|
|
|
155
209
|
|
|
156
210
|
if (this.detectableResponse) {
|
|
157
211
|
this.detectableResponse.addEventListener('detectable-response', (event) => {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
this.detectableTable.cr = event.detail.cr;
|
|
163
|
-
}
|
|
212
|
+
this.h = event.detail.h;
|
|
213
|
+
this.m = event.detail.m;
|
|
214
|
+
this.fa = event.detail.fa;
|
|
215
|
+
this.cr = event.detail.cr;
|
|
164
216
|
|
|
165
|
-
|
|
166
|
-
|
|
217
|
+
this.hr = SDTMath.hM2Hr((this.h + 1), (this.m + 1));
|
|
218
|
+
this.far = SDTMath.faCr2Far((this.fa + 1), (this.cr + 1));
|
|
167
219
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
this.rocSpace.set(newhr, newfar, (this.count === 1) ? 'default' : `point${this.count}`, this.count);
|
|
171
|
-
} else {
|
|
172
|
-
this.rocSpace.hr = newhr;
|
|
173
|
-
this.rocSpace.far = newfar;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
220
|
+
this.d = SDTMath.hrFar2D(this.hr, this.far);
|
|
221
|
+
this.c = SDTMath.hrFar2C(this.hr, this.far);
|
|
176
222
|
|
|
177
|
-
if (this.
|
|
178
|
-
this.
|
|
179
|
-
this.sdtModel.c = SDTMath.hrFar2C(newhr, newfar);
|
|
223
|
+
if (this.rocSpace && this.rocSpace.hasAttribute('history')) {
|
|
224
|
+
this.rocSpace.set(this.hr, this.far, (this.count === 1) ? 'default' : `point${this.count}`, this.count);
|
|
180
225
|
}
|
|
181
226
|
});
|
|
182
227
|
}
|
|
228
|
+
|
|
229
|
+
if (this.sdtParameters) {
|
|
230
|
+
this.sdtParameters.addEventListener('sdt-parameters-d', (event) => {
|
|
231
|
+
this.d = event.detail.d;
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
this.sdtParameters.addEventListener('sdt-parameters-c', (event) => {
|
|
235
|
+
this.c = event.detail.c;
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
this.sdtParameters.addEventListener('sdt-parameters-s', (event) => {
|
|
239
|
+
this.s = event.detail.s;
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
update(changedProperties) {
|
|
245
|
+
super.update(changedProperties);
|
|
246
|
+
|
|
247
|
+
if (this.detectableControl) {
|
|
248
|
+
this.detectableControl.trials = (this.detectableControl.trials != null)
|
|
249
|
+
? this.trials
|
|
250
|
+
: undefined;
|
|
251
|
+
this.detectableControl.duration = (this.detectableControl.duration != null)
|
|
252
|
+
? this.duration
|
|
253
|
+
: undefined;
|
|
254
|
+
this.detectableControl.coherence = (this.detectableControl.coherence != null)
|
|
255
|
+
? this.coherence
|
|
256
|
+
: undefined;
|
|
257
|
+
this.detectableControl.payoff = (this.detectableControl.payoff != null)
|
|
258
|
+
? this.payoff
|
|
259
|
+
: undefined;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (this.detectableResponse) {
|
|
263
|
+
this.detectableResponse.trialTotal = this.trials;
|
|
264
|
+
|
|
265
|
+
this.detectableResponse.hPayoff = this.payoff;
|
|
266
|
+
this.detectableResponse.mPayoff = -this.payoff + 0; // Get rid of -0
|
|
267
|
+
this.detectableResponse.faPayoff = -(100 - this.payoff) + 0; // Get rid of -0
|
|
268
|
+
this.detectableResponse.crPayoff = (100 - this.payoff);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
if (this.detectableTable) {
|
|
272
|
+
this.detectableTable.h = this.h;
|
|
273
|
+
this.detectableTable.m = this.m;
|
|
274
|
+
this.detectableTable.cr = this.cr;
|
|
275
|
+
this.detectableTable.fa = this.fa;
|
|
276
|
+
|
|
277
|
+
this.detectableTable.hPayoff = this.payoff;
|
|
278
|
+
this.detectableTable.mPayoff = -this.payoff + 0; // Get rid of -0
|
|
279
|
+
this.detectableTable.faPayoff = -(100 - this.payoff) + 0; // Get rid of -0
|
|
280
|
+
this.detectableTable.crPayoff = (100 - this.payoff);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (this.rdkTask) {
|
|
284
|
+
this.rdkTask.trials = this.trials;
|
|
285
|
+
|
|
286
|
+
this.rdkTask.duration = this.duration;
|
|
287
|
+
this.rdkTask.wait = (this.duration === Infinity) ? 0 : this.duration;
|
|
288
|
+
this.rdkTask.iti = (this.duration === Infinity) ? 0 : this.duration;
|
|
289
|
+
|
|
290
|
+
this.rdkTask.coherence = this.coherence;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (this.rocSpace && !this.rocSpace.hasAttribute('history')) {
|
|
294
|
+
this.rocSpace.hr = this.hr;
|
|
295
|
+
this.rocSpace.far = this.far;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (this.sdtModel) {
|
|
299
|
+
this.sdtModel.d = this.d;
|
|
300
|
+
this.sdtModel.c = this.c;
|
|
301
|
+
this.sdtModel.s = this.s;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if (this.sdtParameters) {
|
|
305
|
+
this.sdtParameters.d = (this.sdtParameters.d != null)
|
|
306
|
+
? this.d
|
|
307
|
+
: undefined;
|
|
308
|
+
this.sdtParameters.c = (this.sdtParameters.c != null)
|
|
309
|
+
? this.c
|
|
310
|
+
: undefined;
|
|
311
|
+
this.sdtParameters.s = (this.sdtParameters.s != null)
|
|
312
|
+
? this.s
|
|
313
|
+
: undefined;
|
|
314
|
+
}
|
|
183
315
|
}
|
|
184
316
|
}
|
|
185
317
|
|