moonlantern1 commited on
Commit
b8b0a5d
Β·
verified Β·
1 Parent(s): c12563b

Upload brain_virality_predictor/signals.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. brain_virality_predictor/signals.py +79 -0
brain_virality_predictor/signals.py ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Brain-response β†’ 8 UX-relevant signals.
3
+
4
+ Signal design is grounded in published neuroscience:
5
+ aesthetic_appeal β†’ Vessel & Rubin 2019 (Visual network + Default mode)
6
+ visual_fluency β†’ Reber et al. 2004 (Visual clarity β†’ fluency β†’ preference)
7
+ cognitive_load β†’ frontoparietal + dorsal attention engagement
8
+ trust_affinity β†’ Limbic / Default mode emotional resonance
9
+ reward_anticipation β†’ Knutson et al. 2007 (Nucleus accumbens / ventral striatum)
10
+ motor_readiness β†’ Somatomotor cortex activation (mirror-neuron prep)
11
+ surprise_novelty β†’ Ventral attention / salience detection
12
+ friction_anxiety β†’ Frontoparietal conflict signal (effort / aversion)
13
+
14
+ Each signal is a linear (or nonlinear) blend of Yeo7 network time series.
15
+ """
16
+
17
+ import numpy as np
18
+ from typing import Dict
19
+
20
+ # ── blending weights per UX signal ───────────────────────────────────
21
+ # Positive weights = network drives signal up. Negative = drives down.
22
+ SIGNAL_BLEND = {
23
+ "aesthetic_appeal": {
24
+ "Visual": 0.40,
25
+ "Default": 0.35,
26
+ "Limbic": 0.25,
27
+ },
28
+ "visual_fluency": {
29
+ "Visual": 0.50,
30
+ "Dorsal_Attention": 0.30,
31
+ "Ventral_Attention": 0.20,
32
+ },
33
+ "cognitive_load": {
34
+ "Frontoparietal": 0.45,
35
+ "Dorsal_Attention": 0.35,
36
+ "Default": -0.20, # DMN suppression under load
37
+ },
38
+ "trust_affinity": {
39
+ "Limbic": 0.40,
40
+ "Default": 0.35,
41
+ "Somatomotor": 0.10,
42
+ "Frontoparietal": -0.15, # trust should feel easy, not effortful
43
+ },
44
+ "reward_anticipation": {
45
+ "Limbic": 0.50,
46
+ "Ventral_Attention": 0.25,
47
+ "Default": 0.25,
48
+ },
49
+ "motor_readiness": {
50
+ "Somatomotor": 0.60,
51
+ "Frontoparietal": 0.25,
52
+ "Dorsal_Attention": 0.15,
53
+ },
54
+ "surprise_novelty": {
55
+ "Ventral_Attention": 0.50,
56
+ "Dorsal_Attention": 0.30,
57
+ "Frontoparietal": 0.20,
58
+ },
59
+ "friction_anxiety": {
60
+ "Frontoparietal": 0.45,
61
+ "Dorsal_Attention": 0.30,
62
+ "Visual": -0.25, # anxiety kills visual fluency
63
+ },
64
+ }
65
+
66
+
67
+ def network_to_ux_signals(network_ts: Dict[str, np.ndarray]) -> Dict[str, np.ndarray]:
68
+ """
69
+ network_ts: {Yeo_network_name: (n_timesteps,) array}
70
+ Returns: {signal_name: (n_timesteps,) array}
71
+ """
72
+ n = next(iter(network_ts.values())).shape[0]
73
+ signals = {}
74
+ for sig_name, weights in SIGNAL_BLEND.items():
75
+ vec = np.zeros(n, dtype=np.float32)
76
+ for net_name, w in weights.items():
77
+ vec += w * network_ts.get(net_name, np.zeros(n))
78
+ signals[sig_name] = vec
79
+ return signals