@jspsych-contrib/plugin-trail-making 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.
@@ -0,0 +1,341 @@
1
+ import { JsPsychPlugin, ParameterType, JsPsych, TrialType } from 'jspsych';
2
+
3
+ declare const info: {
4
+ readonly name: "trail-making";
5
+ readonly version: string;
6
+ readonly parameters: {
7
+ /**
8
+ * The type of trail making test to run.
9
+ * "A" = numbers only (1-2-3-4...)
10
+ * "B" = alternating numbers and letters (1-A-2-B-3-C...)
11
+ */
12
+ readonly test_type: {
13
+ readonly type: ParameterType.STRING;
14
+ readonly default: "A";
15
+ };
16
+ /**
17
+ * The number of targets to display. For type "B", this should be an even number
18
+ * to have equal numbers and letters.
19
+ */
20
+ readonly num_targets: {
21
+ readonly type: ParameterType.INT;
22
+ readonly default: 25;
23
+ };
24
+ /**
25
+ * The width of the display area in pixels.
26
+ */
27
+ readonly canvas_width: {
28
+ readonly type: ParameterType.INT;
29
+ readonly default: 600;
30
+ };
31
+ /**
32
+ * The height of the display area in pixels.
33
+ */
34
+ readonly canvas_height: {
35
+ readonly type: ParameterType.INT;
36
+ readonly default: 600;
37
+ };
38
+ /**
39
+ * The radius of each target circle in pixels.
40
+ */
41
+ readonly target_radius: {
42
+ readonly type: ParameterType.INT;
43
+ readonly default: 25;
44
+ };
45
+ /**
46
+ * The minimum distance between target centers in pixels.
47
+ */
48
+ readonly min_separation: {
49
+ readonly type: ParameterType.INT;
50
+ readonly default: 80;
51
+ };
52
+ /**
53
+ * The color of unvisited target circles.
54
+ */
55
+ readonly target_color: {
56
+ readonly type: ParameterType.STRING;
57
+ readonly default: "#ffffff";
58
+ };
59
+ /**
60
+ * The border color of target circles.
61
+ */
62
+ readonly target_border_color: {
63
+ readonly type: ParameterType.STRING;
64
+ readonly default: "#000000";
65
+ };
66
+ /**
67
+ * The color of visited (correctly clicked) target circles.
68
+ */
69
+ readonly visited_color: {
70
+ readonly type: ParameterType.STRING;
71
+ readonly default: "#90EE90";
72
+ };
73
+ /**
74
+ * The color of the line connecting targets.
75
+ */
76
+ readonly line_color: {
77
+ readonly type: ParameterType.STRING;
78
+ readonly default: "#000000";
79
+ };
80
+ /**
81
+ * The width of the connecting line in pixels.
82
+ */
83
+ readonly line_width: {
84
+ readonly type: ParameterType.INT;
85
+ readonly default: 2;
86
+ };
87
+ /**
88
+ * The color to flash when an error is made.
89
+ */
90
+ readonly error_color: {
91
+ readonly type: ParameterType.STRING;
92
+ readonly default: "#FF6B6B";
93
+ };
94
+ /**
95
+ * Duration in milliseconds to show error feedback.
96
+ */
97
+ readonly error_duration: {
98
+ readonly type: ParameterType.INT;
99
+ readonly default: 500;
100
+ };
101
+ /**
102
+ * Optional array of {x, y, label} objects to specify exact target positions.
103
+ * If provided, overrides num_targets and random positioning.
104
+ * Coordinates are in pixels from top-left of canvas.
105
+ */
106
+ readonly targets: {
107
+ readonly type: ParameterType.COMPLEX;
108
+ readonly default: any;
109
+ };
110
+ /**
111
+ * Text prompt displayed above the canvas.
112
+ */
113
+ readonly prompt: {
114
+ readonly type: ParameterType.HTML_STRING;
115
+ readonly default: any;
116
+ };
117
+ /**
118
+ * Random seed for reproducible target layouts. If null, uses random seed.
119
+ */
120
+ readonly seed: {
121
+ readonly type: ParameterType.INT;
122
+ readonly default: any;
123
+ };
124
+ };
125
+ readonly data: {
126
+ /** The type of trail making test ("A" or "B"). */
127
+ readonly test_type: {
128
+ readonly type: ParameterType.STRING;
129
+ };
130
+ /** Array of target objects with x, y, and label properties. */
131
+ readonly targets: {
132
+ readonly type: ParameterType.COMPLEX;
133
+ readonly array: true;
134
+ };
135
+ /** Array of click events with target_index, label, time, x, y, and correct properties. */
136
+ readonly clicks: {
137
+ readonly type: ParameterType.COMPLEX;
138
+ readonly array: true;
139
+ };
140
+ /** Total time in milliseconds from first click to last correct click. */
141
+ readonly completion_time: {
142
+ readonly type: ParameterType.INT;
143
+ };
144
+ /** Number of errors (incorrect clicks). */
145
+ readonly num_errors: {
146
+ readonly type: ParameterType.INT;
147
+ };
148
+ /** Total path distance in pixels (sum of distances between consecutive correct targets). */
149
+ readonly total_path_distance: {
150
+ readonly type: ParameterType.FLOAT;
151
+ };
152
+ /** Array of response times between consecutive correct clicks. */
153
+ readonly inter_click_times: {
154
+ readonly type: ParameterType.INT;
155
+ readonly array: true;
156
+ };
157
+ };
158
+ };
159
+ type Info = typeof info;
160
+ /**
161
+ * **trail-making**
162
+ *
163
+ * A jsPsych plugin for the Trail Making Test (TMT), a neuropsychological test of
164
+ * visual attention and task switching. Participants connect circles in sequence
165
+ * as quickly as possible.
166
+ *
167
+ * Part A: Connect numbers in order (1-2-3-4...)
168
+ * Part B: Alternate between numbers and letters (1-A-2-B-3-C...)
169
+ *
170
+ * @author Josh de Leeuw
171
+ * @see {@link https://github.com/jspsych/jspsych-contrib/tree/main/packages/plugin-trail-making}
172
+ */
173
+ declare class TrailMakingPlugin implements JsPsychPlugin<Info> {
174
+ private jsPsych;
175
+ static info: {
176
+ readonly name: "trail-making";
177
+ readonly version: string;
178
+ readonly parameters: {
179
+ /**
180
+ * The type of trail making test to run.
181
+ * "A" = numbers only (1-2-3-4...)
182
+ * "B" = alternating numbers and letters (1-A-2-B-3-C...)
183
+ */
184
+ readonly test_type: {
185
+ readonly type: ParameterType.STRING;
186
+ readonly default: "A";
187
+ };
188
+ /**
189
+ * The number of targets to display. For type "B", this should be an even number
190
+ * to have equal numbers and letters.
191
+ */
192
+ readonly num_targets: {
193
+ readonly type: ParameterType.INT;
194
+ readonly default: 25;
195
+ };
196
+ /**
197
+ * The width of the display area in pixels.
198
+ */
199
+ readonly canvas_width: {
200
+ readonly type: ParameterType.INT;
201
+ readonly default: 600;
202
+ };
203
+ /**
204
+ * The height of the display area in pixels.
205
+ */
206
+ readonly canvas_height: {
207
+ readonly type: ParameterType.INT;
208
+ readonly default: 600;
209
+ };
210
+ /**
211
+ * The radius of each target circle in pixels.
212
+ */
213
+ readonly target_radius: {
214
+ readonly type: ParameterType.INT;
215
+ readonly default: 25;
216
+ };
217
+ /**
218
+ * The minimum distance between target centers in pixels.
219
+ */
220
+ readonly min_separation: {
221
+ readonly type: ParameterType.INT;
222
+ readonly default: 80;
223
+ };
224
+ /**
225
+ * The color of unvisited target circles.
226
+ */
227
+ readonly target_color: {
228
+ readonly type: ParameterType.STRING;
229
+ readonly default: "#ffffff";
230
+ };
231
+ /**
232
+ * The border color of target circles.
233
+ */
234
+ readonly target_border_color: {
235
+ readonly type: ParameterType.STRING;
236
+ readonly default: "#000000";
237
+ };
238
+ /**
239
+ * The color of visited (correctly clicked) target circles.
240
+ */
241
+ readonly visited_color: {
242
+ readonly type: ParameterType.STRING;
243
+ readonly default: "#90EE90";
244
+ };
245
+ /**
246
+ * The color of the line connecting targets.
247
+ */
248
+ readonly line_color: {
249
+ readonly type: ParameterType.STRING;
250
+ readonly default: "#000000";
251
+ };
252
+ /**
253
+ * The width of the connecting line in pixels.
254
+ */
255
+ readonly line_width: {
256
+ readonly type: ParameterType.INT;
257
+ readonly default: 2;
258
+ };
259
+ /**
260
+ * The color to flash when an error is made.
261
+ */
262
+ readonly error_color: {
263
+ readonly type: ParameterType.STRING;
264
+ readonly default: "#FF6B6B";
265
+ };
266
+ /**
267
+ * Duration in milliseconds to show error feedback.
268
+ */
269
+ readonly error_duration: {
270
+ readonly type: ParameterType.INT;
271
+ readonly default: 500;
272
+ };
273
+ /**
274
+ * Optional array of {x, y, label} objects to specify exact target positions.
275
+ * If provided, overrides num_targets and random positioning.
276
+ * Coordinates are in pixels from top-left of canvas.
277
+ */
278
+ readonly targets: {
279
+ readonly type: ParameterType.COMPLEX;
280
+ readonly default: any;
281
+ };
282
+ /**
283
+ * Text prompt displayed above the canvas.
284
+ */
285
+ readonly prompt: {
286
+ readonly type: ParameterType.HTML_STRING;
287
+ readonly default: any;
288
+ };
289
+ /**
290
+ * Random seed for reproducible target layouts. If null, uses random seed.
291
+ */
292
+ readonly seed: {
293
+ readonly type: ParameterType.INT;
294
+ readonly default: any;
295
+ };
296
+ };
297
+ readonly data: {
298
+ /** The type of trail making test ("A" or "B"). */
299
+ readonly test_type: {
300
+ readonly type: ParameterType.STRING;
301
+ };
302
+ /** Array of target objects with x, y, and label properties. */
303
+ readonly targets: {
304
+ readonly type: ParameterType.COMPLEX;
305
+ readonly array: true;
306
+ };
307
+ /** Array of click events with target_index, label, time, x, y, and correct properties. */
308
+ readonly clicks: {
309
+ readonly type: ParameterType.COMPLEX;
310
+ readonly array: true;
311
+ };
312
+ /** Total time in milliseconds from first click to last correct click. */
313
+ readonly completion_time: {
314
+ readonly type: ParameterType.INT;
315
+ };
316
+ /** Number of errors (incorrect clicks). */
317
+ readonly num_errors: {
318
+ readonly type: ParameterType.INT;
319
+ };
320
+ /** Total path distance in pixels (sum of distances between consecutive correct targets). */
321
+ readonly total_path_distance: {
322
+ readonly type: ParameterType.FLOAT;
323
+ };
324
+ /** Array of response times between consecutive correct clicks. */
325
+ readonly inter_click_times: {
326
+ readonly type: ParameterType.INT;
327
+ readonly array: true;
328
+ };
329
+ };
330
+ };
331
+ constructor(jsPsych: JsPsych);
332
+ trial(display_element: HTMLElement, trial: TrialType<Info>): void;
333
+ private generateTargets;
334
+ private generateLabels;
335
+ private getCorrectSequence;
336
+ private findClickedTarget;
337
+ private drawCanvas;
338
+ private endTrial;
339
+ }
340
+
341
+ export { TrailMakingPlugin as default };