| name | music-perception-brain-network |
| description | 音乐感知脑网络建模方法论。使用FitzHugh-Nagumo模型和经验脑连接数据研究听觉刺激对神经网络动力学的影响,分析同步与频率/振幅的关系。触发词:音乐感知、脑网络、听觉刺激、神经同步、FitzHugh-Nagumo、gamma同步、music perception、brain network、auditory stimulus。 |
| user-invocable | true |
音乐感知脑网络建模
基于 arXiv:2504.07721 - "From empirical brain networks towards modeling music perception"
核心方法论
1. FitzHugh-Nagumo (FHN) 模型
FHN模型是简化的神经元模型,用于模拟神经元的兴奋性:
import numpy as np
from scipy.integrate import odeint
class FitzHughNagumoNetwork:
"""FHN神经网络模型"""
def __init__(self, n_nodes, connectivity_matrix, epsilon=0.08, a=0.7, b=0.8):
"""
参数:
n_nodes: 节点数量
connectivity_matrix: 连接矩阵 (N x N)
epsilon: 时间尺度分离参数
a, b: FHN模型参数
"""
self.n_nodes = n_nodes
self.C = connectivity_matrix
self.epsilon = epsilon
self.a = a
self.b = b
def dynamics(self, state, t, coupling_strength=0.1, external_input=None):
"""
神经网络动力学方程
dx/dt = (x - x^3/3 + y + I_ext + coupling) / epsilon
dy/dt = a + b*x - y
"""
x = state[:self.n_nodes]
y = state[self.n_nodes:]
coupling = coupling_strength * (self.C @ x - x * np.sum(self.C, axis=1))
I_ext = external_input if external_input is not None else np.zeros(self.n_nodes)
dxdt = (x - x**3/3 + y + I_ext + coupling) / self.epsilon
dydt = self.a + self.b * x - y
return np.concatenate([dxdt, dydt])
def simulate(self, initial_state, t_span, coupling_strength=0.1,
external_input_func=None, dt=0.1):
"""模拟网络动力学"""
t = np.arange(t_span[0], t_span[1], dt)
states = [initial_state]
state = initial_state.copy()
for i, ti in enumerate(t[:-1]):
I_ext = external_input_func(ti) if external_input_func else None
k1 = self.dynamics(state, ti, coupling_strength, I_ext)
k2 = self.dynamics(state + 0.5*dt*k1, ti + 0.5*dt, coupling_strength, I_ext)
k3 = self.dynamics(state + 0.5*dt*k2, ti + 0.5*dt, coupling_strength, I_ext)
k4 = self.dynamics(state + dt*k3, ti + dt, coupling_strength, I_ext)
state = state + dt/6 * (k1 + 2*k2 + 2*k3 + k4)
states.append(state)
return t, np.array(states)
def generate_auditory_stimulus(t, frequency, amplitude, nodes_indices=None, n_nodes=10):
"""
生成听觉刺激信号
参数:
t: 时间
frequency: 刺激频率 (Hz)
amplitude: 刺激振幅
nodes_indices: 接受刺激的节点索引
n_nodes: 总节点数
"""
if nodes_indices is None:
nodes_indices = [0]
stimulus = np.zeros(n_nodes)
signal = amplitude * np.sin(2 * np.pi * frequency * t)
for idx in nodes_indices:
stimulus[idx] = signal
return stimulus
def compute_synchronization_index(states, n_nodes):
"""
计算同步指数 (Kuramoto order parameter)
同步指数衡量网络中神经元的相位同步程度
"""
x = states[:, :n_nodes]
from scipy.signal import hilbert
phases = np.zeros_like(x)
for i in range(n_nodes):
analytic = hilbert(x[:, i])
phases[:, i] = np.unwrap(np.angle(analytic))
r = np.abs(np.mean(np.exp(1j * phases), axis=1))
return r
def compute_gamma_coherence(states, n_nodes, fs=100.0):
"""
计算Gamma频段相干性
Gamma频段 (30-100 Hz) 对音乐处理至关重要
"""
from scipy.signal import coherence
x = states[:, :n_nodes]
gamma_band = (30, 100)
coherence_matrix = np.zeros((n_nodes, n_nodes))
for i in range(n_nodes):
for j in range(i+1, n_nodes):
f, Cxy = coherence(x[:, i], x[:, j], fs=fs)
gamma_idx = (f >= gamma_band[0]) & (f <= gamma_band[1])
coherence_matrix[i, j] = np.mean(Cxy[gamma_idx])
coherence_matrix[j, i] = coherence_matrix[i, j]
return coherence_matrix
2. 经验脑连接数据集成
import numpy as np
def load_empirical_connectivity(filepath):
"""
加载经验脑连接数据
支持格式:
- DTI结构连接矩阵
- fMRI功能连接矩阵
"""
if filepath.endswith('.npy'):
return np.load(filepath)
elif filepath.endswith('.csv'):
return np.loadtxt(filepath, delimiter=',')
else:
raise ValueError("不支持的文件格式")
def create_auditory_network_template(n_regions=68):
"""
创建听觉网络模板
基于Desikan-Killiany脑图谱
"""
auditory_regions = {
'primary_auditory': [41, 42],
'secondary_auditory': [51, 52],
'associative': [81, 82],
}
template = np.zeros((n_regions, n_regions))
for region_id in auditory_regions.values():
for i in region_id:
for j in region_id:
if i < n_regions and j < n_regions:
template[i, j] = 1.0
template, auditory_regions
():
frequencies = np.linspace(freq_range[], freq_range[], n_freqs)
sync_indices = []
freq frequencies:
():
generate_auditory_stimulus(t, freq, amplitude, n_nodes=model.n_nodes)
initial = np.random.randn( * model.n_nodes) *
t, states = model.simulate(initial, t_span, external_input_func=stimulus)
sync = compute_synchronization_index(states[-((states)*):], model.n_nodes)
sync_indices.append(np.mean(sync))
sync_indices = np.array(sync_indices)
optimal_freq = frequencies[np.argmax(sync_indices)]
half_max = np.(sync_indices) / + np.(sync_indices) /
above_half = sync_indices > half_max
{
: frequencies,
: sync_indices,
: optimal_freq,
: np.(sync_indices),
: (frequencies[above_half][], frequencies[above_half][-]) np.(above_half)
}
3. 相变与临界动力学分析
def detect_phase_transitions(sync_timeseries, threshold=0.5, min_duration=10):
"""
检测同步-去同步相变
识别脑活动在同步和去同步状态之间的交替
"""
binary_states = (sync_timeseries > threshold).astype(int)
transitions = []
current_state = binary_states[0]
duration = 1
for i in range(1, len(binary_states)):
if binary_states[i] == current_state:
duration += 1
else:
if duration >= min_duration:
transitions.append({
'from_state': 'synchronized' if current_state == 1 else 'desynchronized',
'to_state': 'desynchronized' if current_state == 1 else 'synchronized',
'duration': duration,
'position': i - duration
})
current_state = binary_states[i]
duration = 1
return transitions
def compute_criticality_metrics(states, n_nodes):
"""
计算临界动力学指标
包括:
- 变异系数
- 幂律拟合
- 雪崩大小分布
"""
x = states[:, :n_nodes]
cv = np.std(x) / np.mean(np.abs(x)) if np.mean(np.abs(x)) > 0
threshold = np.mean(np.(x)) + * np.std(x)
events = np.(x) > threshold
avalanche_sizes = []
current_size =
t ((events)):
np.(events[t]):
current_size += np.(events[t])
current_size > :
avalanche_sizes.append(current_size)
current_size =
{
: cv,
: avalanche_sizes,
: np.mean(avalanche_sizes) avalanche_sizes
}
应用场景
1. 音乐认知研究
- 分析不同类型音乐对大脑同步的影响
- 研究音乐训练对神经网络的塑形作用
2. 神经调控
3. 临床应用
Activation Keywords
- 音乐感知
- 脑网络
- 听觉刺激
- 神经同步
- FitzHugh-Nagumo
- gamma同步
- music perception
- brain network
- auditory stimulus
- 相位动力学
- 频率响应
Tools Used
Instructions for Agents
- 理解FHN模型:简化的神经元兴奋性模型
- 创建听觉刺激:生成频率和振幅可控的正弦信号
- 计算同步指数:Kuramoto序参量
- 分析频率响应:不同频率刺激下的网络响应
- 注意Gamma频段(30-100 Hz)对音乐处理的重要性
Examples
from music_perception_brain_network import FitzHughNagumoNetwork, generate_auditory_stimulus
network = FitzHughNagumoNetwork(
n_nodes=10,
connectivity_matrix=connectivity,
epsilon=0.08
)
def stimulus(t):
return generate_auditory_stimulus(t, frequency=10.0, amplitude=1.0, n_nodes=10)
initial_state = np.random.randn(20) * 0.1
t, states = network.simulate(initial_state, (0, 100), external_input_func=stimulus)
sync_index = compute_synchronization_index(states, n_nodes=10)
print(f"平均同步指数: {sync_index.mean():.4f}")
参考文献
- Sawicki, J. et al. (2025). "From empirical brain networks towards modeling music perception" arXiv:2504.07721