-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
850 lines (680 loc) · 30.8 KB
/
index.html
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
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
<!DOCTYPE HTML>
<!--
Massively by HTML5 UP
html5up.net | @ajlkn
Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
-->
<html>
<head>
<title>Datalab108</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="stylesheet" href="assets/css/main.css" />
<noscript><link rel="stylesheet" href="assets/css/noscript.css" /></noscript>
<script type="importmap">
{
"imports": {
"three": "https://unpkg.com/[email protected]/build/three.module.js",
"three/addons/": "https://unpkg.com/[email protected]/examples/jsm/"
}
}
</script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/dat.gui.min.js"></script>
</head>
<body class="is-preload">
<!-- Wrapper -->
<div id="wrapper" class="fade-in">
<!-- Intro -->
<div id="intro">
<blockquote id="daily-proverb" > </blockquote><!-- Proverb will be displayed here -->
<!-- <h1>Datalab108<br /></h1> -->
<!-- add spacer -->
<div id="renderMain"></div>
<div style="height: 100px;"></div>
<p>Multidisciplinary Neuroscientist </p>
<p>specializing in Brain Signal Analysis & Neural Engineering,</p>
<p>focuses on understanding the brain's rhythms.</p>
<ul class="actions">
<li><a href="#nav" class="button icon solid solo fa-arrow-down scrolly">Continue</a></li>
</ul>
</div>
<!-- Header -->
<!-- <header id="header">
<a href="index.html" class="logo">Datalab108</a>
</header> -->
<!-- Nav -->
<nav id="nav">
<ul class="links">
<li class="active"><a href="index.html">Science Reports</a></li>
<li><a href="about.html">About</a></li>
<!-- <li><a href="elements.html">Elements Reference</a></li> -->
</ul>
<!-- <ul class="icons">
<li><a href="#" class="icon brands fa-twitter"><span class="label">Twitter</span></a></li>
<li><a href="#" class="icon brands fa-facebook-f"><span class="label">Facebook</span></a></li>
<li><a href="#" class="icon brands fa-instagram"><span class="label">Instagram</span></a></li>
<li><a href="#" class="icon brands fa-github"><span class="label">GitHub</span></a></li>
</ul/Users/luki/Downloads/glsl-pipeline-bcd947519dade0c6ebb094d0937d49b8d0f16b75/index.js> -->
</nav>
<!-- Main -->
<div id="main">
<!-- Featured Post -->
<article class="post featured">
<header class="major">
<span class="date">September 23, 2024</span>
<h2><a href="web-EEGAutoencoder-01.html">Highlighting Temporal Patterns in Resting-State EEG<br />
</a></h2>
<p>Autoencoder Latent Spaces and Multivariate Angular Distance Analysis</p>
</header>
<a href="web-EEGAutoencoder-01.html" class="image main"><img src="images/eeg-autoencoder/model.png" alt="" /></a>
<ul class="actions special">
<li><a href="web-EEGAutoencoder-01.html" class="button small">Full Story</a></li>
</ul>
</article>
<!-- Posts -->
<section class="posts">
<article>
<header class="major">
<span class="date">June 19, 2024</span>
<h2><a href="web-RQA-STC-HC_vs_MCI.html">Recurrence Quantitative Analysis of EEG Data in Mild Cognitive Impairment<br />
</a></h2>
<p>Focus on Default Mode and Executive Networks</p>
</header>
<a href="web-RQA-STC-HC_vs_MCI.html" class="image main"><img src="images/rqa_stc_hht/Pipeline.png" alt="" /></a>
<ul class="actions special">
<li><a href="web-RQA-STC-HC_vs_MCI.html" class="button small">Full Story</a></li>
</ul>
</article>
<article>
<header class="major">
<span class="date">June 17, 2024</span>
<h2><a href="web-CTIT_HC_vs_MCI_rev3.html">Cortical-Thalamic Information Transfer in Mild Cognitive Impairment<br />
</a></h2>
<p>A Study of Theta-Gamma and Alpha-Beta Coupling Dynamics</p>
</header>
<a href="web-CTIT_HC_vs_MCI_rev3.html" class="image main"><img src="images/ctit/pathwaysinfo.jpg" alt="" /></a>
<ul class="actions special">
<li><a href="web-CTIT_HC_vs_MCI_rev3.html" class="button small">Full Story</a></li>
</ul>
</article>
<article>
<header class="major">
<span class="date">March 04, 2024</span>
<h2><a href="web-MCI-model02.html">Prediction of MCI in Source Space<br />
</a></h2>
<p>Prediction of Mild Cognitive Impairment Severity Using EEG Data and Neuropsychological Scores in Source Space</p>
</header>
<a href="web-MCI-model02.html" class="image main"><img src="images/MCI_genlin/ROIs.png" alt="" /></a>
<ul class="actions special">
<li><a href="web-MCI-model02.html" class="button small">Full Story</a></li>
</ul>
</article>
<article>
<header class="major">
<span class="date">February 14, 2024</span>
<h2><a href="web-MCI-model01-corrected.html">Prediction of MCI<br />
</a></h2>
<p>This analysis integrates machine learning models to classify subjects into two groups based on the MCI Neuropsychological score</p>
</header>
<a href="web-MCI-model01-corrected.html" class="image main"><img src="images/MCI_genlin/FRSSD.png" alt="" /></a>
<ul class="actions special">
<li><a href="web-MCI-model01-corrected.html" class="button small">Full Story</a></li>
</ul>
</article>
<article>
<header class="major">
<span class="date">February 04, 2024</span>
<h2><a href="web-MCI-preproc02.html">Preprocessing of HD-EEG Recordings <br />
in Mild Cognitive Impairment (Revision 2)</a></h2>
<p>First Order Features & Spectral Analysis of EEG Recordings in Mild Cognitive Impairment</p>
</header>
<a href="web-MCI-preproc02.html" class="image main"><img src="images/MCI_subsel/i052_20150709_1121_good_4_spectral.jpg" alt="" /></a>
<ul class="actions special">
<li><a href="web-MCI-preproc02.html" class="button small">Full Story</a></li>
</ul>
</article>
<article>
<header class="major">
<span class="date">January 26, 2024</span>
<h2><a href="web-MCI-preproc01.html">Preprocessing of HD-EEG Recordings <br />
in Mild Cognitive Impairment</a></h2>
<p>First Order Features & Spectral Analysis of EEG Recordings in Mild Cognitive Impairment</p>
</header>
<a href="web-MCI-preproc01.html" class="image main"><img src="images/MCI_figures/bandpowers_2nd_iter.png" alt="" /></a>
<ul class="actions special">
<li><a href="web-MCI-preproc01.html" class="button small">Full Story</a></li>
</ul>
</article>
<article>
<header class="major">
<span class="date">January 15, 2024</span>
<h2><a href="web-traids.html">EEG Microstates Triads <br />
in Schizophrenia</a></h2>
<p>Comparison of Healthy and Schizophrenia Triads from Microstates Sequences</p>
</header>
<a href="web-traids.html" class="image main"><img src="images/triads/mainph.png" alt="" /></a>
<ul class="actions special">
<li><a href="web-traids.html" class="button small">Full Story</a></li>
</ul>
</article>
<article>
<header class="major">
<span class="date">December 22, 2023</span>
<h2><a href="state-distributions.html">State Distributions <br />
in Schizophrenia</a></h2>
<p>EEG Microstate Sequences: A Visual Exploration of State Distributions</p>
</header>
<a href="state-distributions.html" class="image main"><img src="images/distributions/schizo_violin.png" alt="" /></a>
<ul class="actions special">
<li><a href="state-distributions.html" class="button small">Full Story</a></li>
</ul>
</article>
<article>
<header class="major">
<span class="date">December 13, 2023</span>
<h2><a href="classification.html">Classification <br />
in Schizophrenia</a></h2>
<p>Classification of Transition Probability Matrix (TPM) between Healthy and Schizophrenia Groups</p>
</header>
<a href="classification.html" class="image main"><img src="images/classification/classification.png" alt="" /></a>
<ul class="actions special">
<li><a href="classification.html" class="button small">Full Story</a></li>
</ul>
</article>
<article>
<header class="major">
<span class="date">December 11, 2023</span>
<h2><a href="transition-probability-matrix.html">Transition Probability Matrix (TPM)<br />
in schizophrenia</a></h2>
<p>EEG Microstate Sequences → Transition Probability Matrix (TPM)</p>
</header>
<a href="transition-probability-matrix.html" class="image main"><img src="images/transition/transition_probabilities_no_self.png" alt="" /></a>
<ul class="actions special">
<li><a href="transition-probability-matrix.html" class="button small">Full Story</a></li>
</ul>
</article>
<article>
<header class="major">
<span class="date">December 9, 2023</span>
<h2><a href="correlation-matrices.html">correlations & differences<br />
in schizophrenia</a></h2>
<p>Correlation Matrices of EEG Microstate Sequences in Healthy and Schizophrenic Individuals</p>
</header>
<a href="correlation-matrices.html" class="image main"><img src="images/transition/correlation_matrices.png" alt="" /></a>
<ul class="actions special">
<li><a href="correlation-matrices.html" class="button small">Full Story</a></li>
</ul>
</article>
<article>
<header class="major">
<span class="date">December 6, 2023</span>
<h2><a href="motifs.html">microstates dynamics<br />
in schizophrenia</a></h2>
<p>This study explores the analysis of EEG signals to understand brain microstates and their dynamics in schizophrenia.</p>
</header>
<a href="motifs.html" class="image main"><img src="images/healthy_schizo_graphs.png" alt="" /></a>
<ul class="actions special">
<li><a href="motifs.html" class="button small">Full Story</a></li>
</ul>
</article>
</section>
<!-- Footer -->
<footer>
<!-- <div class="pagination">
<a href="#" class="previous">Prev</a>
<a href="#" class="page active">1</a>
<a href="#" class="page">2</a>
<a href="#" class="page">3</a>
<span class="extra">…</span>
<a href="#" class="page">8</a>
<a href="#" class="page">9</a>
<a href="#" class="page">10</a>
<a href="#" class="next">Next</a>
</div> -->
</footer>
</div>
<!-- Footer -->
<footer id="footer">
<section>
<iframe allow="autoplay *; encrypted-media *; fullscreen *; clipboard-write" frameborder="0" height="175" style="width:100%;max-width:660px;overflow:hidden;border-radius:10px;" sandbox="allow-forms allow-popups allow-same-origin allow-scripts allow-storage-access-by-user-activation allow-top-navigation-by-user-activation" src="https://embed.music.apple.com/us/album/idea-10-slowed-reverb/1648562802?i=1648562803"></iframe>
<!-- <form method="post" action="#">
<div class="fields">
<div class="field">
<label for="name">Name</label>
<input type="text" name="name" id="name" />
</div>
<div class="field">
<label for="email">Email</label>
<input type="text" name="email" id="email" />
</div>
<div class="field">
<label for="message">Message</label>
<textarea name="message" id="message" rows="3"></textarea>
</div>
</div>
<ul class="actions">
<li><input type="submit" value="Send Message" /></li>
</ul>
</form> -->
</section>
<section class="split contact">
<section>
<h3>Email</h3>
<p><a href="#">[email protected]</a></p>
</section>
<section>
<h3>Social</h3>
<ul class="icons alt">
<!-- <li><a href="#" class="icon brands alt fa-twitter"><span class="label">Twitter</span></a></li> -->
<!-- <li><a href="#" class="icon brands alt fa-facebook-f"><span class="label">Facebook</span></a></li> -->
<!-- <li><a href="#" class="icon brands alt fa-instagram"><span class="label">Instagram</span></a></li> -->
<li><a href="https://github.com/furmanlukasz" class="icon brands alt fa-github"><span class="label">GitHub</span></a></li>
</ul>
</section>
</section>
</footer>
<!-- Copyright -->
<div id="copyright">
<ul><li>© Furman Łukasz</li><li>Design: <a href="https://html5up.net">HTML5 UP</a></li></ul>
</div>
</div>
<!-- Scripts -->
<script type="module">
import * as THREE from 'three';
import { OBJLoader } from 'three/addons/loaders/OBJLoader.js';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js';
import { RenderPass } from 'three/addons/postprocessing/RenderPass.js';
import { UnrealBloomPass } from 'three/addons/postprocessing/UnrealBloomPass.js';
// import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js';
// import { RenderPass } from 'three/addons/postprocessing/RenderPass.js';
// import { ShaderPass } from 'three/addons/postprocessing/ShaderPass.js';
let W = window,
D = document;
let effect;
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(110, window.innerWidth / window.innerHeight, 0.1, 1000);
// const renderer = new THREE.WebGLRenderer({ alpha: true });
// renderer.setPixelRatio( window.devicePixelRatio )
const renderer = new THREE.WebGLRenderer( { antialias: true, alpha: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.toneMapping = THREE.ReinhardToneMapping;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap; // Soft shadows
// document.body.appendChild(renderer.domElement);
W.document.getElementById("renderMain").appendChild(renderer.domElement);
const controls = new OrbitControls(camera, renderer.domElement);
// Optional: Configure controls
controls.enableDamping = true;
controls.dampingFactor = 0.25;
controls.screenSpacePanning = false;
// disable controls for now
controls.enableZoom = false;
controls.enablePan = false;
controls.enableRotate = false;
// auto-rotation
controls.autoRotate = false;
controls.autoRotateSpeed = 0.05;
// Directional light
const directionalLight = new THREE.DirectionalLight(0xffffff, 1);
directionalLight.position.set(3, 4, 1.5);
directionalLight.castShadow = true; // Enable shadow casting
directionalLight.shadow.mapSize.width = 2048; // Shadow map width
directionalLight.shadow.mapSize.height = 2048; // Shadow map height
directionalLight.shadow.camera.near = 0.1; // Near shadow distance
directionalLight.shadow.camera.far = 500; // Far shadow distance
directionalLight.shadow.camera.left = -200; // Shadow camera left boundary
directionalLight.shadow.camera.right = 200; // Shadow camera right boundary
directionalLight.shadow.camera.top = 200; // Shadow camera top boundary
directionalLight.shadow.camera.bottom = -200; // Shadow camera bottom boundary
scene.add(directionalLight);
scene.fog = new THREE.FogExp2(0xCBAC88, 0.0015);
// Set the shadow bias to reduce self-shadowing
// directionalLight.shadow.bias = -0.001;
// Hemisphere light
const hemisphereLight = new THREE.HemisphereLight(0xffffff, 0x444444, 0.6);
scene.add(hemisphereLight);
const brainColor = 0xE2B4BD;
// const nodeColor = 0xF2B880;
const nodeColor = 0xFFBF69;
const connectionColor = 0xFFFFFF;
// Ambient light
const ambientLight = new THREE.AmbientLight(0xffffff, 0.35);
scene.add(ambientLight);
// Create a floor
const floorGeometry = new THREE.PlaneGeometry(1000, 1000);
const floorMaterial = new THREE.MeshStandardMaterial({ color: 0xFFF4EC, metalness: .7, roughness: 1.9, opacity: .25, transparent: true })
// const floorMaterial = new THREE.MeshPhongMaterial({ color: 0x424B54 });
const floorMesh = new THREE.Mesh(floorGeometry, floorMaterial);
// Rotate the floor to lie flat
floorMesh.rotation.x = -Math.PI / 2;
floorMesh.position.y = -300; // Adjust the position so it's below the brain
// Enable shadow casting for the floor
floorMesh.receiveShadow = true;
floorMesh.castShadow = false;
// Add the floor to the scene
scene.add(floorMesh);
// Create a wall behind the brain
const wallGeometry = new THREE.PlaneGeometry(1000, 1000);
const wallMaterial = new THREE.MeshStandardMaterial({ color: 0xFFF4EC, metalness: .7, roughness: 1.9, opacity: .25, transparent: true })
// const wallMaterial = new THREE.MeshPhongMaterial({ color: 0x424B54 });
const wallMesh = new THREE.Mesh(wallGeometry, wallMaterial);
// Rotate the wall to lie flat
// wallMesh.rotation.x = -Math.PI / 2;
// wallMesh.position.y = 0; // Adjust the position so it's below the brain
wallMesh.position.z = -50; // Adjust the position so it's behind the brain
// Enable shadow casting for the wall
wallMesh.receiveShadow = true;
wallMesh.castShadow = false;
// Add the wall to the scene
scene.add(wallMesh);
// Create a placeholder for nodes and connections
const nodes = {};
const connections = [];
const brainGroup = new THREE.Group();
scene.add(brainGroup);
// Lorenz Attractor parameters
let sigma = 10.0;
let rho = 28.0;
let beta = 8.0 / 3.0;
let x = 0.01, y = 0, z = 0; // Initial conditions
// Time step for the simulation
const dt = 0.01;
// Define parameters object
const parameters = {
sigma: 16.0,
rho: 44.0,
beta: 3.2,
cascadeDelay: 900
};
var params = {
exposure: 1.6,
bloomStrength: 1.2,
bloomThreshold: 0.23,
bloomRadius: 1.2
};
var renderScene = new RenderPass( scene, camera );
var bloomPass = new UnrealBloomPass( new THREE.Vector2( window.innerWidth, window.innerHeight ), .5, 0.4, 0.85 );
bloomPass.threshold = params.bloomThreshold;
bloomPass.strength = params.bloomStrength;
bloomPass.radius = params.bloomRadius;
var composer = new EffectComposer( renderer );
composer.addPass( renderScene );
composer.addPass( bloomPass )
// Function to update Lorenz attractor parameters
function updateParameters() {
// Update Lorenz attractor parameters
sigma = parameters.sigma;
rho = parameters.rho;
beta = parameters.beta;
}
// Create a new dat.GUI instance
const gui = new dat.GUI();
gui.close();
// Add sigma control
gui.add(parameters, 'sigma', 0, 30).name('Sigma').onChange(updateParameters);
// Add rho control
gui.add(parameters, 'rho', 0, 50).name('Rho').onChange(updateParameters);
// Add beta control
gui.add(parameters, 'beta', 0, 5).name('Beta').onChange(updateParameters);
// Add cascade delay control
gui.add(parameters, 'cascadeDelay', 0, 3000).name('Cascade Delay').onChange(value => {
parameters.cascadeDelay = value;
});
function loadAdditionalOBJ(filePath, color = 0x00ff00) {
const loader = new OBJLoader();
loader.load(filePath, function (object) {
object.traverse(function (child) {
if (child.type === 'Mesh') {
const material = new THREE.MeshStandardMaterial({ color: color, metalness: 0.2, roughness: 0.6, opacity: 1.0, transparent: true });
child.material = material;
child.castShadow = true;
// scene.add(child); // Add the mesh to the scene directly
brainGroup.add(child);
}
});
});
}
function loadCSVData() {
fetch('con_epochs_matrix.csv')
.then(response => response.text())
.then(csvText => {
const data = parseCSV(csvText);
adjustNodeSizesBasedOnMaxWeight(data);
data.forEach(row => {
const sourceNode = nodes[row.source];
const targetNode = nodes[row.target];
if (!sourceNode || !targetNode) {
console.error(`Nodes not found for connection: ${row.source} to ${row.target}`);
return;
}
const weight = parseFloat(row.weight);
const opacity = Math.min(Math.max(weight / 10, 0.1), 1);
const material = new THREE.MeshStandardMaterial({
color: connectionColor,
metalness: 0.2,
roughness: 0.5,
transparent: true,
opacity: opacity * 5
});
const distance = sourceNode.position.distanceTo(targetNode.position);
const geometry = new THREE.CylinderGeometry(weight*0.9, weight*0.9, distance, 8);
const connection = new THREE.Mesh(geometry, material);
// Calculate midpoint for the position
const midpoint = new THREE.Vector3().addVectors(sourceNode.position, targetNode.position).multiplyScalar(0.5);
connection.position.copy(midpoint);
// Orient the connection to face the target node
connection.lookAt(targetNode.position);
connection.rotateX(Math.PI / 2);
// Add the connection to the scene and store it
// scene.add(connection);
brainGroup.add(connection);
connections.push({ mesh: connection, weight: weight });
// cast shadow
connection.castShadow = true;
});
});
}
function parseCSV(csvText) {
// Trim the text to remove leading/trailing whitespace and split into lines
const lines = csvText.trim().split('\n');
// Process lines, skipping the header
const data = lines.slice(1).map(line => {
console.log("CSV Text:", csvText);
// Trim the line to ensure we don't process empty lines or lines with only whitespace
line = line.trim();
if (!line) return null;
const parts = line.split(',').map(part => part ? part.trim() : '');
if (parts.length === 3) {
const [source, target, weight] = parts;
return { source, target, weight: parseFloat(weight) };
} else {
console.warn('Invalid line format:', line);
return null;
}
}).filter(row => row !== null);
return data;
}
// Update function for the Lorenz attractor
function updateLorenzAttractor() {
const dx = sigma * (y - x) * dt;
const dy = (x * (rho - z) - y) * dt;
const dz = (x * y - beta * z) * dt;
x += dx;
y += dy;
z += dz;
// Return a value based on one of the attractor's variables to control the node size
return Math.abs(x % 3);
}
function adjustNodeSizes() {
const lorenzValue = updateLorenzAttractor();
const currentTime = Date.now();
Object.keys(nodes).forEach(index => {
const node = nodes[index];
if (node) {
const maxWeight = node.maxWeight || 1;
const delay = parameters.cascadeDelay * node.phase;
const timeSinceStart = (currentTime % 10000) - delay;
if (timeSinceStart > 0) {
const dynamicSize = Math.abs(Math.sin(timeSinceStart / 1000) * lorenzValue);
const newSize = Math.max(.1, dynamicSize + (maxWeight * 0.1)) + 2.5;
node.scale.set(newSize, newSize, newSize);
// cast shadow
node.castShadow = true;
// if (newSize > 2.5) {
// node.material.setValues({emissive: new THREE.Color(newSize*0.01, newSize*0.01, newSize*0.01) });
// node.material.setValues({color: new THREE.Color(nodeColor) });
// } else {
// node.material.setValues({emissive: new THREE.Color(0x000000) });
// node.material.setValues({color: new THREE.Color(nodeColor) });
// }
}
}
});
}
function adjustNodeSizesBasedOnMaxWeight(csvData) {
const maxWeights = {};
// Iterate through each row to find the maximum weight for each node
csvData.forEach(row => {
const source = parseInt(row.source, 10);
const target = parseInt(row.target, 10);
const weight = parseFloat(row.weight);
// Update the max weight for involved nodes
maxWeights[source] = Math.max(maxWeights[source] || 0, weight);
maxWeights[target] = Math.max(maxWeights[target] || 0, weight);
});
// Adjust each node's size based on the maximum weight it's involved in
Object.keys(nodes).forEach(index => {
const node = nodes[index];
const maxWeight = maxWeights[index];
if (node && maxWeight !== undefined) {
// Calculate new size; this formula can be adjusted as needed
const newSize = Math.max(0, maxWeight * 2.7);
node.scale.set(newSize, newSize, newSize);
// cast shadow
node.castShadow = true;
}
});
}
// Add a node phase property for the cascade effect
function initializeNodePhases() {
let phase = 0;
Object.keys(nodes).forEach(index => {
nodes[index].phase = phase;
console.log(`Node ${index} phase initialized to ${phase}`);
phase++;
});
}
function loadOBJAndCreateNodes() {
return new Promise((resolve, reject) => {
const loader = new OBJLoader();
loader.load('rois4.obj', function (object) {
object.traverse(function (child) {
if (child.type === 'Points') { // Check if the child is a Points object
const vertices = child.geometry.attributes.position.array; // Access vertex positions
// Create a material to use for the spheres
const material = new THREE.MeshStandardMaterial({ color: nodeColor, metalness: 0.1, roughness: 0.5 , opacity: 1.0, transparent: true });
// const material = new THREE.MeshBasicMaterial({ color: 0xff0000 });
for (let i = 0; i < vertices.length; i += 3) {
// For each vertex, create a sphere
const geometry = new THREE.SphereGeometry(1, 32, 32);
const sphere = new THREE.Mesh(geometry, material);
// Set sphere position to the vertex position
sphere.position.set(vertices[i], vertices[i + 1], vertices[i + 2]);
sphere.castShadow = true;
// Add sphere to the scene
// scene.add(sphere);
brainGroup.add(sphere);
// Store reference to this node
nodes[i / 3] = sphere;
}
}
})
resolve();
}, undefined, function (error) {
reject(error);
});
});
}
function animate() {
requestAnimationFrame(animate);
// brainGroup.rotation.x = -(Math.PI / 2);
// minus 15 degrees on x axis
// brainGroup.rotation.x = (Math.PI / 12);
// move up brainGroup
brainGroup.position.y = -(Math.PI / 2);
// Rotate the brain group
// brainGroup.rotation.z += 0.001;
adjustNodeSizes();
controls.update();
composer.render(scene, camera );
// effect.render( scene, camera );
// effect_cb.render( scene, camera );
// renderer.render(scene, camera);
}
loadOBJAndCreateNodes().then(() => {
return loadAdditionalOBJ('brain_lh_low.obj', brainColor);
}).then(() => {
loadCSVData();
initializeNodePhases();
brainGroup.scale.set(2, 2, 2);
brainGroup.position.set(0, 0, -10);
// brainGroup.position.y = 500;
animate();
});
function lerp(a, b, t) {
return (1 - t) * a + t * b;
}
camera.position.z = 250;
camera.position.y = 20;
// Define variables to track mouse position
let mouseX = 0;
let mouseY = 0;
// Function to handle mouse movement
function handleMouseMove(event) {
// Update mouseX and mouseY with the current mouse position relative to the window
mouseX = event.clientX / window.innerWidth * 2 - 1;
mouseY = -(event.clientY / window.innerHeight) * 2 + 1;
// Update camera position based on mouse position
// camera.position.x = mouseX * 50;
// camera.position.y = mouseY * 50;
// rotate abrain from -30 to 30 degrees based on mouse position x
let rotationX = mouseX * Math.PI ;
brainGroup.rotation.y = lerp(brainGroup.rotation.z, rotationX, 0.04);
// brainGroup.rotation.x = -(mouseY * Math.PI / 6);
// brainGroup.rotation.y = (mouseX * Math.PI / 6);
// Update camera lookAt position to center
// camera.lookAt(0, 0, 0);
}
// Add event listener for mousemove event
window.addEventListener('mousemove', handleMouseMove);
</script>
<script>
// Function to load proverbs and display a daily proverb
function loadDailyProverb() {
fetch('proverbs.json')
.then(response => response.json())
.then(proverbs => {
// Use current date to seed the random selection
const today = new Date();
const index = (today.getFullYear() + today.getMonth() + today.getDate()) % proverbs.length;
// Select a proverb
const dailyProverb = proverbs[index];
// Display the proverb
document.getElementById('daily-proverb').innerText = dailyProverb;
})
.catch(error => console.error('Error loading proverbs:', error));
}
// Call the function on page load
window.onload = loadDailyProverb;
</script>
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/jquery.scrollex.min.js"></script>
<script src="assets/js/jquery.scrolly.min.js"></script>
<script src="assets/js/browser.min.js"></script>
<script src="assets/js/breakpoints.min.js"></script>
<script src="assets/js/util.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>