-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpatial_Calcium_and_Sensor.html
More file actions
629 lines (597 loc) · 22.4 KB
/
Copy pathSpatial_Calcium_and_Sensor.html
File metadata and controls
629 lines (597 loc) · 22.4 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
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-J23ES8WVTN"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-J23ES8WVTN');
</script>
<meta charset="UTF-8">
<title>Interactive Spatial Calcium Dynamics Simulation</title>
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Include Plotly.js -->
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<style>
/* Custom styles for simulation layout */
.heatmap-container {
position: relative;
width: 100%;
height: 60vh;
}
#plotHeatmap {
width: 100%;
height: 100%;
}
.inset-plot {
position: absolute;
top: 10%;
left: 5%;
width: 80%;
height: 10%;
background: transparent;
border: none;
z-index: 10;
}
.fwhm-overlay {
position: absolute;
bottom: 100px;
right: 160px;
font-size: 16px;
font-weight: bold;
color: white;
background: transparent;
z-index: 11;
}
#plotLine {
width: 100%;
height: 30vh;
margin-top: 10px;
}
</style>
</head>
<body>
<nav class="navbar navbar-light bg-white shadow-sm mb-3">
<div class="container">
<a class="navbar-brand fw-bold" href="index.html">SignalLab</a>
<span class="navbar-text d-none d-md-inline">
Interactive experiments in cell and neural signalling
</span>
</div>
</nav>
<div class="container-fluid">
<!-- Header Row: Title and Description -->
<div class="row">
<div class="col-12">
<h1 class="mt-3">Interactive Spatial Calcium Dynamics Simulation</h1>
<p>
This simulation models the spatial spread of calcium over a 100 nm × 100 nm area for 2 seconds.
Calcium entry begins at 500 ms and occurs in pulses from a central 30 nm‑diameter area containing 40 Calcium Channels similar to a cluster of Calcium Channels in a Calcium nanodomain.
A calcium sensor marker is placed 30 nm from the center; mimicking a closely localised Ca<sup>2+</sup> sensor such as Synaptotagmin.
Play with the options below: for instance how does the Ca<sup>2+</sup> buffer type affect activation of the Calicum sensor? What matters most, frequency or number of APs?
</p>
</div>
</div>
<!-- Content Row: Controls and Plots -->
<div class="row">
<!-- Left Column: Controls (col-md-4) -->
<div class="col-md-4">
<!-- Only the Reset button remains -->
<div class="mb-3">
<button id="resetBtn" class="btn btn-danger w-100">Reset</button>
</div>
<h3>Control Options</h3>
<hr>
<h4><strong>Calcium Buffers</strong></h4>
<div class="mb-3">
<label for="bufferConcentration" class="form-label">
Buffer Concentration (Bₜₒₜ) [µM]: <span id="bufferConcentrationValue">50</span>
</label>
<input type="range" class="form-range" id="bufferConcentration" min="10" max="100" value="50">
</div>
<div class="mb-3">
<label for="bufferKinetics" class="form-label">Buffer Kinetics:</label>
<select id="bufferKinetics" class="form-select">
<option value="fast" selected>Fast</option>
<option value="slow">Slow</option>
</select>
</div>
<div class="mb-3">
<label for="calciumIndicator" class="form-label">Calcium Indicator:</label>
<select id="calciumIndicator" class="form-select">
<option value="none" selected>No Indicator</option>
<option value="ogb50">OGB-1 50 µM</option>
<option value="ogb200">OGB-1 100 µM</option>
<option value="ogb400">Fluo-4FF 100 µM</option>
<option value="GCaMP6f">GCaMP6f</option>
</select>
</div>
<!-- Bootstrap Range controls with mapping arrays -->
<!-- Horizontal line to separate sections -->
<hr>
<h4><strong>Calcium Influx</strong></h4>
<div class="mb-3">
<label for="entryDuration" class="form-label">
Calcium Entry Duration [ms]: <span id="entryDurationValue">1</span>
</label>
<input type="range" class="form-range" id="entryDuration" min="0" max="4" step="1" value="1">
</div>
<div class="mb-3">
<label for="numPulses" class="form-label">
Number of Calcium Pulses: <span id="numPulsesValue">2</span>
</label>
<input type="range" class="form-range" id="numPulses" min="0" max="4" step="1" value="2">
</div>
<div class="mb-3">
<label for="pulseFrequency" class="form-label">
Pulse Frequency (Hz): <span id="pulseFrequencyValue">10</span>
</label>
<input type="range" class="form-range" id="pulseFrequency" min="0" max="4" step="1" value="1">
</div>
<div id="timeDisplay" class="mt-3 text-center">Current Time: 0.000 s</div>
</div>
<!-- Right Column: Plots (col-md-8) -->
<div class="col-md-8">
<div
class="heatmap-container mb-3"
data-bs-toggle="popover"
data-bs-trigger="hover"
data-bs-placement="left"
title="Sub-membrane Calcium Dynamics in an active zone"
data-bs-content="This heatmap represents the free [Ca²⁺] at a 100nmx100nm active zone, the dashed circle represents a cluster of Calcium Channels and the blue dot a nearby Ca2+ sensor"
>
<div id="plotHeatmap"></div>
<div id="fwhmOverlay" class="fwhm-overlay"></div>
<div id="insetPlot" class="inset-plot"></div>
</div>
<div id="plotLine"></div>
</div>
</div>
</div>
<!-- Bootstrap Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
<script>
/********** Mapping Arrays for Discrete Options **********/
// For Calcium Entry Duration (ms)
const durationOptions = [0.5, 1, 2, 5, 10];
// For Number of Calcium Pulses
const pulsesOptions = [1, 2, 5, 10, 20];
// For Pulse Frequency (Hz)
const frequencyOptions = [1, 10, 20, 50, 100];
/********** Simulation Parameters **********/
let gridSize = 30;
let gridLength = 100e-9;
let dx = gridLength / gridSize;
let dt = 1e-5;
let totalTime = 2.0;
let steps = Math.floor(totalTime / dt);
/********** Physical Constants **********/
let D_ca = 2.2e-9;
let k_on = 1e6; // default fast
let k_off = 100; // default fast
let k_extrude = 50;
let B_total = 50e-6;
// Set initial discrete parameters using mapping arrays:
let entryDuration = durationOptions[1] * 1e-3; // default 2 ms
let numPulses = pulsesOptions[2]; // default 2 pulses
let pulseFrequency = frequencyOptions[1]; // default 10 Hz
/********** Calcium Indicator Parameters **********/
let k_on_dye = 0, k_off_dye = 0, D_total = 0;
let CaD = create2DArray(gridSize, gridSize, 0);
/********** Initialize 2D Arrays **********/
let Ca = create2DArray(gridSize, gridSize, 0.05e-6);
let CaB = create2DArray(gridSize, gridSize, 0);
function create2DArray(x, y, initial) {
let arr = new Float32Array(x * y);
arr.fill(initial);
return arr;
}
function getIndex(x, y) {
return x + y * gridSize;
}
/********** Calcium Entry Configuration **********/
const entryRadius = 15e-9;
const entryGridRadius = Math.floor(entryRadius / dx);
const entryCenterX = Math.floor(gridSize / 2);
const entryCenterY = Math.floor(gridSize / 2);
const calciumChannels = 40;
let entryPoints = [];
for (let i = 0; i < calciumChannels; i++) {
let angle = Math.random() * 2 * Math.PI;
let radius = Math.random() * entryGridRadius;
let x = Math.round(entryCenterX + radius * Math.cos(angle));
let y = Math.round(entryCenterY + radius * Math.sin(angle));
x = Math.max(0, Math.min(gridSize - 1, x));
y = Math.max(0, Math.min(gridSize - 1, y));
if (!entryPoints.some(pt => pt.x === x && pt.y === y)) {
entryPoints.push({x: x, y: y});
}
if (entryPoints.length >= calciumChannels) break;
}
/********** Simulation Control Variables **********/
let isRunning = false;
let currentStep = 0;
let animationFrame;
const diffusionFactor = D_ca * dt / (dx * dx);
let xAxis = Array.from({length: gridSize}, (_, x) => (x * dx * 1e9).toFixed(2));
let yAxis = Array.from({length: gridSize}, (_, y) => (y * dx * 1e9).toFixed(2));
/********** Plotly Heatmap Initialization **********/
let heatmapData = [{
z: Array.from({length: gridSize}, (_, y) =>
Array.from({length: gridSize}, (_, x) => Ca[getIndex(x, y)] * 1e6)),
type: 'heatmap',
x: xAxis,
y: yAxis,
colorscale: 'Viridis',
zmin: 0,
zmax: 0.6,
colorbar: { title: '[Ca²⁺] (µM)' }
}];
let heatmapLayout = {
title: 'Calcium Concentration Over Time',
autosize: true,
xaxis: {
title: 'X (nm)',
range: [0, gridLength * 1e9],
showticklabels: true
},
yaxis: {
title: 'Y (nm)',
range: [0, gridLength * 1e9],
showticklabels: true
},
margin: { t: 40, l: 40, r: 40, b: 40 },
shapes: [
{
type: 'circle',
xref: 'x',
yref: 'y',
x0: 35,
y0: 35,
x1: 65,
y1: 65,
line: {
color: 'grey',
width: 2,
dash: 'dash'
}
}
]
};
Plotly.newPlot('plotHeatmap', heatmapData, heatmapLayout);
/********** Sensor Overlay (Calcium Sensor Marker) **********/
// Place one sensor marker 50 nm to the right of center.
let sensorDistance = 35e-9;
let sensorOffsetCells = Math.round(sensorDistance / dx);
// For example, sensor is at (centerX + sensorOffsetCells, centerY)
let sensorPos = { x: entryCenterX + sensorOffsetCells, y: entryCenterY };
// Convert sensor position to nm:
let sensorX = sensorPos.x * dx * 1e9;
let sensorY = sensorPos.y * dx * 1e9;
let sensorTrace = {
x: [sensorX],
y: [sensorY],
mode: 'markers',
marker: { color: 'blue', size: 28, symbol: 'circle' },
hoverinfo: 'none',
showlegend: false
};
// Add the sensor trace to the heatmap. Since our heatmap is trace index 0, sensor will be index 1.
Plotly.addTraces('plotHeatmap', sensorTrace);
const sensorTraceIndex = 1;
// Function to update the sensor marker color:
function updateSensor() {
let conc = Ca[getIndex(sensorPos.x, sensorPos.y)] * 1e6; // in µM
let newColor = conc > 0.3 ? "red" : "blue";
Plotly.restyle('plotHeatmap', {'marker.color': [[newColor]]}, [sensorTraceIndex]);
}
/********** Plotly Line Plot for Mean Ca²⁺ **********/
let meanTimeArray = [];
let meanCaArray = [];
let lineData = [{
x: [],
y: [],
type: 'scatter',
mode: 'lines',
line: { color: 'red' }
}];
let lineLayout = {
autosize: true,
xaxis: { title: 'Time (s)', range: [0.3, 2] },
yaxis: { title: 'Mean [Ca²⁺] (µM)' },
margin: { t: 20, b: 40, l: 40, r: 20 }
};
Plotly.newPlot('plotLine', lineData, lineLayout);
/********** Inset Plot: Spatial Profile of Calcium **********/
let injectionRow = entryCenterY;
let insetX = Array.from({length: gridSize}, (_, x) => (x * dx * 1e9).toFixed(2));
let insetData = [{
x: insetX,
y: Array.from({length: gridSize}, (_, x) => Ca[getIndex(x, injectionRow)] * 1e6),
type: 'scatter',
mode: 'lines',
line: { color: 'white' },
hoverinfo: 'none'
}];
let insetLayout = {
margin: { t: 2, b: 2, l: 2, r: 2 },
xaxis: { visible: false },
yaxis: { visible: false },
paper_bgcolor: 'rgba(0,0,0,0)',
plot_bgcolor: 'rgba(0,0,0,0)'
};
Plotly.newPlot('insetPlot', insetData, insetLayout, {displayModeBar: false});
/********** Indicator Parameter Setter **********/
function setIndicatorParameters(value) {
if (value === "none") {
k_on_dye = 0;
k_off_dye = 0;
D_total = 0;
} else if (value === "ogb50") {
k_on_dye = 1e7;
k_off_dye = 80;
D_total = 50e-6;
} else if (value === "ogb200") {
k_on_dye = 1e7;
k_off_dye = 80;
D_total = 100e-6;
} else if (value === "ogb400") {
k_on_dye = 1e7;
k_off_dye = 240;
D_total = 50e-6;
} else if (value === "GCaMP6f") {
k_on_dye = 9.44e6;
k_off_dye = 4;
D_total = 50e-6;
}
CaD = create2DArray(gridSize, gridSize, 0);
}
setIndicatorParameters("none");
/********** Update Inset Plot Function **********/
function updateInsetPlot() {
let newY = [];
for (let x = 0; x < gridSize; x++) {
newY.push(Ca[getIndex(x, injectionRow)] * 1e6);
}
Plotly.update('insetPlot', { y: [newY] });
}
/********** Update Heatmap Function **********/
function updateHeatmap() {
let newZ = [];
for (let y = 0; y < gridSize; y++) {
let row = [];
for (let x = 0; x < gridSize; x++) {
row.push(Ca[getIndex(x, y)] * 1e6);
}
newZ.push(row);
}
Plotly.update('plotHeatmap', { z: [newZ] }, {}, [0]);
let simTimeStr = (currentStep * dt).toFixed(3);
document.getElementById('timeDisplay').innerText = `Current Time: ${simTimeStr} s`;
}
/********** Update Line Plot Function for Mean Ca²⁺ **********/
function updateLinePlot() {
let sum = 0;
for (let i = 0; i < Ca.length; i++) {
sum += Ca[i];
}
let meanCa = (sum / Ca.length) * 1e6;
meanTimeArray.push(currentStep * dt);
meanCaArray.push(meanCa);
Plotly.update('plotLine', { x: [meanTimeArray], y: [meanCaArray] });
}
/********** Calculate FWHM Function (Restricted to 20–80 nm) **********/
function calculateFWHM() {
let profile = [];
for (let x = 0; x < gridSize; x++) {
profile.push(Ca[getIndex(x, injectionRow)] * 1e6);
}
let cellWidth = dx * 1e9;
let indexMin = Math.floor(20 / cellWidth);
let indexMax = Math.ceil(80 / cellWidth);
let restrictedProfile = profile.slice(indexMin, indexMax + 1);
let maxVal = Math.max(...restrictedProfile);
let halfMax = maxVal / 2;
let leftIndexRel = restrictedProfile.findIndex(val => val >= halfMax);
let rightIndexRel = restrictedProfile.length - 1 - restrictedProfile.slice().reverse().findIndex(val => val >= halfMax);
let leftIndex = leftIndexRel + indexMin;
let rightIndex = rightIndexRel + indexMin;
let fwhm = (rightIndex - leftIndex) * cellWidth;
return fwhm;
}
/********** Simulation Step Function **********/
function simulateStep() {
const stepsPerFrame = 1000;
for (let s = 0; s < stepsPerFrame; s++) {
if (currentStep >= steps) {
// At end of 2 seconds, calculate FWHM and update overlay.
let fwhm = calculateFWHM();
document.getElementById('fwhmOverlay').innerText = "FWHM: " + fwhm.toFixed(2) + " nm";
resetSimulation();
isRunning = true;
simulateStep();
return;
}
let Ca_new = Ca;
let CaB_new = CaB;
let CaD_new = CaD;
for (let y = 1; y < gridSize - 1; y++) {
for (let x = 1; x < gridSize - 1; x++) {
const idx = getIndex(x, y);
const laplacian = (
Ca[getIndex(x+1, y)] +
Ca[getIndex(x-1, y)] +
Ca[getIndex(x, y+1)] +
Ca[getIndex(x, y-1)]
) - 4 * Ca[idx];
const diffusion = diffusionFactor * laplacian;
const buffer_free = B_total - CaB[idx];
const J_bind = k_on * Ca[idx] * buffer_free - k_off * CaB[idx];
const extrusion = k_extrude * Ca[idx];
let dCa = (diffusion - extrusion - J_bind) * dt;
let dCaB = J_bind * dt;
if (D_total > 0) {
let freeIndicator = D_total - CaD[idx];
let J_bind_dye = k_on_dye * Ca[idx] * freeIndicator - k_off_dye * CaD[idx];
dCa -= J_bind_dye * dt;
let dCaD = J_bind_dye * dt;
CaD_new[idx] += dCaD;
if (CaD_new[idx] < 0) CaD_new[idx] = 0;
}
Ca_new[idx] += dCa;
CaB_new[idx] += dCaB;
if (Ca_new[idx] < 0) Ca_new[idx] = 0;
if (CaB_new[idx] < 0) CaB_new[idx] = 0;
}
}
// Calcium Entry: Pulses occur after 500 ms.
if (currentStep * dt >= 0.5) {
let t = currentStep * dt;
let pulseInterval = 1 / pulseFrequency;
for (let i = 0; i < numPulses; i++) {
let pulseStart = 0.5 + i * pulseInterval;
if (t >= pulseStart && t < (pulseStart + entryDuration)) {
entryPoints.forEach(point => {
const entryIdx = getIndex(point.x, point.y);
Ca_new[entryIdx] += 5e-3 * dt;
});
break;
}
}
}
Ca = Ca_new;
CaB = CaB_new;
if (D_total > 0) { CaD = CaD_new; }
currentStep++;
}
if (currentStep % 1000 === 0) {
updateHeatmap();
updateLinePlot();
updateInsetPlot();
updateSensor();
}
if (isRunning) {
animationFrame = requestAnimationFrame(simulateStep);
}
}
/********** Reset Simulation Function **********/
function resetSimulation() {
Ca = create2DArray(gridSize, gridSize, 0.05e-6);
CaB = create2DArray(gridSize, gridSize, 0);
CaD = create2DArray(gridSize, gridSize, 0);
currentStep = 0;
isRunning = false;
cancelAnimationFrame(animationFrame);
meanTimeArray = [];
meanCaArray = [];
updateHeatmap();
Plotly.update('plotLine', { x: [[]], y: [[]] });
document.getElementById('fwhmOverlay').innerText = "";
}
/********** Event Listeners **********/
// Reset button event listener (all other controls immediately reset and restart)
document.getElementById('resetBtn').addEventListener('click', () => {
resetSimulation();
// Read values from controls:
B_total = parseFloat(document.getElementById('bufferConcentration').value) * 1e-6;
document.getElementById('bufferConcentrationValue').innerText = document.getElementById('bufferConcentration').value;
let kinetics = document.getElementById('bufferKinetics').value;
if (kinetics === "fast") {
k_on = 1e6;
k_off = 100;
} else {
k_on = 1e4;
k_off = 100;
}
let indicator = document.getElementById('calciumIndicator').value;
setIndicatorParameters(indicator);
let durationIndex = parseInt(document.getElementById('entryDuration').value);
entryDuration = durationOptions[durationIndex] * 1e-3;
document.getElementById('entryDurationValue').innerText = durationOptions[durationIndex];
let pulsesIndex = parseInt(document.getElementById('numPulses').value);
numPulses = pulsesOptions[pulsesIndex];
document.getElementById('numPulsesValue').innerText = pulsesOptions[pulsesIndex];
let frequencyIndex = parseInt(document.getElementById('pulseFrequency').value);
pulseFrequency = frequencyOptions[frequencyIndex];
document.getElementById('pulseFrequencyValue').innerText = frequencyOptions[frequencyIndex];
isRunning = true;
simulateStep();
});
// Event listeners for the other controls.
document.getElementById('bufferKinetics').addEventListener('change', function() {
if (this.value === "fast") {
k_on = 1e6;
k_off = 100;
} else {
k_on = 1e4;
k_off = 100;
}
resetSimulation();
isRunning = true;
simulateStep();
});
document.getElementById('calciumIndicator').addEventListener('change', function() {
setIndicatorParameters(this.value);
resetSimulation();
isRunning = true;
simulateStep();
});
document.getElementById('bufferConcentration').addEventListener('input', function() {
B_total = parseFloat(this.value) * 1e-6;
document.getElementById('bufferConcentrationValue').innerText = this.value;
resetSimulation();
isRunning = true;
simulateStep();
});
document.getElementById('entryDuration').addEventListener('input', function() {
let index = parseInt(this.value);
entryDuration = durationOptions[index] * 1e-3;
document.getElementById('entryDurationValue').innerText = durationOptions[index];
resetSimulation();
isRunning = true;
simulateStep();
});
document.getElementById('numPulses').addEventListener('input', function() {
let index = parseInt(this.value);
numPulses = pulsesOptions[index];
document.getElementById('numPulsesValue').innerText = pulsesOptions[index];
resetSimulation();
isRunning = true;
simulateStep();
});
document.getElementById('pulseFrequency').addEventListener('input', function() {
let index = parseInt(this.value);
pulseFrequency = frequencyOptions[index];
document.getElementById('pulseFrequencyValue').innerText = frequencyOptions[index];
resetSimulation();
isRunning = true;
simulateStep();
});
// Automatically start simulation on page load.
window.onload = function() {
resetSimulation();
isRunning = true;
simulateStep();
};
/********** Sensor Update Function **********/
// The sensor marker (trace index 1) was added below the heatmap.
function updateSensor() {
let sensorConc = Ca[getIndex(sensorPos.x, sensorPos.y)] * 1e6; // in µM
let newColor = sensorConc > 0.1 ? "red" : "blue";
Plotly.restyle('plotHeatmap', {'marker.color': [[newColor]]}, [sensorTraceIndex]);
}
</script>
<script>
// Enable Bootstrap 5 popovers
document.addEventListener('DOMContentLoaded', function () {
var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'));
var popoverList = popoverTriggerList.map(function (popoverTriggerEl) {
return new bootstrap.Popover(popoverTriggerEl);
});
});
</script>
</body>
</html>