@decidables/accumulable-elements 0.1.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/README.md ADDED
@@ -0,0 +1,1048 @@
1
+ <!--lint ignore first-heading-level maximum-heading-length-->
2
+
3
+ # **`@decidables/accumulable-elements`**<br>Web Components for Visualizing the Diffusion Decision Model in [<b><i>a</i>ccumulable</b>](https://decidables.github.io/accumulable)
4
+
5
+ Note: **NOT PUBLISHED YET!**
6
+
7
+ [![npm version](https://img.shields.io/npm/v/@decidables/accumulable-elements?logo=npm)](https://www.npmjs.com/package/@decidables/accumulable-elements)
8
+ [![license](https://img.shields.io/npm/l/@decidables/accumulable-elements?color=informational)](https://github.com/decidables/decidables/blob/main/LICENSE.md)
9
+
10
+ The web components used to visualize the Diffusion Decision Model in
11
+ [<b><i>a</i>ccumulable</b>](https://decidables.github.io/accumulable). There is an emphasis
12
+ on direct manipulation and consistent use of color. SVG is used extensively to provide clean
13
+ scalable diagrams.
14
+
15
+ ## Usage
16
+
17
+ ### Install
18
+
19
+ ```shell
20
+ yarn add @decidables/accumulable-elements
21
+ ```
22
+
23
+ ### Use
24
+
25
+ ```javascript
26
+ import '@decidables/accumulable-elements';
27
+ ```
28
+
29
+ A bare import is used to register the elements in the custom registry, so they are then available
30
+ for use in HTML.
31
+
32
+ ## Contents
33
+
34
+ ### Components
35
+
36
+ Building blocks for interactive visualizations of DDM
37
+
38
+ #### `AccumulableControl` / `<accumulable-control>`
39
+
40
+ Control panel for running demos
41
+
42
+ A configurable set of controls for user manipulation of examples of the diffusion decision model.
43
+ Controls can be provided for the number of trials, resampling trials, the duration of trials, the
44
+ coherence of the dots moving together in the stimulus, the coloring used in the results table, and
45
+ for running, pausing, or resetting a block of trials.
46
+
47
+ ##### Attributes
48
+
49
+ - `trials: number = undefined`
50
+ - Show a slider for setting the number of trials, initialized to the value provided
51
+ - Options
52
+ - `1` to `100` in steps of `1`
53
+ - `resample: boolean = false`
54
+ - Show a button to resample the model
55
+ - `duration: number = undefined`
56
+ - Show a slider for setting the duration of the stimulus, wait, and inter-trial interval on each
57
+ trial, initialized to the value provided in milliseconds
58
+ - Options
59
+ - `10` to `2000` in steps of `10`
60
+ - `coherence: number = undefined`
61
+ - Show a slider for setting the proportion of coherent dots in the visual stimulus
62
+ - Options
63
+ - `0` to `1` in steps of `0.01`
64
+ - `color: string = undefined`
65
+ - Show a set of options to select how to color the cells in the results table
66
+ - Options
67
+ - `'none'`
68
+ - No use of color
69
+ - `'measure'`
70
+ - Color based on measure (*count/accuracy*, *mean RT*, *standard deviation RT*)
71
+ - `'outcome'`
72
+ - Color based on outcome (*correct*, *error*, *overall*)
73
+ - `'all'`
74
+ - Color based on measure and outcome
75
+ - `run: boolean = false`
76
+ - Show a button to run the task
77
+ - `pause: boolean = false`
78
+ - Show a button to pause the task
79
+ - `reset: boolean = false`
80
+ - Show a button to reset the task
81
+
82
+ ##### Methods
83
+
84
+ - `complete()`
85
+ - Indicates that a trial block is done, so it can no longer be paused
86
+
87
+ ##### Custom Events
88
+
89
+ - `accumulable-control-trials`
90
+ - Indicates the number of trials slider has been adjusted
91
+ - `detail`
92
+ - `trials: number`
93
+ - The new number of trials
94
+ - `accumulable-control-resample`
95
+ - Indicates the resample button has been pushed
96
+ - `accumulable-control-duration`
97
+ - Indicates the duration of trials slider has been adjusted
98
+ - `detail`
99
+ - `duration: number`
100
+ - The new duration
101
+ - `accumulable-control-coherence`
102
+ - Indicates the coherence of stimulus dots slider has been adjusted
103
+ - `detail`
104
+ - `coherence: number`
105
+ - The new coherence
106
+ - `accumulable-control-color`
107
+ - Indicates the color selection for the results table has been toggled
108
+ - `detail`
109
+ - `color: string`
110
+ - The new color scheme
111
+ - `accumulable-control-run`
112
+ - Indicates the run button has been pushed
113
+ - `accumulable-control-pause`
114
+ - Indicates the pause button has been pushed
115
+ - `accumulable-control-reset`
116
+ - Indicates the reset button has been pushed
117
+
118
+ ##### Example
119
+
120
+ ```html
121
+ <accumulable-control trials="15" resample duration="1500" coherence="0.2" color="outcome" run pause reset></accumulable-control>
122
+ ```
123
+
124
+ #### `AccumulableResponse` / `<accumulable-response>`
125
+
126
+ Response buttons, feedback, and payoffs for two-alternative forced choice tasks
127
+
128
+ This element provides 'left' and 'right' response buttons. It can also display a running count of
129
+ the trials, display feedback on accuracy, and display the current trial and total payoff.
130
+
131
+ ##### Attributes
132
+
133
+ - `interactive: boolean = false`
134
+ - Allow user to respond, instead of just displaying simulated model responses
135
+ - `feedback: boolean = false`
136
+ - Whether to display feedback
137
+ - `trial: boolean = false`
138
+ - Display the running count of trials, i.e. 'Trial: 2 of 10'
139
+ - `payoff: string = 'none'`
140
+ - What payoff information to display
141
+ - Options
142
+ - `'none'`
143
+ - No payoff information displayed
144
+ - `'trial'`
145
+ - Only display payoff for the current trial
146
+ - `'total'`
147
+ - Display payoff for the current trial and display the total payoff for the block
148
+ - `correct-payoff: number = 0`
149
+ - Value of payoff for a correct response
150
+ - `error-payoff: number = 0`
151
+ - Value of payoff for an error response
152
+ - `no-response-payoff: number = 0`
153
+ - Value of payoff for no response
154
+
155
+ ##### Methods
156
+
157
+ - `start(signal, trial)`
158
+ - Indicates that a trial has started, and its time to wait for a response
159
+ - Parameters
160
+ - `signal: string`
161
+ - Whether this is a movement `'left'` or `'right'` trial
162
+ - `trial: number`
163
+ - The count of the trial within the block
164
+ - `stop()`
165
+ - Indicates that the trial is over and it is time to display any requested feedback
166
+ - **Note:** If no response has been made yet, the trial is recorded as having no response
167
+ - `left()`
168
+ - Emulate a 'left' response
169
+ - `right()`
170
+ - Emulate an 'right' response
171
+ - `responded(response)`
172
+ - Emulate a response
173
+ - Parameters
174
+ - `response: string`
175
+ - Whether to emulate a `'left'` or `'right'` response
176
+ - `reset()`
177
+ - Reset to the state at the start of a block of trials
178
+
179
+ ##### Custom Events
180
+
181
+ - `accumulable-response`
182
+ - Indicates that a response has been made on this trial
183
+ - `detail`
184
+ - `trial: number`
185
+ - The count of this trial in the block
186
+ - `rt: number`
187
+ - The reaction time in milliseconds
188
+ - `signal: string`
189
+ - Whether the signal was actually `'left'` or `'right'`
190
+ - `response: string`
191
+ - Whether the response was `'left'` or `'right'`
192
+ - `outcome: string`
193
+ - The outcome of the trial as an `'error'` or `'correct'`
194
+ - `payoff: number`
195
+ - The payoff for this trial
196
+ - `correctCount: number`
197
+ - Number of correct trials
198
+ - `errorCount: number`
199
+ - Number of error trials
200
+ - `nrCount: number`
201
+ - Number of no-response trials
202
+ - `accuracy: number`
203
+ - Proportion of correct trials
204
+ - `meanRT: number`
205
+ - Overall mean reaction time
206
+ - `correctMeanRT: number`
207
+ - Mean reaction time on correct trials
208
+ - `errorMeanRT: number`
209
+ - Mean reaction time on error trials
210
+ - `sdRT: number`
211
+ - Overall standard deviation of reaction time
212
+ - `correctSDRT: number`
213
+ - Standard deviation of reaction time on correct trials
214
+ - `errorSDRT: number`
215
+ - Standard deviation of reaction time on error trials
216
+ - `totalPayoff: number`
217
+ - Total payoff for the block
218
+
219
+ ##### Example
220
+
221
+ ```html
222
+ <accumulable-response interactive feedback trial payoff="total" correct-payoff="100" error-payoff="-100" no-response-payoff="0"></accumulable-response>
223
+ ```
224
+
225
+ #### `AccumulableTable` / `<accumulable-table>`
226
+
227
+ Table of accuracy and response time outcomes
228
+
229
+ A results table for diffusion decision model tasks. The results are presented in a three by three
230
+ table organized by measure (count/accuracy, mean RT, and SD RT) and outcome ('correct', 'error', and
231
+ overall).
232
+
233
+ ##### Attributes
234
+
235
+ - `interactive: boolean = false`
236
+ - **NOT IMPLEMENTED** Allow user to change values in the table
237
+ - `numeric: boolean = false`
238
+ - Show numeric values instead of just labelling the cells
239
+ - `summary: boolean = false`
240
+ - Should the overall statistics be shown
241
+ - `color: string = 'outcome'`
242
+ - How to color the cells
243
+ - Options
244
+ - `'none'`
245
+ - No use of color
246
+ - `'measure'`
247
+ - Color based on measure (*count/accuracy*, *mean RT*, *standard deviation RT*)
248
+ - `'outcome'`
249
+ - **NOT IMPLEMENTED** Color based on outcome (*correct*, *error*, *overall*)
250
+ - `'all'`
251
+ - **NOT IMPLEMENTED** Color based on measure and outcome
252
+ - `correctCount: number = undefined`
253
+ - Number of correct trials
254
+ - `errorCount: number = undefined`
255
+ - Number of error trials
256
+ - `nrCount: number = undefined`
257
+ - Number of no-response trials
258
+ - `accuracy: number = undefined`
259
+ - Proportion of correct trials
260
+ - `correctMeanRT: number = undefined`
261
+ - Mean reaction time on correct trials
262
+ - `errorMeanRT: number = undefined`
263
+ - Mean reaction time on error trials
264
+ - `meanRT: number = undefined`
265
+ - Overall mean reaction time
266
+ - `correctSDRT: number = undefined`
267
+ - Standard deviation of reaction time on correct trials
268
+ - `errorSDRT: number = undefined`
269
+ - Standard deviation of reaction time on error trials
270
+ - `sdRT: number = undefined`
271
+ - Overall standard deviation of reaction time
272
+ - `payoff: boolean = false`
273
+ - Whether to display payoffs
274
+ - `correct-payoff: number = undefined`
275
+ - Payoff for correct trials
276
+ - `error-payoff: number = undefined`
277
+ - Payoff for error trials
278
+ - `no-response-payoff: number = undefined`
279
+ - Payoff for no-response trials
280
+
281
+ ##### Custom Events
282
+
283
+ - `accumulable-table-change`
284
+ - One or more values in the table have changed
285
+ - `detail`
286
+ - `correctCount: number`
287
+ - Number of correct trials
288
+ - `errorCount: number`
289
+ - Number of error trials
290
+ - `nrCount: number`
291
+ - Number of no-response trials
292
+ - `accuracy: number`
293
+ - Proportion of correct trials
294
+ - `meanRT: number`
295
+ - Overall mean reaction time
296
+ - `correctMeanRT: number`
297
+ - Mean reaction time on correct trials
298
+ - `errorMeanRT: number`
299
+ - Mean reaction time on error trials
300
+ - `sdRT: number`
301
+ - Overall standard deviation of reaction time
302
+ - `correctSDRT: number`
303
+ - Standard deviation of reaction time on correct trials
304
+ - `errorSDRT: number`
305
+ - Standard deviation of reaction time on error trials
306
+
307
+ ##### Example
308
+
309
+ ```html
310
+ <accumulable-table numeric summary color="outcome" correct-count="7" error-count="3" nr-count="0" accuracy="0.7" correct-mean-rt="600" error-mean-rt="300" mean-rt="510" correct-sd-rt="200" error-sd-rt="100" sd-rt="200"></accumulable-table>
311
+ ```
312
+
313
+ #### `DDMFit` / `<ddm-fit>`
314
+
315
+ Fits DDM parameters to empirical data using a model running in a WebWorker
316
+
317
+ The component displays the observed data, the fit parameters, and predicted data from those
318
+ parameters. Currently, the data is fit with the EZ-diffusion model (Wagenmakers et al., 2007). The
319
+ plan is to eventually fit using the EZ2 model (Grasman et al., 2009), but this is currently **NOT
320
+ IMPLEMENTED**.
321
+
322
+ **Note:** The current EZ fit procedure assumes *z* = 0.5
323
+
324
+ - Data
325
+ - **accuracy**: proportion of trials with correct responses
326
+ - **sdRT**: overall standard deviation of the reaction time (in milliseconds)
327
+ - **mRT**: overall mean reaction time (in milliseconds)
328
+ - **s**: diffusion standard deviation (typically set to the default value of `DDMMath.s`)
329
+ - Parameters
330
+ - **a**: boundary separation (distance, from 0 to infinity)
331
+ - **z**: starting point (proportion, from 0 to 1)
332
+ - **v**: drift rate (distance per second, from 0 to infinity)
333
+ - **t0**: non-decision time (milliseconds, from 0 to infinity)
334
+
335
+ ##### Methods
336
+
337
+ - `fit()`
338
+ - Initiates a new fit, or queues one if the model is already fitting
339
+ - `clear()`
340
+ - Removes all observed data, and initiates a data-free initial fit
341
+ - `set(data)`
342
+ - Sets the current observed data
343
+ - Parameters
344
+ - `a: number`
345
+ - Boundary separation
346
+ - `z: number`
347
+ - Starting point
348
+ - `v: number`
349
+ - Drift rate
350
+ - `t0: number`
351
+ - Non-decision time
352
+
353
+ ##### Custom Events
354
+
355
+ - `ddm-fit-update`
356
+ - Indicates that the fit has completed
357
+ - `detail`
358
+ - `a: number`
359
+ - New value for boundary separation
360
+ - `z: number`
361
+ - New value for starting point
362
+ - `v: number`
363
+ - New value for drift rate
364
+ - `t0: number`
365
+ - New value for non-decision time
366
+
367
+ ##### Example
368
+
369
+ ```html
370
+ <ddm-fit></ddm-fit>
371
+ ```
372
+
373
+ #### `DDMModel` / `<ddm-model>`
374
+
375
+ Interactive visualization of DDM in terms of a drift-diffusion process
376
+
377
+ Displays a drift diffusion process with boundaries, a potentially biased starting point,
378
+ non-decision time, and a drift rate - all of which can be directly manipulated. Shows the RT
379
+ distributions for correct and error trials and the proportion of correct trials. Can also show
380
+ simulated individual paths, along with their resulting RTs, and the resulting sampled accuracy. Note
381
+ that simulated paths will update as the parameters are manipulated. Can also show the mean and SD
382
+ for each distribution and for the sampled trials.
383
+
384
+ The paths can be animated when added individually to the visualization.
385
+
386
+ ##### Attributes
387
+
388
+ - `interactive: boolean = false`
389
+ - Allow direct manipulation of boundaries, starting point, non-decision time, and drift rate
390
+ - `measures: boolean = false`
391
+ - Whether to display line and text annotations for each parameter
392
+ - `means: boolean = false`
393
+ - Whether to display means for theoretical distributions and samples
394
+ - `sds: boolean = false`
395
+ - Whether to display standard deviations for theoretical distributions and samples
396
+ - `human: boolean = false`
397
+ - Whether results are passed in from human performance, or need to be generated from the model
398
+ parameters
399
+ - `trials: number = 10`
400
+ - The number of sampled trials to display
401
+ - `seed: number = <random sample from uniform distribution from 0 to 1>`
402
+ - The seed for random number generation, to ensure stable samples when changing parameters
403
+ - `a: number = 1.2`
404
+ - Boundary separation parameter
405
+ - `z: number = 0.35`
406
+ - Starting point parameter
407
+ - `v: number = 1.5`
408
+ - Drift rate parameter
409
+ - `t0: number = 150`
410
+ - Non-decision time parameter
411
+
412
+ ##### Methods
413
+
414
+ - `clear()`
415
+ - Remove all trial-by-trial data
416
+ - `trial(trial)`
417
+ - Add a trial to the sample
418
+ - Parameters
419
+ - `index: number`
420
+ - Numerical count of the trial in the block
421
+ - `seed: string`
422
+ - The random seed used to generate the path for this trial
423
+ - `path: array of {t: number, e: number}`
424
+ - The sampled path as an array of time & evidence pairs
425
+ - `rt: number`
426
+ - The reaction time in milliseconds
427
+ - `outcome: string`
428
+ - The outcome of the trial, either 'correct', 'error', or 'nr' for no response
429
+ - `animate: boolean`
430
+ - Whether or not this trial should be animated
431
+ - `pauseTrial()`
432
+ - Pause the animation of trials
433
+ - `resumeTrial()`
434
+ - Resume the animation of trials
435
+ - `resample()`
436
+ - Generate a new base seed for all samples
437
+
438
+ ##### Custom Events
439
+
440
+ - `ddm-model-output`
441
+ - Indicates that the model and/or sampled data have changed
442
+ - `detail`
443
+ - `data: object`
444
+ - `trials: array of trial objects`
445
+ - `index: number`
446
+ - Numerical count of the trial in the block
447
+ - `seed: string`
448
+ - The random seed used to generate the path for this trial
449
+ - `path: array of {t: number, e: number}`
450
+ - The sampled path as an array of time & evidence pairs
451
+ - `rt: number`
452
+ - The reaction time in milliseconds
453
+ - `outcome: string`
454
+ - The outcome of the trial, either 'correct', 'error', or 'nr' for no response
455
+ - `animate: boolean`
456
+ - Whether or not this trial should be animated
457
+ - `correctCount: number`
458
+ - Number of correct trials
459
+ - `errorCount: number`
460
+ - Number of error trials
461
+ - `nrCount: number`
462
+ - Number of no-response trials
463
+ - `accuracy: number`
464
+ - Proportion of correct trials
465
+ - `meanRT: number`
466
+ - Overall mean reaction time
467
+ - `correctMeanRT: number`
468
+ - Mean reaction time on correct trials
469
+ - `errorMeanRT: number`
470
+ - Mean reaction time on error trials
471
+ - `sdRT: number`
472
+ - Overall standard deviation of reaction time
473
+ - `correctSDRT: number`
474
+ - Standard deviation of reaction time on correct trials
475
+ - `errorSDRT: number`
476
+ - Standard deviation of reaction time on error trials
477
+ - `model: object`
478
+ - `accuracy: number`
479
+ - Proportion of correct trials
480
+ - `correctMeanRT: number`
481
+ - Mean reaction time on correct trials
482
+ - `errorMeanRT: number`
483
+ - Mean reaction time on error trials
484
+ - `correctSDRT: number`
485
+ - Standard deviation of reaction time on correct trials
486
+ - `errorSDRT: number`
487
+ - Standard deviation of reaction time on error trials
488
+ - `ddm-model-a`
489
+ - Indicates an update to boundary separation
490
+ - `detail`
491
+ - `a: number`
492
+ - New value for boundary separation
493
+ - `ddm-model-z`
494
+ - Indicates an update to starting point
495
+ - `detail`
496
+ - `z: number`
497
+ - New value for starting point
498
+ - `ddm-model-v`
499
+ - Indicates an update to drift rate
500
+ - `detail`
501
+ - `v: number`
502
+ - New value for drift rate
503
+ - `ddm-model-t0`
504
+ - Indicates an update to non-decision time
505
+ - `detail`
506
+ - `t0: number`
507
+ - New value for non-decision time
508
+ - `accumulable-response`
509
+ - Indicates that the model has generated a response
510
+ - `detail`
511
+ - `outcome: string`
512
+ - The outcome of the trial as `'correct'`, `'error'`, or `'nr'` for no response
513
+ - `data: object`
514
+ - `trials: array of trial objects`
515
+ - `index: number`
516
+ - Numerical count of the trial in the block
517
+ - `seed: string`
518
+ - The random seed used to generate the path for this trial
519
+ - `path: array of {t: number, e: number}`
520
+ - The sampled path as an array of time & evidence pairs
521
+ - `rt: number`
522
+ - The reaction time in milliseconds
523
+ - `outcome: string`
524
+ - The outcome of the trial, either 'correct', 'error', or 'nr' for no response
525
+ - `animate: boolean`
526
+ - Whether or not this trial should be animated
527
+ - `correctCount: number`
528
+ - Number of correct trials
529
+ - `errorCount: number`
530
+ - Number of error trials
531
+ - `nrCount: number`
532
+ - Number of no-response trials
533
+ - `accuracy: number`
534
+ - Proportion of correct trials
535
+ - `meanRT: number`
536
+ - Overall mean reaction time
537
+ - `correctMeanRT: number`
538
+ - Mean reaction time on correct trials
539
+ - `errorMeanRT: number`
540
+ - Mean reaction time on error trials
541
+ - `sdRT: number`
542
+ - Overall standard deviation of reaction time
543
+ - `correctSDRT: number`
544
+ - Standard deviation of reaction time on correct trials
545
+ - `errorSDRT: number`
546
+ - Standard deviation of reaction time on error trials
547
+ - `model: object`
548
+ - `accuracy: number`
549
+ - Proportion of correct trials
550
+ - `correctMeanRT: number`
551
+ - Mean reaction time on correct trials
552
+ - `errorMeanRT: number`
553
+ - Mean reaction time on error trials
554
+ - `correctSDRT: number`
555
+ - Standard deviation of reaction time on correct trials
556
+ - `errorSDRT: number`
557
+ - Standard deviation of reaction time on error trials
558
+
559
+ ##### Example
560
+
561
+ ```html
562
+ <ddm-model interactive measures means sds seed="0.123456789" trials="10" boundary-separation="1.2" starting-point="0.35" drift-rate="1.5" nondecision-time="150"></ddm-model>
563
+ ```
564
+
565
+ #### `DDMParameters` / `<ddm-parameters>`
566
+
567
+ Control panel for DDM model parameters
568
+
569
+ A configurable set of controls for user manipulation of DDM model parameters. Controls can be
570
+ provided for the boundary separation, starting pointm, drift rate, and non-decision time.
571
+
572
+ ##### Attributes
573
+
574
+ - `a: number = undefined`
575
+ - Show a slider for setting the boundary separation, initialized to the value provided
576
+ - Options
577
+ - `0.01` to `2` in steps of `0.01`
578
+ - `z: number = undefined`
579
+ - Show a slider for setting the starting point, initialized to the value provided
580
+ - Options
581
+ - `0.01` to `0.99` in steps of `0.01`
582
+ - `z: number = undefined`
583
+ - Show a slider for setting the drift rate, initialized to the value provided
584
+ - Options
585
+ - `0.01` to `5` in steps of `0.01`
586
+ - `t0: number = undefined`
587
+ - Show a slider for setting the non-decision time, initialized to the value provided
588
+ - Options
589
+ - `0` to `500` in steps of `1`
590
+
591
+ ##### Methods
592
+
593
+ ##### Custom Events
594
+
595
+ - `ddm-parameters-a`
596
+ - Indicates an update to boundary separation
597
+ - `detail`
598
+ - `a: number`
599
+ - New value for boundary separation
600
+ - `ddm-parameters-z`
601
+ - Indicates an update to starting point
602
+ - `detail`
603
+ - `z: number`
604
+ - New value for starting point
605
+ - `ddm-parameters-v`
606
+ - Indicates an update to drift rate
607
+ - `detail`
608
+ - `v: number`
609
+ - New value for drift rate
610
+ - `ddm-parameters-t0`
611
+ - Indicates an update to non-decision time
612
+ - `detail`
613
+ - `t0: number`
614
+ - New value for non-decision time
615
+
616
+ ##### Example
617
+
618
+ ```html
619
+ <ddm-parameters interactive boundary-separation="1.6" starting-point="0.75" drift-rate="1.25" nondecision-time="300"></ddm-parameters>
620
+ ```
621
+
622
+ #### `RDK2AFCTask` / `<rdt-2afc-task>`
623
+
624
+ Displays stimuli for random dot kinematogram two-alternative forced choice task
625
+
626
+ When run, a block of trials is presented. Before each trial is an inter-trial interval (ITI). Each
627
+ trial then consists of a stimulus followed by a period of waiting for a response. The stimulus
628
+ consists of a circle with a collection of small dots moving about. A subset of the dots move
629
+ coherently in the same direction, either to the *left* or the *right*. The task can be paused and
630
+ then resumed, and it can also be reset and run again.
631
+
632
+ ##### Attributes
633
+
634
+ - `coherence: number = 0.5`
635
+ - Proportion of dots moving coherently
636
+ - `count: number = 100`
637
+ - Number of dots
638
+ - `probability: number = 0.5`
639
+ - Probability of leftward (as opposed to rightward) movement
640
+ - `duration: number = 2000`
641
+ - Duration of stimulus in milliseconds
642
+ - `wait: number = 2000`
643
+ - Duration of wait period for response in milliseconds
644
+ - `iti: number = 2000`
645
+ - Duration of inter-trial interval in milliseconds
646
+ - `trials: number = 5`
647
+ - Number of trials per block
648
+ - `running: boolean = false`
649
+ - Currently executing block of trials
650
+
651
+ ##### Methods
652
+
653
+ - `reset()`
654
+ - Stops a currently running or ended block of trials and resets everything to be ready to run
655
+ again
656
+
657
+ ##### Custom Events
658
+
659
+ - `rdk-block-start`
660
+ - Indicates the beginning of a block of trials
661
+ - `rdk-block-end`
662
+ - Indicates the completion of a block of trials
663
+ - `detail` for `rdk-block-start` and `rdk-block-end`
664
+ - `trials: number`
665
+ - Number of trials in the block
666
+ - `rdk-trial-start`
667
+ - Indicates the beginning of a trial (iti is over and stimulus is about to start)
668
+ - `rdk-trial-middle`
669
+ - Indicates the middle of a trial (stimulus is over and the wait is about to start)
670
+ - `rdk-trial-end`
671
+ - Indicates the end of a trial (wait is over and iti is about to start)
672
+ - `detail` for `rdk-trial-start`, `rdk-trial-middle`, and `rdk-trial-end`
673
+ - `trials: number`
674
+ - Number of trials in the block
675
+ - `duration: number`
676
+ - Duration of stimulus in milliseconds
677
+ - `wait: number`
678
+ - Duration of wait period in milliseconds
679
+ - `iti: number`
680
+ - Duration of inter-trial interval in milliseconds
681
+ - `trial: number`
682
+ - Count of trial in block (one-based)
683
+ - `signal: string`
684
+ - Whether the signal is `present` or `absent` in this trial
685
+
686
+ ##### Example
687
+
688
+ ```html
689
+ <rdk-2afc-task trials="10" coherence="0.5" count="100" probability="0.5" duration="2000" wait="2000" iti="2000" running></rdk-2afc-task>
690
+ ```
691
+
692
+ ### Equations
693
+
694
+ Interactive equations for DDM
695
+
696
+ The equations can either be static and display the variable names, be static and display names and
697
+ values or be interactive with names and editable values, in which case only the values on the right
698
+ side of the equals sign are editable.
699
+
700
+ **Note:** The layout for these equations leaves something to be desired, especially on smaller
701
+ screens. Ideally a proper math renderer would be used, but I'm still working on how to use MathML in
702
+ conjunction with the custom elements needed for live editing.
703
+
704
+ #### DDMEquationAZV2PC / 'ddm-equation-azv2pc>`
705
+
706
+ Probability correct (accuracy) from boundary separation, starting point, and drift rate
707
+
708
+ ##### Attributes
709
+
710
+ - `numeric: boolean = false`
711
+ - Show values instead of just the names of variables
712
+ - `interactive: boolean = false`
713
+ - Allow editing of numeric values in the equation
714
+ - `boundary-separation: number = 1.5`
715
+ - Boundary separation, in units of evidence, *a*
716
+ - `starting-point: number = 0.5`
717
+ - Starting point, as a proportion of boundary separation, *z*
718
+ - `drift-rate: number = 0.1`
719
+ - Drift rate, in units of evidence per second, *v*
720
+
721
+ ##### Properties
722
+
723
+ - `accuracy: number`
724
+ - Proportion correct trials
725
+
726
+ ##### Custom Events
727
+
728
+ - `sdt-equation-azv2pc-change`
729
+ - Indicates that the values in the equation have changed
730
+ - `detail`
731
+ - `a: number`
732
+ - New value of boundary separation
733
+ - `z: number`
734
+ - New value of staring point
735
+ - `v: number`
736
+ - New value of drift rate
737
+ - `accuracy: number`
738
+ - New value of proportion correct
739
+
740
+ ##### Example
741
+
742
+ ```html
743
+ <ddm-equation-azv2pc numeric interactive boundary-separation="1.3" starting-point="0.5" drift-rate="1.2"></ddm-equation-azv2pc>
744
+ ```
745
+
746
+ #### DDMEquationAZVT02M / 'ddm-equation-azvt02m>`
747
+
748
+ Overall mean reaction time from boundary separation, starting point, drift rate, and non-decision
749
+ time
750
+
751
+ ##### Attributes
752
+
753
+ - `numeric: boolean = false`
754
+ - Show values instead of just the names of variables
755
+ - `interactive: boolean = false`
756
+ - Allow editing of numeric values in the equation
757
+ - `boundary-separation: number = 1.5`
758
+ - Boundary separation, in units of evidence, *a*
759
+ - `starting-point: number = 0.5`
760
+ - Starting point, as a proportion of boundary separation, *z*
761
+ - `drift-rate: number = 0.1`
762
+ - Drift rate, in units of evidence per second, *v*
763
+ - `non-decision-time: number = 200`
764
+ - Non-decision time, in milliseconds, *t0*
765
+
766
+ ##### Properties
767
+
768
+ - `meanRT: number`
769
+ - Overall mean reaction time in milliseconds
770
+
771
+ ##### Custom Events
772
+
773
+ - `sdt-equation-azvt02m-change`
774
+ - Indicates that the values in the equation have changed
775
+ - `detail`
776
+ - `a: number`
777
+ - New value of boundary separation
778
+ - `z: number`
779
+ - New value of staring point
780
+ - `v: number`
781
+ - New value of drift rate
782
+ - `t0: number`
783
+ - New value of non-decision time
784
+ - `meanRT: number`
785
+ - New value of overall mean reaction time
786
+
787
+ ##### Example
788
+
789
+ ```html
790
+ <ddm-equation-azvt02m numeric interactive boundary-separation="1.3" starting-point="0.5" drift-rate="1.2" nondecision-time="200" class=""></ddm-equation-azvt02m>
791
+ ```
792
+
793
+ #### `DDMEquation`
794
+
795
+ Base class for all interactive DDM equations
796
+
797
+ To define a new equation:
798
+
799
+ ```javascript
800
+ export default class DDMEquationSomething extends DDMEquation {
801
+ ...
802
+ }
803
+ ```
804
+
805
+ `DDMEquation` extends `AccumulableElement` extends `DecidablesElement` extends `LitElement`
806
+
807
+ ### Examples
808
+
809
+ Full examples built from multiple components
810
+
811
+ #### `DDMExampleHuman` / `<ddm-example-human>`
812
+
813
+ User runs two-alternative forced choice task and results are fit and displayed in real-time using
814
+ DDM
815
+
816
+ Used to build examples where the user is performing the random-dot kinematogram task. Can include
817
+ controls, the task itself, response buttons with feedback and payoffs, a table of results, ROC
818
+ space, and a visual rendering of signal detection theory. The table of results, ROC space, and the
819
+ SDT model should not be interactive, because their values are received from the user's task
820
+ performance.
821
+
822
+ ##### Slots
823
+
824
+ - *unnamed*
825
+ - Place relevant `accumulable-elements` components here
826
+ - Wired elements
827
+ - `<accumulable-control>`
828
+ - Allows user to adjust parameters and control the task
829
+ - `<rdk-2afc-task>`
830
+ - Displays the task
831
+ - `<accumulable-response>`
832
+ - Allows user to make responses and see feedback and payoffs
833
+ - `<accumulable-table>`
834
+ - Displays numerical results for the current block of trials
835
+ - `<ddm-parameters>`
836
+ - Displays the model parameters for current fit
837
+ - `<ddm-model>`
838
+ - Displays a visual rendering of model parameters, data, and model predictions
839
+ - `<ddm-fit>`
840
+ - Fits the user's responses to DDM using the EZ model in a Web Worker
841
+
842
+ ##### Example
843
+
844
+ ```html
845
+ <ddm-example-human>
846
+ <accumulable-control trials="10" duration="1000" coherence="0.4" color="outcome" run pause reset></accumulable-control>
847
+ <rdk-2afc-task trials="10"></rdk-2afc-task>
848
+ <accumulable-response interactive trial feedback></accumulable-response>
849
+ <accumulable-table numeric summary color="outcome"></accumulable-table>
850
+ <ddm-parameters></ddm-parameters>
851
+ <ddm-model human measures means sds></ddm-model>
852
+ <ddm-fit></ddm-fit>
853
+ </ddm-example-human>
854
+ ```
855
+
856
+ #### `DDMExampleInteractive` / `<ddm-example-interactive>`
857
+
858
+ Explore how RT mean, RT standard deviation, and accuracy relate to DDM model parameters
859
+
860
+ Used to build examples where the user can explore the relationship between RT and accuracy and model
861
+ parameters. All components can be interactive.
862
+
863
+ ##### Attributes
864
+
865
+ **Note:** Since many attributes are set on the example, they don't need to be set on the individual
866
+ components, as they will be propagated and kept in sync.
867
+
868
+ - `trials: number = 10`
869
+ - Number of sampled trials to display
870
+ - `boundary-separation: number = 1.5`
871
+ - Boundary separation, in units of evidence, *a*
872
+ - `starting-point: number = 0.5`
873
+ - Starting point, as a proportion of boundary separation, *z*
874
+ - `drift-rate: number = 0.1`
875
+ - Drift rate, in units of evidence per second, *v*
876
+ - `non-decision-time: number = 200`
877
+ - Non-decision time, in milliseconds, *t0*
878
+
879
+ ##### Slots
880
+
881
+ - *unnamed*
882
+ - Place relevant `accumulable-elements` components here
883
+ - Wired elements
884
+ - `<accumulable-control>`
885
+ - Allows user to adjust number of trials and resample paths
886
+ - `<accumulable-table>`
887
+ - Displays numerical results for the current block of trials
888
+ - `<ddm-parameters>`
889
+ - Allows user to adjust model parameters with sliders
890
+ - `<ddm-model>`
891
+ - Allows user to manipulate parameters in a visual rendering of model parameters, data, and
892
+ model predictions
893
+
894
+ ##### Example
895
+
896
+ ```html
897
+ <ddm-example-interactive trials="10" boundary-separation="1.2" starting-point="0.35" drift-rate="1.5" nondecision-time="150">
898
+ <accumulable-control trials="10" resample></accumulable-control>
899
+ <ddm-parameters interactive></ddm-parameters>
900
+ <ddm-model interactive measures means sds></ddm-model>
901
+ <accumulable-table numeric summary color="outcome"></accumulable-table>
902
+ </ddm-example-interactive>
903
+ ```
904
+
905
+ #### `DDMExampleModel` / `<ddm-example-model>`
906
+
907
+ Model simulates task performance based on DDM parameter values
908
+
909
+ Used to build examples where the model is simulated to perform the two-alternative forced choice
910
+ random-dot kinematogram task. Can include controls, the task itself, adjustable parameters, an
911
+ interactive visual rendering of the model, response buttons with feedback and payoffs, and a table
912
+ of results.
913
+
914
+ ##### Attributes
915
+
916
+ **Note:** Since model parameter attributes are set on the example, they don't need to be set on the
917
+ individual components, as they will be propagated and kept in sync.
918
+
919
+ - `trials: number = 10`
920
+ - Number of sampled trials to display
921
+ - `duration: number = 2000`
922
+ - The duration of the stimulus, wait, and inter-trial interval on each trial, initialized to the
923
+ value provided in milliseconds
924
+ - `coherence: number = 0.5`
925
+ - The proportion of coherent dots in the visual stimulus
926
+ - `color: string = outcome`
927
+ - How to color the cells in the results table
928
+ - Options
929
+ - `'none'`
930
+ - No use of color
931
+ - `'measure'`
932
+ - Color based on measure (*count/accuracy*, *mean RT*, *standard deviation RT*)
933
+ - `'outcome'`
934
+ - Color based on outcome (*correct*, *error*, *overall*)
935
+ - `'all'`
936
+ - Color based on measure and outcome
937
+ - `boundary-separation: number = 1.5`
938
+ - Model parameter: boundary separation, in units of evidence, *a*
939
+ - `starting-point: number = 0.5`
940
+ - Model parameter: starting point, as a proportion of boundary separation, *z*
941
+ - `drift-rate: number = 0.1`
942
+ - Model parameter: drift rate, in units of evidence per second, *v*
943
+ - `non-decision-time: number = 200`
944
+ - Model parameter: non-decision time, in milliseconds, *t0*
945
+
946
+ ##### Slots
947
+
948
+ - *unnamed*
949
+ - Place relevant `accumulable-elements` components here
950
+ - Wired elements
951
+ - `<accumulable-control>`
952
+ - Allows user to adjust parameters and control the task
953
+ - `<rdk-2afc-task>`
954
+ - Displays the task
955
+ - `<ddm-parameters>`
956
+ - Allows the user to adjust the model parameters for current fit
957
+ - `<ddm-model>`
958
+ - Interactive visual rendering of model parameters, data, and model predictions
959
+ - `<accumulable-response>`
960
+ - Allows user to view model responses and see feedback and payoffs
961
+ - `<accumulable-table>`
962
+ - Displays numerical results for the current block of trials
963
+
964
+ ##### Example
965
+
966
+ ```html
967
+ <ddm-example-model trials="10" duration="2000" coherence="0.5" color="outcome" boundary-separation="1.2" starting-point="0.35" drift-rate="1.5" nondecision-time="150">
968
+ <accumulable-control trials color run pause reset></accumulable-control>
969
+ <rdk-2afc-task></rdk-2afc-task>
970
+ <ddm-parameters interactive></ddm-parameters>
971
+ <ddm-model interactive measures means sds></ddm-model>
972
+ <accumulable-response trial feedback></accumulable-response>
973
+ <accumulable-table numeric summary></accumulable-table>
974
+ </ddm-example-model>
975
+ ```
976
+
977
+ #### `DDMExample`
978
+
979
+ Base class for all DDM examples
980
+
981
+ To define a new example:
982
+
983
+ ```javascript
984
+ export default class DDMExampleSomething extends DDMExample {
985
+ ...
986
+ }
987
+ ```
988
+
989
+ `DDMExample` extends `AccumulableElement` extends `DecidablesElement` extends `LitElement`
990
+
991
+ ### Base class
992
+
993
+ #### `AccumulableElement`
994
+
995
+ Base class for all *accumulable* web components
996
+
997
+ To define a new element:
998
+
999
+ ```javascript
1000
+ export default class AccumulableElementSomething extends AccumulableElement {
1001
+ ...
1002
+ }
1003
+ ```
1004
+
1005
+ `AccumulableElement` extends `DecidablesElement` extends `LitElement`
1006
+
1007
+ ## Development
1008
+
1009
+ ### Features/Bugs/Notes
1010
+
1011
+ - Very early stages!
1012
+
1013
+ ### Package Scripts
1014
+
1015
+ - `yarn lint`
1016
+ - Lints scripts in `src/`
1017
+ - `yarn test`
1018
+ - Runs all tests and reports coverage in `test/coverage/`
1019
+ - `yarn gulp testWatchScripts`
1020
+ - Runs all tests in watch mode and reports coverage in `test/coverage/`
1021
+ - `yarn gulp testScript <filename>`
1022
+ - Runs tests for a single file and reports coverage in `test/coverage/`
1023
+ - `yarn build`
1024
+ - Builds browser-compatible optimized bundle from `src/` to `lib/`
1025
+
1026
+ ### File Organization
1027
+
1028
+ - `accumulable-elements/`
1029
+ - `lib/` (Bundles created from `src/` by `build`)
1030
+ **\[autogenerated\]**
1031
+ - `src/` (Source files)
1032
+ - `components/` (Source for visualizations)
1033
+ - `equations/` (Source for equations)
1034
+ - `examples/` (Source for examples combining visualizations)
1035
+ - `test/` (Testing files)
1036
+ - `coverage/` (Code coverage results) **\[autogenerated\]**
1037
+ - `CHANGELOG.md` (Based on conventional commits) **\[autogenerated\]**
1038
+ - `gulpfile.js` (Tasks for *gulp*)
1039
+ - `package.json` (Package config for *yarn* and *npm*)
1040
+ - `README.md` (This file)
1041
+ - `rollup-stats.html` (Report on js bundle composition and size) **\[autogenerated\]**
1042
+
1043
+ ## [License](https://github.com/decidables/decidables/blob/main/LICENSE.md)
1044
+
1045
+ The content of this project is licensed under [Creative Commons Attribution-ShareAlike 4.0
1046
+ International License (CC-BY-SA-4.0)](https://creativecommons.org/licenses/by-sa/4.0/) and the
1047
+ source code of this project is licensed under [GNU General Public License v3.0 or any later version
1048
+ (GPL-3.0-or-later)](https://www.gnu.org/licenses/gpl-3.0.html).