OSCR

Cerebellar microcircuits enable robust evidence-based decisions through cortico-cerebellar coupling.

Code ↔ Paper

The paper beside its authors' code: matches between them have not been computed for this paper yet.

Paper

Loaded from Europe PMC by your browser, not stored by OSCR: doi.org · Europe PMC

The paper is loaded when this pane is shown.

The authors' code

Python · 542 lines · 23 KB · no license

  1. # coding=gbk
  2. import multiprocessing
  3. import os
  4. import matplotlib
  5. matplotlib.use('Agg')
  6. import matplotlib.pyplot as plt
  7. import numpy as np
  8. import matplotlib.gridspec as gridspec
  9. from brian2 import *
  10. from collections import OrderedDict
  11. import cupy as cp
  12. continuous_model_params = dict(
  13. V_L = -70*mV, Vth = -50*mV, Vreset = -55*mV,
  14. gE = 25*nS, tau_m_E = 20*ms, tau_ref_E = 2*ms,
  15. gI = 20*nS, tau_m_I = 10*ms, tau_ref_I = 1*ms,
  16. V_E = 0*mV, V_I = -70*mV,
  17. a = 0.062*mV**-1, b = 3.57,
  18. tauAMPA = 2*ms, tau_x = 2*ms, tauNMDA = 100*ms, alpha = 0.5*kHz, tauGABA = 5*ms, delay = 0*ms,
  19. gAMPA_ext_E = 1*nS, gAMPA_ext_E_input = 150*nS, gAMPA_ext_I = 1.62*nS,
  20. gAMPA_E = 200*nS, gNMDA_E = 400*nS, gGABA_E = 10*nS,
  21. gAMPA_I = 300*nS, gNMDA_I = 0*nS, gGABA_I = 400*nS,
  22. nu_ext = 100*Hz,
  23. g_SFA = 100*nS, tau_w = 80*ms, b_SFA = 0.1, V_K = -80*mV,
  24. N_E = 1600, N_I = 400,
  25. fsel = 0.15,
  26. wp = 35, sigma_w=2.4
  27. )
  28. gc_par = dict(
  29. C = 100 * pF, vr = -60 * mV, vt = -40 * mV, k = 0.7 * pA/(mV**2),
  30. a = 0.03 / ms , b = -2 * nS , vpeak = 0* mV , c_reset = -50 * mV , d_reset = 100 * pA ,
  31. V_E=0*mV, gAMPA=50*nS, f = 0.062*mV**-1, g = 3.57, tauAMPA = 2*ms,
  32. possion_noise=0.5*kHz, gAMPA_noise=1*nS, tau_c=2*second,
  33. N_gc = 1000, mossy_fiber_input_num=4
  34. )
  35. PC_par=dict(
  36. N=400, c = 268 * pF, gl = 8.47 * nS, el = -51.31 * mV, vt = -53.23 * mV, delta = 0.85 * mV, vreset = -60.35 * mV,
  37. a = 37.79 * nS, tauw = 20.76 * ms, b = 441.12 * pA,
  38. Ihold = -140 * pA, VSpike=60*mV, V_E=0*mV, V_I=-80*mV,
  39. sigma=40*pA, corr=2*ms,
  40. tauAMPA = 2*ms, tauGABA = 5*ms,
  41. gAMPA=3*nS, gGABA =17*nS
  42. )
  43. pulse_params = dict(
  44. start_time=1000*ms, end_time=4800*ms, stim_num_sum=19, left_right_diff=1, start_index=800, end_index=900
  45. )
  46. sim_params=dict(
  47. sim_purations=7000*ms
  48. )
  49. E_equations = '''
  50. dV/dt = (-(V - V_L) - Isyn/gE) / tau_m_E : volt (unless refractory)
  51. Isyn = I_AMPA_ext + I_AMPA + I_NMDA + I_GABA+I_SFA+I_AMPA_input: amp
  52. I_AMPA_ext = gAMPA_ext_E*sAMPA_ext*(V - V_E) : amp
  53. I_AMPA_input = gAMPA_ext_E_input*sAMPA_input*(V - V_E) : amp
  54. I_AMPA = gAMPA_E*S_AMPA*(V - V_E) : amp
  55. I_NMDA = gNMDA_E*S_NMDA*(V - V_E)/(1 + exp(-a*V)/b) : amp
  56. I_GABA = gGABA_E*S_GABA*(V - V_I) : amp
  57. I_SFA = g_SFA * w_SFA * (V - V_K) : amp
  58. dsAMPA_ext/dt = -sAMPA_ext/tauAMPA : 1
  59. dsAMPA_input/dt = -sAMPA_input/tauAMPA : 1
  60. dsAMPA/dt = -sAMPA/tauAMPA : 1
  61. dx/dt = -x/tau_x : 1
  62. dw_SFA/dt = -w_SFA / tau_w : 1
  63. dsNMDA/dt = -sNMDA/tauNMDA + alpha*x*(1 - sNMDA) : 1
  64. S_AMPA : 1
  65. S_NMDA : 1
  66. S_GABA : 1
  67. '''
  68. I_equations = '''
  69. dV/dt = (-(V - V_L) - Isyn/gI) / tau_m_I : volt (unless refractory)
  70. Isyn = I_AMPA_ext + I_AMPA + I_NMDA + I_GABA : amp
  71. I_AMPA_ext = gAMPA_ext_I*sAMPA_ext*(V - V_E) : amp
  72. I_AMPA = gAMPA_I*S_AMPA*(V - V_E) : amp
  73. I_NMDA = gNMDA_I*S_NMDA*(V - V_E)/(1 + exp(-a*V)/b) : amp
  74. I_GABA = gGABA_I*S_GABA*(V - V_I) : amp
  75. dsAMPA_ext/dt = -sAMPA_ext/tauAMPA : 1
  76. dsGABA/dt = -sGABA/tauGABA : 1
  77. S_AMPA: 1
  78. S_NMDA: 1
  79. S_GABA: 1
  80. '''
  81. eqs_gc = '''
  82. dv/dt = (k*(v-vr)*(v-vt)- u + I_syn)/C : volt
  83. du/dt = a*(b*(v-vr)-u) : amp
  84. I_syn=I_AMPA+I_AMPA_noise: amp
  85. I_AMPA= gAMPA*sAMPA*(V_E-v) : amp
  86. I_AMPA_noise= gAMPA_noise*sAMPA_noise*(V_E-v) : amp
  87. dsAMPA/dt= -sAMPA/tauAMPA : 1
  88. dsAMPA_noise/dt= -sAMPA_noise/tauAMPA : 1
  89. '''
  90. eqs_pc='''
  91. dv/dt = (gl * delta * exp((v - vt) / delta) - gl * (v - el) - w + Ihold+I_ou+I_ext) / c : volt
  92. dw/dt = (a * (v - el) - w) / tauw : amp
  93. dtemp/dt = -temp/corr + (sqrt(2/(corr*dt)))*randn() : 1
  94. I_ou =temp * sigma : amp
  95. I_ext=I_GABA+I_AMPA:amp
  96. dsAMPA/dt = -sAMPA/tauAMPA : 1
  97. dsGABA/dt= -sGABA/tauGABA : 1
  98. I_AMPA=gAMPA*sAMPA*(V_E-v):amp
  99. I_GABA=gGABA*S_GABA*(V_I-v) : amp
  100. S_GABA:1
  101. '''
  102. current_script_dir = os.path.dirname(__file__)
  103. base_data_dir = os.path.join(current_script_dir, '..', 'evidence_accumulation', 'Data','Figure1')
  104. def calculate_sliding_window_rate(spike_times, num_neurons_in_group, total_duration, window_size, step_size):
  105. spike_times_ms = spike_times / ms
  106. total_duration_ms = total_duration / ms
  107. window_size_ms = window_size / ms
  108. step_size_ms = step_size / ms
  109. time_points_ms = np.arange(0, total_duration_ms, step_size_ms)
  110. firing_rates_Hz = np.zeros(len(time_points_ms))
  111. if num_neurons_in_group == 0:
  112. return time_points_ms, firing_rates_Hz
  113. for i, t_start_ms in enumerate(time_points_ms):
  114. t_end_ms = t_start_ms + window_size_ms
  115. spikes_in_window = np.sum((spike_times_ms >= t_start_ms) & (spike_times_ms < t_end_ms))
  116. if window_size_ms > 0:
  117. firing_rates_Hz[i] = spikes_in_window / (num_neurons_in_group * (window_size_ms / 1000.0))
  118. else:
  119. firing_rates_Hz[i] = 0 # If window size is 0, rate is 0
  120. return time_points_ms, firing_rates_Hz
  121. def calculate_weight(theta_i, theta_j, J_plus, J_minus, sigma_w_deg):
  122. delta_theta_deg = abs(theta_i - theta_j)
  123. delta_theta_deg = np.minimum(delta_theta_deg, 360 - delta_theta_deg)
  124. return J_minus + (J_plus - J_minus) * np.exp(-(delta_theta_deg**2) / (2 * sigma_w_deg**2))
  125. def generate_random_pulse_times_strict_constrained(start_t_ms, end_t_ms, num_pulses, proportional_jitter_factor=0.5):
  126. if num_pulses <= 0:
  127. return np.array([])
  128. if num_pulses == 1:
  129. return np.array([start_t_ms])
  130. min_interval = 200
  131. total_duration_ms = end_t_ms - start_t_ms
  132. if total_duration_ms < (num_pulses - 1) * min_interval:
  133. raise ValueError(
  134. f"²ÎÊý³åÍ»: ÎÞ·¨ÔÚ {total_duration_ms:.2f}ms ÄÚ·ÅÖà {num_pulses} ¸öÂö³å "
  135. f"ÇÒ±£³Ö×îС¼ä¸ô {min_interval}ms¡£"
  136. )
  137. free_time = total_duration_ms - (num_pulses - 1) * min_interval
  138. random_shifts = np.random.uniform(0, free_time, num_pulses - 1)
  139. random_shifts.sort()
  140. pulse_times = np.zeros(num_pulses)
  141. pulse_times[0] = start_t_ms
  142. for i in range(1, num_pulses):
  143. pulse_times[i] = start_t_ms + i * min_interval + random_shifts[i - 1]
  144. return pulse_times
  145. def run_continuous_layer(args):
  146. left_right_diff_val, iteration_num, gpu_id = args
  147. output_dir = os.path.join(base_data_dir, f'{left_right_diff_val}')
  148. os.makedirs(output_dir, exist_ok=True)
  149. txt_save_path = os.path.join(output_dir, f'E_spikes_run_{iteration_num}.txt')
  150. if os.path.exists(txt_save_path):
  151. print(f"Skipping Phase 1 for diff={left_right_diff_val}, run={iteration_num} (File already exists: {txt_save_path})")
  152. return
  153. start_scope()
  154. np.random.seed(iteration_num)
  155. try:
  156. cp.cuda.Device(gpu_id).use()
  157. except Exception as e:
  158. print(f"Phase 1 Warning: Could not set GPU {gpu_id}. Error: {e}")
  159. pass
  160. params = continuous_model_params.copy()
  161. pulse_params_local = pulse_params.copy()
  162. sim_params_local = sim_params.copy()
  163. pulse_params_local['left_right_diff'] = left_right_diff_val
  164. for par in ['gAMPA_E', 'gAMPA_I', 'gNMDA_E', 'gNMDA_I']:
  165. params[par] /= params['N_E']
  166. for par in ['gGABA_E', 'gGABA_I']:
  167. params[par] /= params['N_I']
  168. N_E = params['N_E']
  169. fsel = params['fsel']
  170. wp = params['wp']
  171. delay = params['delay']
  172. N1 = int(fsel*N_E)
  173. N2 = N1
  174. N0 = N_E - (N1 + N2)
  175. params['N0'] = N0
  176. params['N1'] = N1
  177. params['N2'] = N2
  178. wm = 0
  179. params['wm'] = wm
  180. weight_matrix = np.zeros((N_E, N_E))
  181. excitatory_thetas = np.linspace(0, 360, N_E, endpoint=False)
  182. for l in range(N_E):
  183. for m in range(N_E):
  184. weight_matrix[l, m] = calculate_weight(excitatory_thetas[l], excitatory_thetas[m], params['wp'], params['wm'], params['sigma_w'])
  185. weight_matrix_gpu = cp.asarray(weight_matrix)
  186. start_time_ms = pulse_params_local['start_time']/ms
  187. end_time_ms = pulse_params_local['end_time']/ms
  188. stim_num_left = (pulse_params_local['stim_num_sum'] - pulse_params_local['left_right_diff']) // 2
  189. stim_num_right = (pulse_params_local['stim_num_sum'] + pulse_params_local['left_right_diff']) // 2
  190. stim_num_left = max(0, stim_num_left)
  191. stim_num_right = max(0, stim_num_right)
  192. input_neuron_indices_left = np.array([], dtype=int)
  193. spike_times_left = np.array([]) * ms
  194. if stim_num_left > 0:
  195. try:
  196. pulse_times_ms_left = generate_random_pulse_times_strict_constrained(start_time_ms, end_time_ms, stim_num_left)
  197. input_neuron_indices_left = np.repeat(np.arange(N1), stim_num_left)
  198. spike_times_left = np.tile(pulse_times_ms_left, N1)*ms
  199. except ValueError as e:
  200. print(f"Simulation (diff={left_right_diff_val}, run={iteration_num}) for LEFT side failed: {e}")
  201. return
  202. input_neuron_indices_right = np.array([], dtype=int)
  203. spike_times_right = np.array([]) * ms
  204. if stim_num_right > 0:
  205. try:
  206. pulse_times_ms_right = generate_random_pulse_times_strict_constrained(start_time_ms, end_time_ms, stim_num_right)
  207. input_neuron_indices_right = np.repeat(np.arange(N1), stim_num_right)
  208. spike_times_right = np.tile(pulse_times_ms_right, N1)*ms
  209. except ValueError as e:
  210. print(f"Simulation (diff={left_right_diff_val}, run={iteration_num}) for RIGHT side failed: {e}")
  211. return
  212. net = OrderedDict()
  213. net['input_neurons_left'] = SpikeGeneratorGroup(N1, input_neuron_indices_left, spike_times_left)
  214. net['input_neurons_right'] = SpikeGeneratorGroup(N1, input_neuron_indices_right, spike_times_right)
  215. net['E']=NeuronGroup(2*params['N_E'],E_equations,method='rk2',threshold='V > Vth',reset='V = Vreset;w_SFA+=b_SFA',refractory=params['tau_ref_E'],namespace=params)
  216. net['E_left']= net['E'][0:params['N_E']]
  217. net['E_right']= net['E'][params['N_E']:]
  218. net['I_left']=NeuronGroup(params['N_I'],I_equations,method='rk2',threshold='V > Vth',reset='V = Vreset',refractory=params['tau_ref_I'],namespace=params)
  219. net['I_right']=NeuronGroup(params['N_I'],I_equations,method='rk2',threshold='V > Vth',reset='V = Vreset',refractory=params['tau_ref_I'],namespace=params)
  220. net['pgE_left'] = PoissonGroup(params['N_E'], params['nu_ext'])
  221. net['pgI_left'] = PoissonGroup(params['N_I'], params['nu_ext'])
  222. net['pgE_right'] = PoissonGroup(params['N_E'], params['nu_ext'])
  223. net['pgI_right'] = PoissonGroup(params['N_I'], params['nu_ext'])
  224. if len(input_neuron_indices_left) > 0:
  225. net['inE_left']=Synapses(net['input_neurons_left'], net['E_left'][pulse_params_local['start_index']:pulse_params_local['end_index']],on_pre='sAMPA_input += 1',delay=delay)
  226. net['inE_left'].connect(condition='i == j')
  227. if len(input_neuron_indices_right) > 0:
  228. net['inE_right']=Synapses(net['input_neurons_right'], net['E_right'][pulse_params_local['start_index']:pulse_params_local['end_index']],on_pre='sAMPA_input += 1',delay=delay)
  229. net['inE_right'].connect(condition='i == j')
  230. net['icE_left'] = Synapses(net['pgE_left'], net['E_left'],on_pre='sAMPA_ext += 1', delay=delay)
  231. net['icE_left'].connect(condition='i == j')
  232. net['icE_right'] = Synapses(net['pgE_right'], net['E_right'],on_pre='sAMPA_ext += 1', delay=delay)
  233. net['icE_right'].connect(condition='i == j')
  234. net['icI_left'] = Synapses(net['pgI_left'], net['I_left'],on_pre='sAMPA_ext += 1', delay=delay)
  235. net['icI_left'].connect(condition='i == j')
  236. net['icI_right'] = Synapses(net['pgI_right'], net['I_right'],on_pre='sAMPA_ext += 1', delay=delay)
  237. net['icI_right'].connect(condition='i == j')
  238. net['icAMPA_left'] = Synapses(net['E_left'], net['E_left'], on_pre='sAMPA += 1', delay=delay)
  239. net['icAMPA_left'].connect(condition='i == j')
  240. net['icNMDA_left'] = Synapses(net['E_left'], net['E_left'], on_pre='x += 1', delay=delay)
  241. net['icNMDA_left'].connect(condition='i == j')
  242. net['icGABA_left'] = Synapses(net['I_left'], net['I_left'], on_pre='sGABA += 1', delay=delay)
  243. net['icGABA_left'].connect(condition='i == j')
  244. net['icAMPA_right'] = Synapses(net['E_right'], net['E_right'], on_pre='sAMPA += 1', delay=delay)
  245. net['icAMPA_right'].connect(condition='i == j')
  246. net['icNMDA_right'] = Synapses(net['E_right'], net['E_right'], on_pre='x += 1', delay=delay)
  247. net['icNMDA_right'].connect(condition='i == j')
  248. net['icGABA_right'] = Synapses(net['I_right'], net['I_right'], on_pre='sGABA += 1', delay=delay)
  249. net['icGABA_right'].connect(condition='i == j')
  250. @network_operation(when='start')
  251. def recurrent_input():
  252. sAMPA_gpu_left = cp.asarray(net['E_left'].sAMPA)
  253. sNMDA_gpu_left = cp.asarray(net['E_left'].sNMDA)
  254. sAMPA_gpu_right = cp.asarray(net['E_right'].sAMPA)
  255. sNMDA_gpu_right = cp.asarray(net['E_right'].sNMDA)
  256. net['E_left'].S_AMPA = cp.dot(sAMPA_gpu_left, weight_matrix_gpu).get()
  257. net['E_left'].S_NMDA = cp.dot(sNMDA_gpu_left, weight_matrix_gpu).get()
  258. net['I_left'].S_AMPA=sum(net['E_left'].sAMPA)
  259. net['I_left'].S_NMDA=sum(net['E_left'].sNMDA)
  260. net['E_right'].S_AMPA = cp.dot(sAMPA_gpu_right, weight_matrix_gpu).get()
  261. net['E_right'].S_NMDA = cp.dot(sNMDA_gpu_right, weight_matrix_gpu).get()
  262. net['I_right'].S_AMPA=sum(net['E_right'].sAMPA)
  263. net['I_right'].S_NMDA=sum(net['E_right'].sNMDA)
  264. net['E_left'].S_GABA=sum(net['I_left'].sGABA)
  265. net['E_right'].S_GABA=sum(net['I_right'].sGABA)
  266. net['I_left'].S_GABA=sum(net['I_left'].sGABA)
  267. net['I_right'].S_GABA=sum(net['I_right'].sGABA)
  268. net['E_left'].V = np.random.uniform(params['Vreset'],params['Vth'],size=params['N_E']) * volt
  269. net['I_left'].V = np.random.uniform(params['Vreset'],params['Vth'],size=params['N_I']) * volt
  270. net['E_right'].V = np.random.uniform(params['Vreset'],params['Vth'],size=params['N_E']) * volt
  271. net['I_right'].V = np.random.uniform(params['Vreset'],params['Vth'],size=params['N_I']) * volt
  272. spikemon_E = SpikeMonitor(net['E'])
  273. defaultclock.dt=0.05*ms
  274. total_duration = sim_params_local['sim_purations']
  275. network = Network(list(net.values()) + [recurrent_input, spikemon_E])
  276. print(f"Continuous Model (diff={left_right_diff_val}, run={iteration_num}): Starting...")
  277. network.run(total_duration, report='text')
  278. spike_data = np.column_stack((spikemon_E.i, spikemon_E.t/ms))
  279. np.savetxt(txt_save_path, spike_data, fmt=['%d', '%.4f'])
  280. print(f"Continuous Model (diff={left_right_diff_val}, run={iteration_num}): Saved to {txt_save_path}")
  281. del weight_matrix_gpu
  282. try:
  283. cp.get_default_memory_pool().free_all_blocks()
  284. except:
  285. pass
  286. def run_purkinje_layer(args):
  287. left_right_diff_val, iteration_num, gGABA_val = args
  288. start_scope()
  289. output_dir = os.path.join(base_data_dir, f'{gGABA_val}nS', f'{left_right_diff_val}')
  290. os.makedirs(output_dir, exist_ok=True)
  291. txt_load_path = os.path.join(base_data_dir, f'{left_right_diff_val}', f'E_spikes_run_{iteration_num}.txt')
  292. if not os.path.exists(txt_load_path):
  293. print(f"Error: Continuous model data not found at {txt_load_path}")
  294. return
  295. np.random.seed(iteration_num)
  296. params = continuous_model_params.copy()
  297. gc_par_local = gc_par.copy()
  298. PC_par_local = PC_par.copy()
  299. sim_params_local = sim_params.copy()
  300. PC_par_local['gGABA'] = gGABA_val * nS
  301. PC_par_local['gAMPA'] = PC_par_local['gAMPA'] / gc_par_local['N_gc']
  302. try:
  303. loaded_data = np.loadtxt(txt_load_path)
  304. if loaded_data.size == 0:
  305. E_replay_indices = np.array([], dtype=int)
  306. E_replay_times = np.array([]) * ms
  307. elif loaded_data.ndim == 1:
  308. E_replay_indices = np.array([int(loaded_data[0])])
  309. E_replay_times = np.array([loaded_data[1]]) * ms
  310. else:
  311. E_replay_indices = loaded_data[:, 0].astype(int)
  312. E_replay_times = loaded_data[:, 1] * ms
  313. except Exception as e:
  314. print(f"Error reading file {txt_load_path}: {e}")
  315. return
  316. net = OrderedDict()
  317. net['E_replay'] = SpikeGeneratorGroup(2 * params['N_E'], E_replay_indices, E_replay_times)
  318. net['E'] = net['E_replay']
  319. net['pgr'] = PoissonGroup(gc_par_local['N_gc'], rates=gc_par_local['possion_noise'])
  320. net['gc_layer'] = NeuronGroup(gc_par_local['N_gc'], model=eqs_gc,threshold='v >= vpeak',reset='v = c_reset; u += d_reset',method='euler',namespace=gc_par_local)
  321. net['gc_layer'].v = gc_par_local['vr']
  322. net['gc_layer'].u = gc_par_local['b'] * (net['gc_layer'].v - gc_par_local['vr'])
  323. net['PC_neuron_left'] = NeuronGroup(PC_par_local['N'], eqs_pc, threshold='v >= VSpike', reset='v = vreset; w += b', method='euler',namespace=PC_par_local)
  324. net['PC_neuron_right'] = NeuronGroup(PC_par_local['N'], eqs_pc, threshold='v >= VSpike', reset='v = vreset; w += b', method='euler',namespace=PC_par_local)
  325. net['PC_neuron_left'].v = -55 * mV
  326. net['PC_neuron_left'].w = 0* pA
  327. net['PC_neuron_right'].v = -55 * mV
  328. net['PC_neuron_right'].w = 0* pA
  329. net['gc_left']=net['gc_layer'][0:gc_par_local['N_gc'] // 2]
  330. net['gc_right']=net['gc_layer'][gc_par_local['N_gc'] // 2:]
  331. net['icgr']=Synapses(net['pgr'],net['gc_layer'],on_pre="sAMPA_noise+=1",namespace=gc_par_local)
  332. net['icgr'].connect(condition='i == j')
  333. pre_indices = []
  334. post_indices = []
  335. E_left_global_indices = np.arange(params['N_E'])
  336. E_right_global_indices = np.arange(params['N_E'], 2 * params['N_E'])
  337. for l in range(gc_par_local['N_gc'] // 2):
  338. chosen_pre_indices = np.random.choice(E_left_global_indices, size=gc_par_local['mossy_fiber_input_num'], replace=False)
  339. pre_indices.extend(chosen_pre_indices)
  340. post_indices.extend([l] * gc_par_local['mossy_fiber_input_num'])
  341. for l in range(gc_par_local['N_gc'] // 2, gc_par_local['N_gc']):
  342. chosen_pre_indices = np.random.choice(E_right_global_indices, size=gc_par_local['mossy_fiber_input_num'], replace=False)
  343. pre_indices.extend(chosen_pre_indices)
  344. post_indices.extend([l] * gc_par_local['mossy_fiber_input_num'])
  345. net['icEgr']=Synapses(net['E'],net['gc_layer'],on_pre="sAMPA+=1",namespace=gc_par_local)
  346. net['icEgr'].connect(i=pre_indices, j=post_indices)
  347. net['icgrPc_left']=Synapses(net['gc_left'], net['PC_neuron_left'], on_pre='sAMPA_post += 1')
  348. net['icgrPc_left'].connect()
  349. net['icgrPc_right']=Synapses(net['gc_right'], net['PC_neuron_right'], on_pre='sAMPA_post += 1')
  350. net['icgrPc_right'].connect()
  351. net['icPcPc_left']=Synapses(net['PC_neuron_left'],net['PC_neuron_left'],on_pre='sGABA+=1')
  352. net['icPcPc_left'].connect('i==j')
  353. net['icPcPc_right']=Synapses(net['PC_neuron_right'],net['PC_neuron_right'],on_pre='sGABA+=1')
  354. net['icPcPc_right'].connect('i==j')
  355. @network_operation(when='start')
  356. def recurrent_input_pc():
  357. net['PC_neuron_left'].S_GABA=sum(net['PC_neuron_right'].sGABA)/PC_par_local['N']
  358. net['PC_neuron_right'].S_GABA=sum(net['PC_neuron_left'].sGABA)/PC_par_local['N']
  359. spikemon_PC_left = SpikeMonitor(net['PC_neuron_left'])
  360. spikemon_PC_right = SpikeMonitor(net['PC_neuron_right'])
  361. defaultclock.dt=0.05*ms
  362. total_duration = sim_params_local['sim_purations']
  363. network = Network(list(net.values()) + [recurrent_input_pc, spikemon_PC_left, spikemon_PC_right])
  364. print(f"Purkinje Simulation (gGABA={gGABA_val}nS, diff={left_right_diff_val}, run={iteration_num}): Starting run...")
  365. try:
  366. network.run(total_duration, report='text')
  367. print(f"Purkinje Simulation (gGABA={gGABA_val}nS, diff={left_right_diff_val}, run={iteration_num}): Finished run.")
  368. except Exception as e:
  369. print(f"Purkinje Simulation (gGABA={gGABA_val}nS, diff={left_right_diff_val}, run={iteration_num}): Failed with error: {e}")
  370. return
  371. PC_spike_times_left = spikemon_PC_left.t
  372. PC_spike_indices_left = spikemon_PC_left.i
  373. PC_spike_times_right = spikemon_PC_right.t
  374. PC_spike_indices_right = spikemon_PC_right.i
  375. np.save(os.path.join(output_dir, f'spikes_PC_left_t_run_{iteration_num}.npy'), PC_spike_times_left/ms)
  376. np.save(os.path.join(output_dir, f'spikes_PC_left_i_run_{iteration_num}.npy'), PC_spike_indices_left)
  377. np.save(os.path.join(output_dir, f'spikes_PC_right_t_run_{iteration_num}.npy'), PC_spike_times_right/ms)
  378. np.save(os.path.join(output_dir, f'spikes_PC_right_i_run_{iteration_num}.npy'), PC_spike_indices_right)
  379. window_size = 100*ms
  380. step_size = 2*ms
  381. time_points, rate_PC_left = calculate_sliding_window_rate(PC_spike_times_left, PC_par_local['N'], total_duration, window_size, step_size)
  382. _, rate_PC_right = calculate_sliding_window_rate(PC_spike_times_right, PC_par_local['N'], total_duration, window_size, step_size)
  383. np.save(os.path.join(output_dir, f'rates_time_points_run_{iteration_num}.npy'), time_points)
  384. np.save(os.path.join(output_dir, f'rates_PC_left_run_{iteration_num}.npy'), rate_PC_left)
  385. np.save(os.path.join(output_dir, f'rates_PC_right_run_{iteration_num}.npy'), rate_PC_right)
  386. if __name__ == '__main__':
  387. try:
  388. multiprocessing.set_start_method('spawn', force=True)
  389. except RuntimeError:
  390. pass
  391. # phase1_gpu_config = {
  392. # 1: 3,
  393. # 2: 3,
  394. # 3: 3,
  395. # 4: 3,
  396. # 5: 3
  397. # }
  398. phase1_gpu_config = {
  399. 0:3
  400. }
  401. phase1_num_processes_to_use = sum(list(phase1_gpu_config.values()))
  402. phase1_gpu_pool = []
  403. for gid, threads in phase1_gpu_config.items():
  404. phase1_gpu_pool.extend([gid] * threads)
  405. # -------------------------------------------------------------
  406. left_right_diff_values = [1,3,5,9,13]
  407. num_runs_per_diff = 255
  408. gGABA_values = range(2, 31)
  409. num_processes_to_use = 255
  410. # -------------------------------------------------------------
  411. print(f"Using {phase1_num_processes_to_use} processes for Phase 1 multiprocessing.")
  412. print(f"Using {num_processes_to_use} processes for Phase 2 multiprocessing.")
  413. for diff_val in left_right_diff_values:
  414. print(f"\n=== Phase 1: Running Continuous Model for diff = {diff_val} ===")
  415. phase1_tasks = []
  416. for run_idx in range(1, num_runs_per_diff + 1):
  417. expected_txt_path = os.path.join(base_data_dir, f'{diff_val}', f'E_spikes_run_{run_idx}.txt')
  418. if os.path.exists(expected_txt_path):
  419. print(f"File exists, skipping Phase 1 task submission for diff={diff_val}, run={run_idx}")
  420. continue
  421. assigned_gpu = phase1_gpu_pool[run_idx % len(phase1_gpu_pool)]
  422. phase1_tasks.append((diff_val, run_idx, assigned_gpu))
  423. if len(phase1_tasks) > 0:
  424. print(f"Submitting {len(phase1_tasks)} Phase 1 tasks...")
  425. with multiprocessing.Pool(processes=phase1_num_processes_to_use) as pool:
  426. for _ in pool.imap_unordered(run_continuous_layer, phase1_tasks):
  427. pass
  428. else:
  429. print("All Phase 1 tasks already completed. Skipping simulation.")
  430. for g_val in gGABA_values:
  431. print(f"\n=== Processing gGABA = {g_val}nS, left_right_diff = {diff_val} ===")
  432. print(f"--- Phase 2: Running Purkinje Model (Multi Threaded) ---")
  433. current_tasks = []
  434. for run_idx in range(1, num_runs_per_diff + 1):
  435. current_tasks.append((diff_val, run_idx, g_val))
  436. print(f"Submitting {len(current_tasks)} tasks for gGABA = {g_val}nS...")
  437. with multiprocessing.Pool(processes=num_processes_to_use) as pool:
  438. for _ in pool.imap_unordered(run_purkinje_layer, current_tasks):
  439. pass
  440. print(f"--- Finished gGABA = {g_val}nS ---")
  441. print(f"\nAll simulations completed across all gGABA and diff_values.")

cortico-cerebellar.py at commit e03ac74, no license · at the source

Overview

Authors: Yeyao Bao1,2, Liao Yu3, Liangfu Lu1,2, Zhuoqin Yang3, Yunliang Zang1,2
  1. Academy of Medical Engineering and Translational Medicine, Medical Faculty, Tianjin University, Tianjin 300072, China
  2. State Key Laboratory of Advanced Medical Materials and Medical Devices, Tianjin University, Tianjin 300072, China
  3. School of Mathematical Sciences, Beihang University, Beijing 100191, China
Institutions: Tianjin University (China); Beihang University (China)
Dates: received 13 May 2026; accepted 22 July 2026; published online 27 August 2026; in print 1 September 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI 10.1073/pnas.2616911123 · PMID 42658769 · PMCID PMC13534631 · OpenAlex W7204485119
Open access: hybrid, a free copy (OpenAlex)
Status: code verified
Categories: computational modeling (no new data) (modality), human (organism), cognitive (subfield)
Methods: Smoothing, state filtering, decompositions, Single-unit activity, calcium imaging, Connectivity
Keywords: cerebellar learning, decision-making, feedforward network, primacy bias, pattern separation
MeSH: Cerebellar Cortex*, Cerebellum*, Decision Making*, Models, Neurological*, Animals, Computer Simulation, Humans, Nerve Net, Purkinje Cells (* major topic)
Topic: Vestibular and auditory disorders (Neurology, Neuroscience), according to OpenAlex
Funding: The National Key Research and Development Program of China (2023YFF1204200); the National Natural Science Foundation of China (12372060, 62476197)
Citations: cited by 1 paper (Europe PMC); 88 references in the paper

Abstract

The cerebellum is increasingly implicated in perceptual decision-making, yet it remains unclear how the cerebellar cortex can support sparse evidence accumulation over behavioral time scales without assuming cortical-style dense local excitatory recurrence. We present a biologically constrained modeling framework showing that cerebellar microcircuits can implement graded accumulation and competition in the absence of such recurrence. In our model, type-II Purkinje-neuron excitability generates firing-rate hysteresis that prolongs the impact of brief inputs far beyond intrinsic membrane and synaptic time constants, enabling accumulation across long interevent intervals. Purkinje neuron collateral inhibition produces competitive divergence and tunes temporal evidence weighting, revealing a trade-off between commitment and primacy bias. In a bidirectionally coupled cortico-cerebello-cortical model, cerebellar processing reduces primacy while cortical processing reduces indecision, improving robustness. Finally, granule-layer sparsification improves the separability of correlated inputs, enhancing discrimination under biologically realistic stimulus statistics. Together, these simulation results propose a mechanistic division of labor that positions the cerebellum as an active computational partner in perceptual decisions.

Reproduced under the paper's license (CC BY), from the paper cited above.

Repository

Its files are read in the Code ↔ Paper reader above.

yyb177/cerebellar-decision-making

License: none: the authors keep all their rights
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Commit: e03ac74ba0c66ccb4bb275d1b81b8defd1122c7d, 13 May 2026
Languages: Python (3)
Size: 4 files, 3 scripts
Software Heritage: not archived
Found in: the references
Holds: README
Not found: license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: Brian 2 (3 files), NumPy (3 files), CuPy (2 files), Matplotlib (2 files)
Availability: 1 check, the latest on 27 September 2026: the link answers
  • 27 September 2026: the link answers
4 files

The paper's code and data availability statement is in the Data section.

Tracing map

Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.

What the map holds:

  • 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
  • 3 scripts, each with its path and the digest of its content;
  • no match between paragraphs and code yet;
  • neither the text of the paper nor the code itself.

Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.

Data

No dataset and no data link were found in the paper.

Data, Materials, and Software Availability

The simulation code used in this study is publicly available at GitHub (88).

Reproduced under the paper's license (CC BY), from the paper cited above.

Versions

The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.

Version 1, 27 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 5 authors, 5 keywords, 9 MeSH terms, 2 funders, 87 references.

Cite

This paper

Bao, Y., Yu, L., Lu, L., Yang, Z., & Zang, Y. (2026). Cerebellar microcircuits enable robust evidence-based decisions through cortico-cerebellar coupling. Proceedings of the National Academy of Sciences of the United States of America, 123(35), e2616911123. https://doi.org/10.1073/pnas.2616911123

BibTeX

@article{bao2026cerebellar,
author = {Bao, Yeyao and Yu, Liao and Lu, Liangfu and Yang, Zhuoqin and Zang, Yunliang},
title = {{Cerebellar microcircuits enable robust evidence-based decisions through cortico-cerebellar coupling}},
journal = {Proceedings of the National Academy of Sciences of the United States of America},
year = {2026},
month = aug,
volume = {123},
number = {35},
pages = {e2616911123},
publisher = {National Academy of Sciences},
issn = {0027-8424},
doi = {10.1073/pnas.2616911123},
url = {https://doi.org/10.1073/pnas.2616911123},
pmid = {42658769},
pmcid = {PMC13534631}
}

RIS

TY - JOUR
AU - Bao, Yeyao
AU - Yu, Liao
AU - Lu, Liangfu
AU - Yang, Zhuoqin
AU - Zang, Yunliang
TI - Cerebellar microcircuits enable robust evidence-based decisions through cortico-cerebellar coupling
T2 - Proceedings of the National Academy of Sciences of the United States of America
J2 - Proc Natl Acad Sci U S A
PY - 2026
DA - 2026/08/27
VL - 123
IS - 35
SP - e2616911123
SN - 0027-8424
PB - National Academy of Sciences
DO - 10.1073/pnas.2616911123
UR - https://doi.org/10.1073/pnas.2616911123
LA - en
ER -

CSL-JSON

{
"id": "10.1073/pnas.2616911123",
"type": "article-journal",
"title": "Cerebellar microcircuits enable robust evidence-based decisions through cortico-cerebellar coupling",
"container-title": "Proceedings of the National Academy of Sciences of the United States of America",
"author": [
{
"family": "Bao",
"given": "Yeyao"
},
{
"family": "Yu",
"given": "Liao"
},
{
"family": "Lu",
"given": "Liangfu"
},
{
"family": "Yang",
"given": "Zhuoqin"
},
{
"family": "Zang",
"given": "Yunliang"
}
],
"container-title-short": "Proc Natl Acad Sci U S A",
"volume": "123",
"issue": "35",
"page": "e2616911123",
"DOI": "10.1073/pnas.2616911123",
"PMID": "42658769",
"PMCID": "PMC13534631",
"ISSN": "0027-8424",
"publisher": "National Academy of Sciences",
"URL": "https://doi.org/10.1073/pnas.2616911123",
"language": "en",
"issued": {
"date-parts": [
[
2026,
8,
27
]
]
}
}

The tracing map gets a citation of its own once an author has validated it and it has a DOI.

Similar papers

The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.

[1] doi:10.1371/journal.pcbi.1014595 [code]
Cerebellum-inspired neural network of supervised learning with tensor-based sparse coding for multi-class classification.
Journal: PLoS computational biology
In common: Matplotlib, NumPy, 6 references
[2] doi:10.1038/s41593-026-02255-7 [code]
Neural circuits encode prior knowledge of temporal statistics.
Journal: Nature neuroscience
In common: Matplotlib, NumPy, 6 references
[3] doi:10.1016/j.celrep.2026.117262 [code]
Cerebellar acceleration of learning in an evidence-accumulation task.
Journal: Cell reports
In common: Matplotlib, NumPy, cognitive, 5 references
[4] doi:10.1126/sciadv.aed6417 [code]
Intrinsic timing, not temporal prediction, underlies ramping dynamics in visual and parietal cortex during passive behavior.
Journal: Science advances
In common: Matplotlib, NumPy, 5 references
[5] doi:10.1038/s41467-026-75924-7 [code]
Data-driven reduced modeling of neural dynamics.
Journal: Nature communications
In common: Matplotlib, NumPy, computational modeling (no new data), 4 references
[6] doi:10.1038/s41467-026-75371-4 [code]
Cerebellar neural populations orchestrate dopamine reward signaling with single-trial precision.
Journal: Nature communications
In common: Matplotlib, NumPy, 4 references
[7] doi:10.1038/s41467-026-75704-3 [code]
A minimal model of working memory in neural systems and neuromorphic circuits.
Journal: Nature communications
In common: Brian 2, Matplotlib, NumPy, computational modeling (no new data), 1 reference
[8] doi:10.7554/elife.102813
Multiple functions of cerebello-thalamic neurons in learning and offline consolidation of a motor skill in mice.
Journal: eLife
In common: 4 references
[9] doi:10.1038/s42003-026-10034-0 [code]
Region- and cell type-specific changes in gene expression in the cerebellum after classical fear conditioning.
Journal: Communications biology
In common: Matplotlib, NumPy, 3 references
[10] doi:10.1038/s41593-026-02388-9 [code]
Hippocampal CA3 connectomics reveals a gradient of mossy fiber inputs and selective feedforward inhibition onto pyramidal cells.
Journal: Nature neuroscience
In common: Matplotlib, NumPy, 3 references

Contribute

The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.

Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.

Request its removal

To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).

Discussion, reproductions, activity

Discussion: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.

Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.

Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.