Laibaff7 commited on
Commit
dfe6df8
·
verified ·
1 Parent(s): 0063d6d

Upload 4 files

Browse files
.gitattributes CHANGED
@@ -58,3 +58,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
 
 
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
61
+ hf_emr_explorer/data.json filter=lfs diff=lfs merge=lfs -text
hf_emr_explorer/.gitattributes ADDED
@@ -0,0 +1 @@
 
 
1
+ data.json filter=lfs diff=lfs merge=lfs -text
hf_emr_explorer/README.md ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: EMR Explorer
3
+ sdk: static
4
+ ---
5
+
6
+ # EMR Explorer (CDA channels 650-1018)
7
+
8
+ Interactive Hugging Face Space for exploring the **VQ-VAE latent space** of Cassini
9
+ Cosmic Dust Analyzer (CDA) TOF mass spectra in the high-mass / **Extended Mass Range**
10
+ region (channels 650-1018). Built as a **static** Space: a single `index.html` that
11
+ loads its data from `data.json` at runtime.
12
+
13
+ ## Features
14
+ - **Projections:** toggle between t-SNE and UMAP of the latent space.
15
+ - **Coloring:** by Base Model Error, Error Bands, or Outlier score.
16
+ - **Top-outliers strip:** one-click jump to the highest-outlier samples.
17
+ - **Interactive spectra:** click any point to view its raw, processed, and
18
+ reconstructed spectrum (channels 650-1018).
19
+
20
+ ## Files (all required -- do not skip `data.json`)
21
+ - `index.html` -- the app (does `fetch('data.json')` on load).
22
+ - `data.json` (~60 MB) -- 10,000 sub-sampled spectra, latent coordinates, and scores.
23
+ This is a large file and is tracked with **Git LFS**.
24
+ - `README.md` -- this file (defines the Space; `sdk: static`).
25
+ - `.gitattributes` -- marks `data.json` for Git LFS.
26
+
27
+ ## Run locally
28
+ ```bash
29
+ cd hf_emr_explorer
30
+ python -m http.server 8000
31
+ # open http://localhost:8000
32
+ ```
33
+
34
+ ## Upload to a Hugging Face Space
35
+ 1. Go to https://huggingface.co/spaces and click **New Space**.
36
+ 2. Name it (e.g. `emr-explorer`) and set the SDK to **Static** (taken from this README).
37
+ 3. In the Space's **Files** tab, upload **all four**: `index.html`, `data.json`,
38
+ `README.md`, and `.gitattributes`.
39
+ - Or via CLI (from inside this folder):
40
+ `huggingface-cli upload <you>/emr-explorer . --repo-type space`
41
+ 4. `data.json` (~60 MB) is tracked with Git LFS, so the Space takes a moment to build.
42
+
43
+ > The app shows "Error loading data.json" if `data.json` is missing -- always upload it.
hf_emr_explorer/data.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e2fd39df31f94bea13a99a8e221e864aeec7b02b82a1831518b47f20a2e69ceb
3
+ size 60363321
hf_emr_explorer/index.html ADDED
@@ -0,0 +1,383 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>EMR Explorer &mdash; CDA 650-1018</title>
7
+ <script src="https://cdn.plot.ly/plotly-2.32.0.min.js" charset="utf-8"></script>
8
+ <style>
9
+ *{box-sizing:border-box;margin:0;padding:0;}
10
+ html,body{height:100%;overflow:hidden;}
11
+ body{
12
+ font-family:"Segoe UI",system-ui,Arial,sans-serif;
13
+ background:#0d0f1a;color:#d8dce8;
14
+ display:flex;flex-direction:column;
15
+ }
16
+ #hdr{
17
+ flex-shrink:0;
18
+ display:flex;align-items:center;gap:14px;
19
+ padding:9px 18px;
20
+ background:#111422;
21
+ border-bottom:1px solid #232640;
22
+ }
23
+ #hdr h1{font-size:1rem;font-weight:700;color:#7fa8f7;letter-spacing:.02em;}
24
+ .sub{font-size:.75rem;color:#555e7a;}
25
+ .ctrls{display:flex;gap:6px;margin-left:auto;align-items:center;flex-wrap:wrap;}
26
+ .lbl{font-size:.72rem;color:#555e7a;}
27
+ .sep{width:1px;height:18px;background:#232640;margin:0 4px;}
28
+ .btn{
29
+ padding:4px 11px;border-radius:5px;
30
+ border:1px solid #2d3355;background:#181b2e;
31
+ color:#9ba8d0;font-size:.72rem;cursor:pointer;
32
+ transition:background .15s,color .15s;
33
+ }
34
+ .btn:hover{background:#222744;}
35
+ .btn.on{background:#2e3d7a;border-color:#4a5da8;color:#c0ccff;}
36
+ #main{flex:1;display:flex;min-height:0;min-width:0;}
37
+ #left{
38
+ flex:0 0 60%;display:flex;flex-direction:column;
39
+ border-right:1px solid #232640;
40
+ position: relative;min-width:0;
41
+ }
42
+ #loading{
43
+ position: absolute; top:0; left:0; width:100%; height:100%;
44
+ background: rgba(13, 15, 26, 0.9); display:flex;
45
+ justify-content:center; align-items:center; z-index:10;
46
+ font-size: 1.2rem; font-weight: bold; color: #7fa8f7;
47
+ }
48
+ #right{flex:1;display:flex;flex-direction:column;min-width:0;}
49
+ .ptitle{
50
+ flex-shrink:0;font-size:.65rem;letter-spacing:.08em;text-transform:uppercase;
51
+ padding:5px 12px;background:#0f1120;color:#454d6a;border-bottom:1px solid #1c1f35;
52
+ }
53
+ #scatter{flex:1;min-height:0;min-width:0;overflow:hidden;}
54
+ #spec-wrap{flex:1;min-height:0;min-width:0;display:flex;flex-direction:column;gap:0;}
55
+ #spec-orig{flex:1;min-height:0;min-width:0;border-bottom:1px solid #1c1f35;overflow:hidden;}
56
+ #spec-overlay{flex:1;min-height:0;min-width:0;overflow:hidden;}
57
+ #info{
58
+ flex-shrink:0;padding:6px 14px;background:#0f1120;
59
+ border-top:1px solid #1c1f35;font-size:.73rem;color:#6b7280;min-height:28px;
60
+ }
61
+ #hint{
62
+ display:flex;flex-direction:column;align-items:center;justify-content:center;
63
+ height:100%;gap:10px;color:#2a3050;font-size:.88rem;pointer-events:none;
64
+ }
65
+ #hint svg{width:44px;height:44px;}
66
+ #topout-strip{
67
+ flex-shrink:0; height:36px; overflow-x:auto; overflow-y:hidden; white-space:nowrap;
68
+ background:#0f1120; border-top:1px solid #1c1f35;
69
+ display:flex; align-items:center; gap:6px; padding:0 10px;
70
+ }
71
+ #topout-strip > *{flex-shrink:0;}
72
+ #topout-strip .lbl{white-space:nowrap;}
73
+ .tchip{
74
+ padding:2px 8px;border-radius:4px;border:1px solid #2d3355;background:#181b2e;
75
+ color:#9ba8d0;font-size:.7rem;cursor:pointer;white-space:nowrap;
76
+ }
77
+ .tchip:hover{background:#2e3d7a;color:#c0ccff;}
78
+ </style>
79
+ </head>
80
+ <body>
81
+
82
+ <div id="hdr">
83
+ <h1>EMR Explorer &mdash; CDA channels 650-1018</h1>
84
+ <span class="sub">n=10,000 random samples &nbsp;&middot;&nbsp; 368-pt spectra</span>
85
+ <div class="ctrls">
86
+ <span class="lbl">Proj.</span>
87
+ <button class="btn on" id="bt-tsne" onclick="setProj('tsne')">t-SNE</button>
88
+ <button class="btn" id="bt-umap" onclick="setProj('umap')">UMAP</button>
89
+ <div class="sep"></div>
90
+ <span class="lbl">Colour</span>
91
+ <button class="btn on" id="bt-base-err" onclick="setCol('base-err')">Base Err</button>
92
+ <button class="btn" id="bt-base-band" onclick="setCol('base-band')">Base Band</button>
93
+ <button class="btn" id="bt-outlier" onclick="setCol('outlier')">Outlier</button>
94
+ <div class="sep"></div>
95
+ <span class="lbl">Highlight top</span>
96
+ <select id="sel-topn" class="btn" onchange="setTopN(this.value)">
97
+ <option value="0" selected>off</option>
98
+ <option value="50">50</option>
99
+ <option value="100">100</option>
100
+ <option value="500">500</option>
101
+ </select>
102
+ <div class="sep"></div>
103
+ <span class="lbl">Colormap</span>
104
+ <button class="btn on" id="bt-cmap-def" onclick="setCmap('default')">Default</button>
105
+ <button class="btn" id="bt-cmap-cb" onclick="setCmap('cb')">Colorblind</button>
106
+ </div>
107
+ </div>
108
+
109
+ <div id="main">
110
+ <div id="left">
111
+ <div id="loading">Loading embedded data... please wait.</div>
112
+ <div class="ptitle">Latent Space &mdash; click a point to inspect its spectrum</div>
113
+ <div id="scatter"></div>
114
+ <div id="topout-strip"></div>
115
+ </div>
116
+ <div id="right">
117
+ <div class="ptitle">Spectrum Viewer</div>
118
+ <div id="spec-wrap">
119
+ <div id="spec-orig">
120
+ <div id="hint">
121
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.4">
122
+ <circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/>
123
+ </svg>
124
+ Click any point in the scatter plot
125
+ </div>
126
+ </div>
127
+ <div id="spec-overlay"></div>
128
+ </div>
129
+ <div id="info">&mdash;</div>
130
+ </div>
131
+ </div>
132
+
133
+ <script>
134
+ let D = null;
135
+ let rawFlat = null;
136
+ let origFlat = null;
137
+ let reconFlat = null;
138
+ let N = 0;
139
+ let C = 0;
140
+
141
+ function decodeF32(b64) {
142
+ const bin = window.atob(b64);
143
+ const buf = new ArrayBuffer(bin.length);
144
+ const u8 = new Uint8Array(buf);
145
+ for (let i = 0; i < bin.length; i++) u8[i] = bin.charCodeAt(i);
146
+ return new Float32Array(buf);
147
+ }
148
+
149
+ function spectrum(flat, i) {
150
+ return Array.from(flat.subarray(i * C, (i + 1) * C));
151
+ }
152
+
153
+ let proj = 'tsne', col = 'base-err', cmap = 'default', topN = 0;
154
+ let specInited = false;
155
+ const scDiv = document.getElementById('scatter');
156
+ const spOrig = document.getElementById('spec-orig');
157
+ const spOverlay = document.getElementById('spec-overlay');
158
+
159
+ const BAND_NAMES = ['0-20% (Best)','20-40%','40-60%','60-80%','80-100% (Worst)'];
160
+ const BAND_COLORS_DEF = ['#27ae60','#3498db','#f1c40f','#e67e22','#e74c3c'];
161
+ const BAND_COLORS_CB = ['#009E73','#56B4E9','#F0E442','#E69F00','#D55E00'];
162
+
163
+ const CSCALE_DEF = 'Plasma';
164
+ const CSCALE_CB = 'Cividis';
165
+
166
+ function activeBand() { return cmap === 'cb' ? BAND_COLORS_CB : BAND_COLORS_DEF; }
167
+ function activeCscale() { return cmap === 'cb' ? CSCALE_CB : CSCALE_DEF; }
168
+
169
+ function topNIdx(n) {
170
+ return D.outlier_score
171
+ .map((s,i) => [s,i])
172
+ .sort((a,b) => b[0]-a[0])
173
+ .slice(0, n)
174
+ .map(p => p[1]);
175
+ }
176
+
177
+ function scatterTraces() {
178
+ const xs = proj === 'tsne' ? D.tsne_x : D.umap_x;
179
+ const ys = proj === 'tsne' ? D.tsne_y : D.umap_y;
180
+
181
+ const cd = D.base_err.map((e,i) => [i, e, D.base_band_label[i], D.sclk[i], D.outlier_score[i]]);
182
+ let htpl = '<b>sample %{customdata[0]}</b><br>';
183
+ const traces = [];
184
+
185
+ if (col === 'base-err') {
186
+ const logE = D.base_err.map(v => Math.log10(Math.max(v, 1e-12)));
187
+ htpl += 'MSE: %{customdata[1]:.3e}<br>Outlier: %{customdata[4]:.3f}<br>SCLK: %{customdata[3]}<extra></extra>';
188
+ traces.push({
189
+ type:'scattergl', mode:'markers', x:xs, y:ys,
190
+ marker:{
191
+ size:3, opacity:.72, color:logE, colorscale:activeCscale(), showscale:true,
192
+ colorbar:{
193
+ title:{text:'log₁₀(MSE)',side:'right',font:{color:'#7a82a0',size:10}},
194
+ tickfont:{color:'#7a82a0',size:9},
195
+ bgcolor:'rgba(0,0,0,0)', bordercolor:'rgba(0,0,0,0)',
196
+ len:.75, thickness:14,
197
+ },
198
+ },
199
+ customdata:cd, hovertemplate:htpl,
200
+ });
201
+ }
202
+
203
+ if (col === 'outlier') {
204
+ htpl += 'Outlier: %{customdata[4]:.3f}<br>MSE: %{customdata[1]:.3e}<br>SCLK: %{customdata[3]}<extra></extra>';
205
+ traces.push({
206
+ type:'scattergl', mode:'markers', x:xs, y:ys,
207
+ marker:{
208
+ size:3, opacity:.72, color:D.outlier_score, colorscale:'Inferno', showscale:true,
209
+ cmin:0, cmax:1,
210
+ colorbar:{
211
+ title:{text:'Outlier score',side:'right',font:{color:'#7a82a0',size:10}},
212
+ tickfont:{color:'#7a82a0',size:9},
213
+ bgcolor:'rgba(0,0,0,0)', bordercolor:'rgba(0,0,0,0)',
214
+ len:.75, thickness:14,
215
+ },
216
+ },
217
+ customdata:cd, hovertemplate:htpl,
218
+ });
219
+ }
220
+
221
+ if (col === 'base-band') {
222
+ htpl += 'Band: %{customdata[2]}<br>Outlier: %{customdata[4]:.3f}<br>MSE: %{customdata[1]:.3e}<extra></extra>';
223
+ BAND_NAMES.forEach((name, b) => {
224
+ const bx=[], by=[], bcd=[];
225
+ D.base_band.forEach((eb,i) => {
226
+ if(eb===b){ bx.push(xs[i]); by.push(ys[i]); bcd.push(cd[i]); }
227
+ });
228
+ traces.push({
229
+ type:'scattergl', mode:'markers', name, x:bx, y:by,
230
+ marker:{size:3, color:activeBand()[b], opacity:.75},
231
+ customdata:bcd, hovertemplate:htpl,
232
+ });
233
+ });
234
+ }
235
+
236
+ if (topN > 0) {
237
+ const hi = topNIdx(topN);
238
+ traces.push({
239
+ type:'scattergl', mode:'markers', name:`Top-${topN} outliers`,
240
+ x:hi.map(i => xs[i]), y:hi.map(i => ys[i]),
241
+ marker:{size:5.5, color:'#22d3ee', opacity:.95,
242
+ line:{color:'rgba(255,255,255,.65)', width:.5}},
243
+ customdata:hi.map(i => cd[i]),
244
+ hovertemplate:htpl,
245
+ });
246
+ }
247
+
248
+ return traces;
249
+ }
250
+
251
+ function scatterLayout() {
252
+ const isCont = (col === 'base-err' || col === 'outlier');
253
+ return {
254
+ paper_bgcolor:'#0d0f1a', plot_bgcolor:'#0d0f1a',
255
+ margin:{l:45, r:isCont?80:10, t:30, b:45},
256
+ xaxis:{title:proj.toUpperCase() + ' 1', titlefont:{color:'#555e7a',size:10}, tickfont:{color:'#454d6a',size:9}, gridcolor:'#181b2e', zeroline:false, showline:false},
257
+ yaxis:{title:proj.toUpperCase() + ' 2', titlefont:{color:'#555e7a',size:10}, tickfont:{color:'#454d6a',size:9}, gridcolor:'#181b2e', zeroline:false, showline:false},
258
+ legend:{font:{color:'#8a93b0',size:10}, bgcolor:'rgba(0,0,0,0)', x:.01, y:.99},
259
+ hovermode:'closest',
260
+ uirevision: proj + col + cmap,
261
+ };
262
+ }
263
+
264
+ function renderScatter() {
265
+ if(!D) return;
266
+ Plotly.react(scDiv, scatterTraces(), scatterLayout(), {
267
+ responsive:true, displayModeBar:true, modeBarButtonsToRemove:['lasso2d','select2d','toImage'], displaylogo:false,
268
+ });
269
+ scDiv.on('plotly_click', onPointClick);
270
+ }
271
+
272
+ function onPointClick(evt) {
273
+ if (!evt?.points?.length) return;
274
+ showSample(evt.points[0].customdata[0]);
275
+ }
276
+
277
+ function showSample(si) {
278
+ const base_err = D.base_err[si];
279
+ const base_band_l = D.base_band_label[si];
280
+ const sclk = D.sclk[si];
281
+ const out_score = D.outlier_score[si];
282
+
283
+ const raw = spectrum(rawFlat, si);
284
+ const proc = spectrum(origFlat, si);
285
+ const recon = spectrum(reconFlat, si);
286
+ const xs = D.channel_indices;
287
+
288
+ const commonLayout = {
289
+ paper_bgcolor:'#0d0f1a', plot_bgcolor:'#111220',
290
+ margin:{l:55, r:20, t:32, b:38},
291
+ xaxis:{ title:'m/z', titlefont:{color:'#555e7a',size:10}, tickfont:{color:'#454d6a',size:9}, gridcolor:'#181b2e', zeroline:false },
292
+ yaxis:{ title:'Intensity', titlefont:{color:'#555e7a',size:10}, tickfont:{color:'#454d6a',size:9}, gridcolor:'#181b2e', zeroline:false },
293
+ legend:{ font:{color:'#8a93b0',size:10}, bgcolor:'rgba(16,18,32,.8)', bordercolor:'#2a2d45', borderwidth:1, x:.01, y:.99 },
294
+ hovermode:'x unified',
295
+ };
296
+
297
+ const layoutOrig = Object.assign({}, commonLayout, {
298
+ title:{
299
+ text:`Sample #${si} &nbsp;<span style="font-size:10px;color:#555e7a">&mdash; SCLK ${sclk} | ${base_band_l} | outlier ${out_score.toFixed(3)}</span>`,
300
+ font:{color:'#8a93b0',size:11}, x:.04,
301
+ },
302
+ });
303
+
304
+ const layoutOverlay = Object.assign({}, commonLayout, {
305
+ title:{ text:'Processed vs Reconstructed', font:{color:'#8a93b0',size:11}, x:.04 },
306
+ legend:{ font:{color:'#8a93b0',size:10}, bgcolor:'rgba(16,18,32,.8)', bordercolor:'#2a2d45', borderwidth:1, x:.99, y:.99, xanchor:'right', yanchor:'top' },
307
+ });
308
+
309
+ if (!specInited) { spOrig.innerHTML = ''; specInited = true; }
310
+
311
+ Plotly.react(spOrig, [
312
+ {type:'scatter', mode:'lines', name:'Raw', x:xs, y:raw, line:{color:'#6eadf5', width:1.6}},
313
+ ], layoutOrig, {responsive:true, displayModeBar:false});
314
+
315
+ Plotly.react(spOverlay, [
316
+ {type:'scatter', mode:'lines', name:'Processed', x:xs, y:proc, line:{color:'#6eadf5', width:1.6, opacity:0.5}},
317
+ {type:'scatter', mode:'lines', name:'Reconstructed', x:xs, y:recon, line:{color:'#fb923c', width:1.5, dash:'dash'}},
318
+ ], layoutOverlay, {responsive:true, displayModeBar:false});
319
+
320
+ document.getElementById('info').innerHTML =
321
+ `<b style="color:#d8dce8">Sample #${si}</b>` +
322
+ `&nbsp;&nbsp;SCLK: <b style="color:#cccccc">${sclk}</b>` +
323
+ `&nbsp;&nbsp;Band: <b style="color:#cccccc">${base_band_l}</b>` +
324
+ `&nbsp;&nbsp;Recon MSE: <b style="color:#fb923c">${base_err.toExponential(3)}</b>` +
325
+ `&nbsp;&nbsp;Outlier: <b style="color:#22d3ee">${out_score.toFixed(3)}</b>`;
326
+ }
327
+
328
+ function buildTopOutStrip() {
329
+ const el = document.getElementById('topout-strip');
330
+ if (!el) return;
331
+ const order = D.outlier_score.map((s,i) => [s,i]).sort((a,b) => b[0]-a[0]).slice(0, 20);
332
+ el.innerHTML = '<span class="lbl">Top outliers (click to inspect):</span>' +
333
+ order.map(([s,i], k) =>
334
+ `<span class="tchip" onclick="showSample(${i})" title="outlier score ${s.toFixed(3)}">#${k+1} SCLK ${D.sclk[i]} (${s.toFixed(3)})</span>`
335
+ ).join('');
336
+ }
337
+
338
+ function setProj(p) {
339
+ proj = p;
340
+ document.getElementById('bt-tsne').classList.toggle('on', p==='tsne');
341
+ document.getElementById('bt-umap').classList.toggle('on', p==='umap');
342
+ renderScatter();
343
+ }
344
+ function setCol(c) {
345
+ col = c;
346
+ ['base-err','base-band','outlier'].forEach(x => {
347
+ document.getElementById('bt-'+x).classList.toggle('on', c===x);
348
+ });
349
+ renderScatter();
350
+ }
351
+ function setTopN(v) {
352
+ topN = parseInt(v, 10) || 0;
353
+ renderScatter();
354
+ }
355
+ function setCmap(m) {
356
+ cmap = m;
357
+ document.getElementById('bt-cmap-def').classList.toggle('on', m==='default');
358
+ document.getElementById('bt-cmap-cb' ).classList.toggle('on', m==='cb');
359
+ renderScatter();
360
+ }
361
+
362
+ fetch('data.json')
363
+ .then(res => res.json())
364
+ .then(data => {
365
+ D = data;
366
+ N = D.n_samples;
367
+ C = D.n_channels;
368
+ rawFlat = decodeF32(D.raw_b64);
369
+ origFlat = decodeF32(D.orig_b64);
370
+ reconFlat = decodeF32(D.recon_b64);
371
+
372
+ document.getElementById('loading').style.display = 'none';
373
+ buildTopOutStrip();
374
+ renderScatter();
375
+ })
376
+ .catch(err => {
377
+ document.getElementById('loading').innerText = "Error loading data.json: " + err.message;
378
+ console.error(err);
379
+ });
380
+
381
+ </script>
382
+ </body>
383
+ </html>