Repository navigation
Expand file tree
/
Copy pathtasks.html
More file actions
597 lines (556 loc) · 26.1 KB
/
Copy pathtasks.html
File metadata and controls
597 lines (556 loc) · 26.1 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>PyHealth Tasks — Clinical Prediction Tasks</title>
<meta name="description" content="Browse all clinical prediction tasks supported by PyHealth across mortality, readmission, drug recommendation, sleep staging, imaging, and genomics.">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600&family=Source+Serif+4:opsz,wght@8..60,500;8..60,600&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/styles.css">
<style>
/* ── Hero ── */
.ph-hero {
background: linear-gradient(140deg, #1c2b3a 0%, #28425e 60%, #1e3348 100%);
border-radius: 16px;
padding: 3rem 2.4rem 2.8rem;
color: white;
position: relative;
overflow: hidden;
border: 1px solid rgba(255,255,255,0.07);
box-shadow: 0 20px 48px rgba(22, 33, 31, 0.18);
animation: rise 420ms ease;
}
.ph-hero::before {
content: "";
position: absolute;
top: -80px; right: -80px;
width: 340px; height: 340px;
border-radius: 50%;
background: radial-gradient(circle, rgba(201,95,38,0.22) 0%, transparent 70%);
pointer-events: none;
}
.ph-hero::after {
content: "";
position: absolute;
bottom: -100px; left: -60px;
width: 280px; height: 280px;
border-radius: 50%;
background: radial-gradient(circle, rgba(90,160,230,0.1) 0%, transparent 70%);
pointer-events: none;
}
.ph-eyebrow {
font-size: 0.8rem;
font-weight: 600;
letter-spacing: 0.1em;
text-transform: uppercase;
color: rgba(201,95,38,0.9);
margin: 0 0 0.6rem;
}
.ph-hero h1 {
color: white;
font-size: clamp(2rem, 4.5vw, 3.2rem);
margin: 0 0 0.5rem;
letter-spacing: -0.01em;
}
.ph-tagline {
color: rgba(255,255,255,0.72);
font-size: 1.05rem;
line-height: 1.55;
max-width: 600px;
margin: 0 0 1.8rem;
}
.ph-cta-row {
display: flex;
gap: 0.7rem;
flex-wrap: wrap;
position: relative;
z-index: 1;
}
.ph-btn {
display: inline-flex;
align-items: center;
gap: 0.5rem;
text-decoration: none;
border-radius: 10px;
padding: 0.64rem 1.15rem;
font-size: 0.95rem;
font-weight: 500;
font-family: "IBM Plex Sans", sans-serif;
transition: filter 0.15s, transform 0.1s;
}
.ph-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.ph-btn.primary {
background: var(--accent);
color: white;
border: 1px solid rgba(255,255,255,0.1);
box-shadow: 0 4px 12px rgba(201,95,38,0.35);
}
.ph-btn.outline {
background: rgba(255,255,255,0.09);
color: rgba(255,255,255,0.9);
border: 1px solid rgba(255,255,255,0.22);
backdrop-filter: blur(6px);
}
/* ── Growing notice ── */
.growing-notice {
display: inline-flex;
align-items: center;
gap: 0.5rem;
background: rgba(255,255,255,0.07);
border: 1px solid rgba(255,255,255,0.15);
border-radius: 100px;
padding: 0.4rem 1rem;
font-size: 0.82rem;
color: rgba(255,255,255,0.7);
margin-top: 1.4rem;
position: relative;
z-index: 1;
}
.growing-notice .dot {
width: 6px; height: 6px;
border-radius: 50%;
background: #4ade80;
box-shadow: 0 0 0 2px rgba(74,222,128,0.3);
animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
0%, 100% { box-shadow: 0 0 0 2px rgba(74,222,128,0.3); }
50% { box-shadow: 0 0 0 5px rgba(74,222,128,0.1); }
}
/* ── Filter bar ── */
.filter-bar {
display: flex;
gap: 0.45rem;
flex-wrap: wrap;
margin-bottom: 1.5rem;
animation: rise 380ms ease;
}
.filter-btn {
font-family: "IBM Plex Sans", sans-serif;
font-size: 0.83rem;
font-weight: 500;
padding: 0.38rem 0.85rem;
border-radius: 100px;
border: 1.5px solid var(--line);
background: var(--paper);
color: var(--muted);
cursor: pointer;
transition: all 0.15s;
}
.filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.filter-btn.active { background: var(--accent); color: white; border-color: var(--accent); }
/* ── Task grid ── */
.task-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
gap: 1rem;
}
.task-card {
background: var(--paper);
border: 1px solid var(--line);
border-radius: 14px;
padding: 1.3rem 1.4rem 1.2rem;
display: flex;
flex-direction: column;
gap: 0.6rem;
transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}
.task-card:hover {
border-color: rgba(201,95,38,0.35);
box-shadow: 0 4px 16px rgba(0,0,0,0.07);
transform: translateY(-2px);
}
.task-card-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 0.5rem;
}
.task-title {
font-family: "Source Serif 4", Georgia, serif;
font-size: 1rem;
font-weight: 600;
color: var(--ink);
line-height: 1.25;
margin: 0;
}
.task-classname {
font-family: "IBM Plex Mono", "Menlo", monospace;
font-size: 0.74rem;
color: var(--muted);
margin: 0;
}
/* Output type pill */
.output-tag {
flex-shrink: 0;
font-size: 0.7rem;
font-weight: 600;
padding: 0.18rem 0.5rem;
border-radius: 100px;
letter-spacing: 0.04em;
text-transform: uppercase;
}
.out-binary { background: rgba(59,130,246,0.12); color: #2563eb; }
.out-multiclass { background: rgba(16,185,129,0.12); color: #059669; }
.out-multilabel { background: rgba(139,92,246,0.12); color: #7c3aed; }
.out-regression { background: rgba(245,158,11,0.12); color: #d97706; }
.out-recommend { background: rgba(236,72,153,0.12); color: #db2777; }
.out-generative { background: rgba(201,95,38,0.12); color: #c2410c; }
.out-survival { background: rgba(20,184,166,0.12); color: #0d9488; }
.out-segmentation { background: rgba(14,165,233,0.12); color: #0284c7; }
.out-other { background: rgba(100,116,139,0.12); color: #475569; }
/* Dataset pill */
.dataset-pill {
display: inline-block;
font-size: 0.72rem;
font-weight: 500;
padding: 0.15rem 0.5rem;
border-radius: 100px;
background: rgba(0,0,0,0.05);
color: var(--muted);
font-family: "IBM Plex Mono", monospace;
}
a.dataset-pill { text-decoration: none; }
a.dataset-pill:hover { background: rgba(59,130,246,0.12); color: #2563eb; }
.task-card { scroll-margin-top: 80px; } /* clear the sticky header on #anchor jumps */
.task-card:target { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Modality pills */
.mod-pill {
display: inline-block;
font-size: 0.7rem;
font-weight: 600;
padding: 0.15rem 0.5rem;
border-radius: 100px;
letter-spacing: 0.02em;
}
.mod-ehr { background: rgba(99,102,241,0.12); color: #4f46e5; }
.mod-timeseries { background: rgba(20,184,166,0.12); color: #0d9488; }
.mod-image { background: rgba(139,92,246,0.12); color: #7c3aed; }
.mod-text { background: rgba(245,158,11,0.12); color: #d97706; }
.mod-signal { background: rgba(34,197,94,0.12); color: #16a34a; }
.mod-audio { background: rgba(236,72,153,0.12); color: #db2777; }
.mod-genomics { background: rgba(6,182,212,0.12); color: #0891b2; }
.mod-graph { background: rgba(249,115,22,0.12); color: #ea580c; }
.task-desc {
font-size: 0.85rem;
color: var(--muted);
line-height: 1.5;
margin: 0;
}
/* Code block */
.task-code {
background: #0f1923;
border-radius: 8px;
padding: 0.85rem 1rem;
font-family: "IBM Plex Mono", "Menlo", monospace;
font-size: 0.75rem;
line-height: 1.65;
color: #cdd6f4;
overflow-x: auto;
margin: 0;
white-space: pre;
}
.tok-kw { color: #89b4fa; }
.tok-cl { color: #cba6f7; }
.tok-fn { color: #89dceb; }
.tok-str { color: #a6e3a1; }
.tok-cm { color: #585b70; font-style: italic; }
/* Card footer */
.task-card-footer {
display: flex;
gap: 0.6rem;
flex-wrap: wrap;
margin-top: auto;
padding-top: 0.3rem;
}
.colab-link, .docs-link, .example-link {
font-size: 0.8rem;
font-weight: 500;
text-decoration: none;
padding: 0.28rem 0.7rem;
border-radius: 6px;
transition: opacity 0.15s;
}
.colab-link:hover, .docs-link:hover, .example-link:hover { opacity: 0.8; }
.colab-link {
background: rgba(234,88,12,0.1);
color: #c95f26;
border: 1px solid rgba(201,95,38,0.25);
}
.docs-link {
background: rgba(59,130,246,0.08);
color: #2563eb;
border: 1px solid rgba(59,130,246,0.2);
}
.example-link {
background: rgba(16,185,129,0.08);
color: #059669;
border: 1px solid rgba(16,185,129,0.2);
}
/* Count badge */
.count-badge {
display: inline-block;
background: var(--accent);
color: white;
font-size: 0.78rem;
font-weight: 600;
padding: 0.15rem 0.55rem;
border-radius: 100px;
margin-left: 0.5rem;
vertical-align: middle;
}
@media (max-width: 500px) {
.task-grid { grid-template-columns: 1fr; }
}
</style>
<link rel="icon" href="/favicon.ico" sizes="any">
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
<link rel="icon" href="/favicon-32x32.png" type="image/png" sizes="32x32">
<link rel="apple-touch-icon" href="/apple-touch-icon.png" sizes="180x180">
</head>
<body>
<header class="site-header">
<div class="site-wrap header-inner">
<nav class="nav" aria-label="Main navigation">
<a href="index.html" class="back-link">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"/></svg>
PyHealth
</a>
</nav>
<span style="color: var(--muted); font-size: 0.88rem; font-weight: 500;">Tasks</span>
</div>
</header>
<main class="site-wrap" style="padding: 2.2rem 0 3.5rem;">
<!-- ── Hero ── -->
<section class="ph-hero">
<p class="ph-eyebrow">PyHealth Tasks</p>
<h1><span id="heroTaskCount">…</span> Clinical Tasks</h1>
<p class="ph-tagline">Standardized clinical prediction task definitions — from mortality and readmission to drug recommendation, sleep staging, and genomic analysis. Call <code style="font-family:monospace; background:rgba(255,255,255,0.1); padding:0.1rem 0.4rem; border-radius:4px;">dataset.set_task()</code> and you're ready to train.</p>
<div class="ph-cta-row">
<a href="https://colab.research.google.com/drive/1ndi6HGnC_l_1s23LUmzcICPgfc-cJn2N" class="ph-btn primary" target="_blank" rel="noopener">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="5 3 19 12 5 21 5 3"/></svg>
Tutorial: Tasks and Processors (Colab)
</a>
<a href="https://pyhealth.readthedocs.io/en/latest/api/tasks.html" class="ph-btn outline" target="_blank" rel="noopener">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20"/><path d="M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"/></svg>
API Reference
</a>
</div>
<div class="growing-notice">
<span class="dot"></span>
Actively growing — new tasks added regularly. <a href="https://docs.google.com/spreadsheets/d/1PNMgDe-llOm1SM5ZyGLkmPysjC4wwaVblPLAHLxejTw/edit#gid=159213380" target="_blank" rel="noopener" style="color:rgba(255,255,255,0.85); text-decoration:underline; text-underline-offset:2px;">View planned additions →</a>
</div>
</section>
<!-- ── Filter + Grid ── -->
<section class="page-section fade-up">
<div style="display:flex; align-items:baseline; justify-content:space-between; flex-wrap:wrap; gap:0.5rem; margin-bottom:1.2rem;">
<h2 class="section-h2" style="margin:0;">Browse Tasks <span class="count-badge" id="visibleCount">…</span></h2>
<a href="https://pyhealth.readthedocs.io/en/latest/api/tasks.html" target="_blank" rel="noopener" style="font-size:0.85rem; color:var(--accent); text-decoration:none; font-weight:500;">Full API reference →</a>
</div>
<div class="catalog-tools">
<input type="search" class="catalog-search" id="catalogSearch" placeholder="Search tasks: mortality, sepsis, ECG, MIMIC-IV…" aria-label="Search tasks" autocomplete="off">
<select class="catalog-select" id="datasetFilter" aria-label="Filter by dataset"></select>
<div class="catalog-view" id="viewToggle" role="group" aria-label="View as"></div>
</div>
<p class="filter-label">Output type</p>
<div class="filter-bar" role="group" aria-label="Filter by output type" id="filterBar">
<!-- populated by JS after tasks.json loads -->
</div>
<p class="filter-label">Input modality</p>
<div class="filter-bar" role="group" aria-label="Filter by input modality" id="modalityBar">
<!-- populated by JS after tasks.json loads -->
</div>
<div class="task-grid" id="taskGrid">
<div id="taskGridPlaceholder" style="grid-column:1/-1; padding:2rem; text-align:center; color:var(--muted); font-size:0.9rem;">Loading tasks…</div>
</div><!-- /task-grid -->
<div class="catalog-table-wrap" id="catalogTable" hidden></div>
<p class="catalog-empty" id="catalogEmpty" hidden>No tasks match. <button type="button" data-clear>Clear the search and filters</button></p>
</section>
<!-- ── Custom Task Note ── -->
<section class="page-section fade-up">
<div style="background:var(--paper); border:1px solid var(--line); border-radius:14px; padding:1.6rem 1.8rem; display:flex; gap:1.2rem; align-items:flex-start;">
<div style="flex-shrink:0; width:40px; height:40px; border-radius:10px; background:rgba(201,95,38,0.1); display:flex; align-items:center; justify-content:center;">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="var(--accent)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>
</div>
<div>
<h3 style="margin:0 0 0.4rem; font-size:1rem;">Need a custom task?</h3>
<p style="margin:0 0 0.8rem; font-size:0.88rem; color:var(--muted); line-height:1.55;">Defining a new clinical prediction task in PyHealth takes minutes. Specify your input features and output label schema, and <code style="font-family:monospace; font-size:0.85rem; background:rgba(0,0,0,0.05); padding:0.1rem 0.35rem; border-radius:4px;">dataset.set_task()</code> handles the rest — including batching, tokenization, and dataloader creation.</p>
<div style="display:flex; gap:0.6rem; flex-wrap:wrap;">
<a href="https://pyhealth.readthedocs.io/en/latest/api/tasks.html#writing-a-custom-task" target="_blank" rel="noopener" style="font-size:0.83rem; font-weight:500; color:var(--accent); text-decoration:none; padding:0.3rem 0.75rem; border:1.5px solid rgba(201,95,38,0.3); border-radius:7px; transition:background 0.15s;" onmouseover="this.style.background='rgba(201,95,38,0.07)'" onmouseout="this.style.background=''">Custom Task Guide →</a>
<a href="https://github.com/sunlabuiuc/PyHealth" target="_blank" rel="noopener" style="font-size:0.83rem; font-weight:500; color:var(--muted); text-decoration:none; padding:0.3rem 0.75rem; border:1.5px solid var(--line); border-radius:7px; transition:background 0.15s;" onmouseover="this.style.background='rgba(0,0,0,0.03)'" onmouseout="this.style.background=''">View Source on GitHub →</a>
</div>
</div>
</div>
</section>
</main>
<footer class="site-footer">
<div class="site-wrap" style="display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:0.5rem;">
<span>Copyright <span id="year"></span> PyHealth Team</span>
<a href="index.html" style="color:var(--accent); text-decoration:none; font-size:0.9rem;">← Back to PyHealth</a>
</div>
</footer>
<script src="assets/js/catalog.js"></script>
<script>
document.getElementById('year').textContent = new Date().getFullYear();
// ── Output type display config ──────────────────────────────────────────
const OUTPUT_LABELS = {
binary: { label: 'Binary', cls: 'out-binary' },
multiclass: { label: 'Multiclass', cls: 'out-multiclass' },
multilabel: { label: 'Multilabel', cls: 'out-multilabel' },
regression: { label: 'Regression', cls: 'out-regression' },
recommend: { label: 'Recommendation', cls: 'out-recommend' },
generative: { label: 'Generative', cls: 'out-generative' },
survival: { label: 'Survival', cls: 'out-survival' },
segmentation: { label: 'Segmentation', cls: 'out-segmentation' },
other: { label: 'Other', cls: 'out-other' },
};
// ── Modality display config ─────────────────────────────────────────────
const MODALITY_LABEL = {
ehr: 'EHR Codes',
timeseries: 'Timeseries',
image: 'Image',
text: 'Text / NLP',
signal: 'Signal',
audio: 'Audio',
genomics: 'Genomics',
graph: 'Graph',
};
// ── Escape HTML to avoid XSS from JSON data ─────────────────────────────
function esc(str) {
return String(str ?? '').replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"');
}
// ── Build one task card ─────────────────────────────────────────────────
// Dataset class -> {label, anchor, ...} from data/datasets.json.
let DATASETS = {};
// Dataset pills link to the dataset's card on datasets.html. They come
// from dataset_classes (read from the task docstring by
// scripts/extract_metadata.py); hand-written labels are the fallback.
function datasetPills(task) {
const seen = new Set();
const pills = (task.dataset_classes || []).map(cls => {
const info = DATASETS[cls];
const label = info ? info.label : cls;
if (seen.has(label)) return '';
seen.add(label);
const anchor = (info && info.anchor) || cls;
return `<a class="dataset-pill" href="datasets.html#${esc(anchor)}" title="${esc(cls)}">${esc(label)}</a>`;
}).filter(Boolean);
if (pills.length) return pills.join(' ');
return (task.datasets || []).map(d =>
`<span class="dataset-pill">${esc(d)}</span>`
).join(' ');
}
function buildCard(task) {
const displayName = task.display_name || task.class_name;
const type = task.output_type || 'other';
const cfg = OUTPUT_LABELS[type] || { label: type, cls: 'out-other' };
const datasets = datasetPills(task);
const modalities = (task.modality || []).join(' ');
const modPills = (task.modality || []).map(m =>
`<span class="mod-pill mod-${esc(m)}">${esc(MODALITY_LABEL[m] || m)}</span>`
).join(' ');
const dc = esc(task.display_class || task.class_name);
const codeHtml =
`<span class="tok-kw">from</span> pyhealth.tasks ` +
`<span class="tok-kw">import</span> <span class="tok-cl">${dc}</span>\n` +
`samples <span class="tok-op">=</span> dataset.<span class="tok-fn">set_task</span>` +
`(<span class="tok-cl">${dc}</span>(${task.init_args ? esc(task.init_args) : ''}))` +
(task.requires ? `\n<span class="tok-cm"># needs: ${esc(task.requires)}</span>` : '');
return `
<div class="task-card" id="${esc(task.class_name)}" data-type="${esc(type)}" data-modality="${esc(modalities)}" data-datasets="${esc(datasetKeys(task).join(' '))}">
<div class="task-card-header">
<div>
<p class="task-title">${esc(displayName)}</p>
<p class="task-classname">${dc}</p>
</div>
<span class="output-tag ${cfg.cls}">${cfg.label}</span>
</div>
<div>${datasets}${modPills ? ' ' + modPills : ''}</div>
<p class="task-desc">${esc(task.description)}</p>
<pre class="task-code">${codeHtml}</pre>
<div class="task-card-footer">
${task.colab_url ? `<a href="${esc(task.colab_url)}" class="colab-link" target="_blank" rel="noopener">Open in Colab →</a>` : ''}
<a href="${esc(task.docs_url || 'https://pyhealth.readthedocs.io/en/latest/api/tasks.html')}" class="docs-link" target="_blank" rel="noopener">Docs →</a>
${task.example_url ? `<a href="${esc(task.example_url)}" class="example-link" target="_blank" rel="noopener">Example →</a>` : ''}
</div>
</div>`;
}
// ── Filters ─────────────────────────────────────────────────────────────
// Output-type buttons, in this order; a task with none counts as Other.
const OUTPUT_ORDER = ['binary', 'multiclass', 'multilabel', 'recommend', 'regression',
'generative', 'survival', 'segmentation', 'other'];
// The datasets a task is listed under: those it cites, and the datasets
// that roll them up (MIMIC4EHRDataset tasks are also MIMIC4Dataset tasks).
function datasetKeys(task) {
return [...new Set((task.dataset_classes || []).flatMap(Catalog.withRelated))];
}
// One option per dataset class, sorted by label; classes that share a
// label (MIMIC4Dataset and MIMIC4EHRDataset) also show the class name.
function datasetOptions(tasks) {
const classes = [...new Set(tasks.flatMap(datasetKeys))];
const label = cls => (DATASETS[cls] && DATASETS[cls].label) || cls;
const shared = l => classes.filter(cls => label(cls) === l).length > 1;
return classes.map(cls => [cls, shared(label(cls)) ? `${label(cls)} · ${cls}` : label(cls)])
.sort((a, b) => a[1].localeCompare(b[1]));
}
// A table cell holding copies of the card's pills.
function tags(el, selector) {
return `<span class="cell-tags">${[...el.querySelectorAll(selector)].map(t => t.outerHTML).join('')}</span>`;
}
// ── Load and render ─────────────────────────────────────────────────────
(async function () {
const grid = document.getElementById('taskGrid');
const placeholder = document.getElementById('taskGridPlaceholder');
try {
const [res, dsRes] = await Promise.all([
fetch('data/tasks.json'),
fetch('data/datasets.json'),
]);
if (!res.ok) throw new Error('Failed to load task data');
const tasks = await res.json();
// Links still work without the labels, so this file is optional.
if (dsRes.ok) DATASETS = await dsRes.json();
// Render cards
placeholder.remove();
grid.insertAdjacentHTML('beforeend', tasks.map(buildCard).join(''));
document.getElementById('heroTaskCount').textContent = tasks.length;
Catalog.init({
grid, cards: '.task-card',
count: document.getElementById('visibleCount'),
search: document.getElementById('catalogSearch'),
empty: document.getElementById('catalogEmpty'),
facets: [
{ key: 'dataset', attr: 'datasets', kind: 'select', all: 'All datasets',
el: document.getElementById('datasetFilter'), options: datasetOptions(tasks) },
{ key: 'type', attr: 'type', el: document.getElementById('filterBar'),
options: OUTPUT_ORDER.map(type => [type, OUTPUT_LABELS[type].label]) },
{ key: 'modality', attr: 'modality', el: document.getElementById('modalityBar'),
options: Object.entries(MODALITY_LABEL) },
],
table: {
el: document.getElementById('catalogTable'), toggle: document.getElementById('viewToggle'),
columns: [
{ key: 'task', label: 'Task',
cell: el => Catalog.name(el, el.querySelector('.task-title').textContent, el.querySelector('.task-classname').textContent),
sort: el => el.querySelector('.task-title').textContent.toLowerCase() },
{ key: 'output', label: 'Output', cell: el => el.querySelector('.output-tag').outerHTML },
{ key: 'modality', label: 'Modality', cell: el => tags(el, '.mod-pill') },
{ key: 'datasets', label: 'Datasets', cell: el => tags(el, '.dataset-pill') },
{ label: 'Links', cell: el => `<span class="cell-links">${Catalog.links(el,
[['.colab-link', 'Colab'], ['.docs-link', 'Docs'], ['.example-link', 'Example']])}</span>` },
],
},
});
// Cards are rendered after load, so jump to #TaskName ourselves.
const target = location.hash && document.getElementById(location.hash.slice(1));
if (target) target.scrollIntoView();
} catch (err) {
placeholder.textContent = 'Could not load task data. Check data/tasks.json for errors.';
console.error(err);
}
})();
</script>
</body>
</html>