Repository navigation
Expand file tree
/
Copy pathdatasets.html
More file actions
565 lines (531 loc) · 25.5 KB
/
Copy pathdatasets.html
File metadata and controls
565 lines (531 loc) · 25.5 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>PyHealth Datasets — 29 Clinical Datasets</title>
<meta name="description" content="Browse all 27 clinical datasets supported by PyHealth across EHR, biosignals, medical imaging, genomics, and clinical text.">
<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); }
/* ── Dataset grid ── */
.dataset-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
gap: 1rem;
}
.dataset-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.65rem;
transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}
.dataset-card:hover {
border-color: rgba(201,95,38,0.35);
box-shadow: 0 4px 16px rgba(0,0,0,0.07);
transform: translateY(-2px);
}
.dataset-card-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 0.5rem;
}
.dataset-classname {
font-family: "IBM Plex Mono", "Menlo", monospace;
font-size: 0.88rem;
font-weight: 600;
color: var(--ink);
line-height: 1.2;
}
.modality-tag {
flex-shrink: 0;
font-size: 0.72rem;
font-weight: 600;
padding: 0.2rem 0.55rem;
border-radius: 100px;
letter-spacing: 0.04em;
text-transform: uppercase;
}
.mod-ehr { background: rgba(59,130,246,0.12); color: #2563eb; }
.mod-signal { background: rgba(16,185,129,0.12); color: #059669; }
.mod-image { background: rgba(236,72,153,0.12); color: #db2777; }
.mod-genomics { background: rgba(139,92,246,0.12); color: #7c3aed; }
.mod-text { background: rgba(245,158,11,0.12); color: #d97706; }
.mod-other { background: rgba(100,116,139,0.12); color: #475569; }
.dataset-desc {
font-size: 0.86rem;
color: var(--muted);
line-height: 1.5;
margin: 0;
}
/* ── Code block ── */
.dataset-code {
background: #0f1923;
border-radius: 8px;
padding: 0.9rem 1rem;
font-family: "IBM Plex Mono", "Menlo", monospace;
font-size: 0.77rem;
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-num { color: #fab387; }
.tok-op { color: #cdd6f4; }
.tok-cm { color: #585b70; font-style: italic; }
/* ── Card footer ── */
.dataset-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);
}
/* ── Access line and task links (filled from data/*.json) ── */
.dataset-access {
display: flex;
flex-wrap: wrap;
align-items: baseline;
gap: 0.35rem 0.5rem;
font-size: 0.8rem;
color: var(--muted);
line-height: 1.45;
margin: 0;
}
.access-tag {
flex-shrink: 0;
font-size: 0.68rem;
font-weight: 600;
padding: 0.15rem 0.5rem;
border-radius: 100px;
letter-spacing: 0.04em;
text-transform: uppercase;
}
.access-open { background: rgba(16,185,129,0.12); color: #047857; }
.access-restricted { background: rgba(245,158,11,0.14); color: #b45309; }
.access-credentialed { background: rgba(239,68,68,0.12); color: #b91c1c; }
.access-format { background: rgba(0,0,0,0.06); color: var(--muted); }
.dataset-access a { color: var(--accent); text-underline-offset: 2px; }
.dataset-tasks {
font-size: 0.8rem;
color: var(--muted);
line-height: 1.6;
margin: 0;
}
.dataset-tasks a {
display: inline-block;
font-family: "IBM Plex Mono", monospace;
font-size: 0.72rem;
padding: 0.1rem 0.45rem;
margin: 0 0.15rem 0.2rem 0;
border-radius: 100px;
background: rgba(0,0,0,0.05);
color: var(--muted);
text-decoration: none;
}
.dataset-tasks a:hover { background: rgba(59,130,246,0.12); color: #2563eb; }
.dataset-tasks a.more { font-family: inherit; background: none; color: var(--accent); font-weight: 500; }
.dataset-card { scroll-margin-top: 80px; } /* clear the sticky header on #anchor jumps */
.dataset-card:target { outline: 2px solid var(--accent); outline-offset: 2px; }
/* ── 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) {
.dataset-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;">Datasets</span>
</div>
</header>
<main class="site-wrap" style="padding: 2.2rem 0 3.5rem;">
<!-- ── Hero ── -->
<section class="ph-hero">
<p class="ph-eyebrow">PyHealth Datasets</p>
<h1><span id="heroCount">…</span> Clinical Datasets</h1>
<p class="ph-tagline">A unified API for loading healthcare data across electronic health records, physiological signals, medical imaging, genomics, and clinical text — all ready for machine learning.</p>
<div class="ph-cta-row">
<a href="https://colab.research.google.com/drive/1azBqFS_vrJxoYMxP4M_dAIDcrU92uNDv" 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: Datasets (Colab)
</a>
<a href="https://pyhealth.readthedocs.io/en/latest/api/datasets.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 datasets 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 Datasets <span class="count-badge" id="visibleCount">…</span></h2>
<a href="https://pyhealth.readthedocs.io/en/latest/api/datasets.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 datasets: EEG, ICU, chest X-ray, PhysioNet…" aria-label="Search datasets" autocomplete="off">
<div class="catalog-view" id="viewToggle" role="group" aria-label="View as"></div>
</div>
<p class="filter-label">Modality</p>
<div class="filter-bar" role="group" aria-label="Filter by modality" id="filterBar">
<!-- populated by JS after datasets.json loads -->
</div>
<p class="filter-label">Access</p>
<div class="filter-bar" role="group" aria-label="Filter by access" id="accessBar">
<!-- populated by JS after datasets.json loads -->
</div>
<p class="snippet-note" style="margin:0 0 1rem; padding:0.75rem 1rem; border:1px solid var(--line); border-radius:10px; background:var(--paper); font-size:0.9rem; color:var(--muted); line-height:1.55;"><strong style="color:var(--ink);">How to read these snippets.</strong> PyHealth does not ship data: download each dataset from its source, then point <code>root</code> at the folder (or URL) holding the raw files. Each card's badge says what that takes (<strong>Open</strong>: download now; <strong>Restricted</strong>: free, but sign an agreement or request access; <strong>Credentialed</strong>: PhysioNet-style credentialing and training first), and <em>Get the data</em> links to the source. The dataset's docs page has the download command and the folder layout. Add <code>cache_dir="..."</code> to keep the processed copy somewhere you control, and <code>dev=True</code> to try 1,000 patients first. To try the API with no download, use the public synthetic copy: <code>MIMIC3Dataset(root="https://storage.googleapis.com/pyhealth/Synthetic_MIMIC-III", tables=["diagnoses_icd"])</code>. <a href="https://colab.research.google.com/drive/1azBqFS_vrJxoYMxP4M_dAIDcrU92uNDv" target="_blank" rel="noopener">Tutorial 01</a> covers datasets in depth. Snippets checked against PyHealth 2.1.0.</p>
<div class="dataset-grid" id="datasetGrid">
<div id="datasetGridPlaceholder" style="grid-column:1/-1; padding:2rem; text-align:center; color:var(--muted); font-size:0.9rem;">Loading datasets…</div>
</div><!-- /dataset-grid -->
<div class="catalog-table-wrap" id="catalogTable" hidden></div>
<p class="catalog-empty" id="catalogEmpty" hidden>No datasets match. <button type="button" data-clear>Clear the search and filters</button></p>
</section>
<!-- ── Custom Dataset 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 dataset?</h3>
<p style="margin:0 0 0.8rem; font-size:0.88rem; color:var(--muted); line-height:1.55;">PyHealth makes it easy to add your own data source by inheriting <code style="font-family:monospace; font-size:0.85rem; background:rgba(0,0,0,0.05); padding:0.1rem 0.35rem; border-radius:4px;">BaseDataset</code>. Your custom dataset immediately gets access to all PyHealth tasks, models, and the trainer — no extra wiring needed.</p>
<div style="display:flex; gap:0.6rem; flex-wrap:wrap;">
<a href="https://pyhealth.readthedocs.io/en/latest/api/datasets.html#native-datasets-vs-custom-datasets" 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 Dataset 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();
// Cards are built from data/datasets.json (one entry per dataset class;
// scripts/extract_datasets.py keeps it in step with PyHealth) and
// data/tasks.json (which tasks cite each dataset).
const MODALITIES = [
['ehr', 'EHR'], ['signal', 'Biosignal'], ['image', 'Image'],
['genomics', 'Genomics'], ['text', 'Text'], ['other', 'Other'],
];
const MODALITY_LABEL = Object.fromEntries(MODALITIES);
const ACCESS_LABEL = {
open: 'Open', restricted: 'Restricted', credentialed: 'Credentialed', format: 'Format',
};
const TASKS_SHOWN = 6;
const DOCS_URL = 'https://pyhealth.readthedocs.io/en/latest/api/datasets/pyhealth.datasets.';
function escHtml(s) {
return String(s).replace(/[&<>"']/g, c => ({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]));
}
// Highlight a snippet: keywords, the classes it imports, strings, numbers and "=".
function highlight(code) {
const classes = new Set();
code.replace(/^from \S+ import (.+)$/gm, (_, names) =>
names.split(',').forEach(n => classes.add(n.trim())));
return code.replace(/("[^"\n]*")|([A-Za-z_]\w*)|(\d+(?:\.\d+)?)|(=)|([^"\w=]+)/g,
(tok, str, word, num, op) => {
let cls = null;
if (str) cls = 'tok-str';
else if (word === 'from' || word === 'import') cls = 'tok-kw';
else if (word && classes.has(word)) cls = 'tok-cl';
else if (num || word === 'True' || word === 'False' || word === 'None') cls = 'tok-num';
else if (op) cls = 'tok-op';
return cls ? `<span class="${cls}">${escHtml(tok)}</span>` : escHtml(tok);
});
}
function buildCard(cls, info, tasks) {
const modality = MODALITY_LABEL[info.modality] ? info.modality : 'other';
const demo = info.demo_url
? ` · No access yet? Try the <a href="${escHtml(info.demo_url)}" target="_blank" rel="noopener">${escHtml(info.demo_label || 'open demo')}</a>.`
: '';
const access = info.source_url ? `
<p class="dataset-access">
<span class="access-tag access-${escHtml(info.access)}">${ACCESS_LABEL[info.access] || escHtml(info.access)}</span>
<span>${escHtml(info.access_note)}. <a href="${escHtml(info.source_url)}" target="_blank" rel="noopener">Get the data →</a>${demo}</span>
</p>` : '';
// Long task lists stop after TASKS_SHOWN and link to the tasks page,
// filtered to this dataset.
const more = tasks.length > TASKS_SHOWN
? `<a class="more" href="tasks.html?dataset=${encodeURIComponent(cls)}">All ${tasks.length} tasks →</a>`
: '';
const taskLinks = tasks.length ? `
<p class="dataset-tasks"><strong>Tasks:</strong> ${tasks.slice(0, TASKS_SHOWN).map(task =>
`<a href="tasks.html#${escHtml(task.class_name)}" title="${escHtml(task.class_name)}">${escHtml(task.display_name || task.class_name)}</a>`
).join('')}${more}</p>` : '';
const example = info.example_url
? `\n <a href="${escHtml(info.example_url)}" class="example-link" target="_blank" rel="noopener">Example →</a>`
: '';
return `
<div class="dataset-card" id="${escHtml(cls)}" data-modality="${modality}" data-access="${escHtml(info.source_url ? info.access || '' : '')}" data-task-count="${tasks.length}">
<div class="dataset-card-header">
<span class="dataset-classname">${escHtml(cls)}</span>
<span class="modality-tag mod-${modality}">${MODALITY_LABEL[modality]}</span>
</div>
<p class="dataset-desc">${escHtml(info.description || '')}</p>${access}
<pre class="dataset-code">${highlight(info.snippet || '')}</pre>${taskLinks}
<div class="dataset-card-footer">
<a href="${escHtml(info.docs_url || `${DOCS_URL}${cls}.html`)}" class="docs-link" target="_blank" rel="noopener">Docs →</a>${example}
</div>
</div>`;
}
(async function render() {
const grid = document.getElementById('datasetGrid');
const placeholder = document.getElementById('datasetGridPlaceholder');
try {
const [d, t] = await Promise.all([fetch('data/datasets.json'), fetch('data/tasks.json')]);
if (!d.ok) throw new Error('Failed to load dataset data');
const datasets = await d.json();
// Cards still render without task links, so this file is optional.
const tasks = t.ok ? await t.json() : [];
const byDataset = {};
tasks.forEach(task => (task.dataset_classes || []).forEach(cls => {
(byDataset[cls] = byDataset[cls] || []).push(task);
}));
const tasksFor = cls => {
const seen = new Set();
return [cls, ...(Catalog.RELATED[cls] || [])].flatMap(c => byDataset[c] || [])
.filter(task => !seen.has(task.class_name) && seen.add(task.class_name))
.sort((a, b) => (a.display_name || a.class_name).localeCompare(b.display_name || b.class_name));
};
// Cards follow file order; entries with an anchor have no card of their own.
const entries = Object.entries(datasets).filter(([, info]) => !info.anchor);
placeholder.remove();
grid.insertAdjacentHTML('beforeend',
entries.map(([cls, info]) => buildCard(cls, info, tasksFor(cls))).join(''));
const cards = grid.querySelectorAll('.dataset-card');
document.getElementById('heroCount').textContent = cards.length;
document.title = document.title.replace(/\d+/, cards.length);
Catalog.init({
grid, cards: '.dataset-card',
count: document.getElementById('visibleCount'),
search: document.getElementById('catalogSearch'),
empty: document.getElementById('catalogEmpty'),
facets: [
{ key: 'modality', attr: 'modality', el: document.getElementById('filterBar'), options: MODALITIES },
{ key: 'access', attr: 'access', el: document.getElementById('accessBar'),
options: Object.entries(ACCESS_LABEL) },
],
table: {
el: document.getElementById('catalogTable'), toggle: document.getElementById('viewToggle'),
columns: [
{ key: 'dataset', label: 'Dataset', cell: el => Catalog.name(el, el.id) },
{ key: 'modality', label: 'Modality', cell: el => el.querySelector('.modality-tag').outerHTML },
{ key: 'access', label: 'Access', cell: el => (el.querySelector('.access-tag') || {}).outerHTML || '' },
{ key: 'tasks', label: 'Tasks', sort: el => Number(el.dataset.taskCount),
cell: el => Number(el.dataset.taskCount)
? `<span class="cell-links"><a href="tasks.html?dataset=${encodeURIComponent(el.id)}">${el.dataset.taskCount}</a></span>` : '' },
{ label: 'Description', cell: el => `<span class="cell-desc">${escHtml(el.querySelector('.dataset-desc').textContent)}</span>` },
{ label: 'Links', cell: el => `<span class="cell-links">${Catalog.links(el,
[['.dataset-access a', 'Get the data'], ['.docs-link', 'Docs'], ['.example-link', 'Example']])}</span>` },
],
},
});
// Cards are rendered after load, so jump to #ClassName ourselves.
const target = location.hash && document.getElementById(decodeURIComponent(location.hash.slice(1)));
if (target) target.scrollIntoView();
} catch (err) {
placeholder.textContent = 'Could not load dataset data. Check data/datasets.json for errors.';
console.error(err);
}
})();
</script>
</body>
</html>