OSCR

Distinct Disinhibitory Circuits Link Short-Term Adaptation to Familiarity and Reward Learning in Visual Cortex

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; OSCR does not store it: doi.org · Europe PMC

The paper is loaded when this pane is shown.

The authors' code

Jupyter notebook · 642 lines · 22 KB · Apache-2.0

  1. # %% [markdown]
  2. # # Model Implementation Habituation Session 1
  3. # %% [markdown]
  4. # # Imports
  5. # %%
  6. import numpy as np
  7. import random
  8. import pandas as pd
  9. import matplotlib.pyplot as plt
  10. from scipy.integrate import odeint, solve_ivp
  11. import seaborn as sns
  12. from sklearn.metrics import mean_squared_error, r2_score
  13. from lmfit import Parameters
  14. from IPython import display
  15. # %% [markdown]
  16. # # Model diagram
  17. # %%
  18. display.Image(r'Model_diagram.png')
  19. # %% [markdown]
  20. # # Functions
  21. # %%
  22. def Step(t, stim = 5, inter = 10, amp = 1.0, base = 0, k = 0, delay = 0, decay_f = 0):
  23. """
  24. Feedback (FB) input:
  25. ------------------------------------
  26. Represented as a step function. Returns value of the input function in a time point t.
  27. ------------------------------------
  28. Parameters:
  29. t (running) - time in seconds;
  30. stim (fixed) = 5 s - time of the stimulus start;
  31. inter (fixed) = 10 s - duration of the stimulus;
  32. amp (fixed) = 1.0 Hz - amplitude of response;
  33. base (fixed) = 0 Hz - baseline activity;
  34. k (fixed) = 0 - slope of the slow component. Used to be varied while testing linear depression or sensitization component in the FB input;
  35. delay (variable) - delay of the FB input to the cell relative to the stimulus start;
  36. """
  37. if (t < stim + delay):
  38. h = base
  39. elif (t > stim + inter):
  40. h = amp * np.exp(-(t - stim - inter)*decay_f)
  41. else:
  42. h = amp*(t - stim - delay)*k*0.164745 + amp
  43. return h
  44. # %%
  45. def Sigm(t, stim = 5, inter = 10, ampl = 1.0, base = 0, rate = 1, delay = 0, decay_s = 1, dt = 0):
  46. """
  47. Slow Sensitizing (SS) input:
  48. ------------------------------------
  49. Represented as a sigmoid function. Returns value of the input function in a time point t.
  50. ------------------------------------
  51. Parameters:
  52. t (running) - time in seconds;
  53. stim (fixed) = 5 s - time of the stimulus start;
  54. inter (fixed) = 10 s - duration of the stimulus;
  55. ampl (fixed) = 1.0 Hz - amplitude of response;
  56. base (fixed) = 0 Hz - baseline activity;
  57. rate (variable) - time-constant of the SS input;
  58. delay (variable) - shift of the sigmoid center relative to stimulus start;
  59. decay_s (variable) - time-constant of the SS input exponential decay after the end of stimulation;
  60. """
  61. if (t < stim):
  62. h = base
  63. elif (t > stim + inter):
  64. h = (base + (ampl/(1 + np.exp((delay-inter - dt)/rate))))*np.exp(-(t - stim - inter)*decay_s) + base
  65. else:
  66. h = base + (ampl/(1 + np.exp((stim + delay - t)/rate))) #Actualy rate here is time constant, where 1/rate is actual rate
  67. return h
  68. # %%
  69. def expon(t, stim = 5, inter = 10, ampl = 1.5, base = 0, decay = 1, delay = 0, b = 0, decay_ff = 0, s_start = 0.1, k = 0.1):
  70. """
  71. Feedforward (FF) input:
  72. ------------------------------------
  73. Represented as a flat step function with fast exponential decay on the stimulus start and linear increase during 10 second period.
  74. Returns value of the input function in a time point t.
  75. ------------------------------------
  76. Parameters:
  77. t (running) - time in seconds;
  78. stim (fixed) = 5 s - time of the stimulus start;
  79. inter (fixed) = 10 s - duration of the stimulus;
  80. ampl (variable) - amplitude of peak;
  81. base (fixed) = 1 Hz - steady-state firing rate after fast exponential depression;
  82. decay (variable) - time-constant of the fast exponential depression;
  83. delay (variable) - delay of the FF input to the cell relative to the stimulus start;
  84. b (fixed) = 0 Hz - baseline activity;
  85. decay_ff (varaible) - time-constant of the FF input exponential decay after the end of stimulation;
  86. s_start (varaible) - delay after stimulus when linear modulation starts;
  87. k (varaible) - slope of the slow linear modulation;
  88. """
  89. if (t < stim + delay):
  90. h = b
  91. elif (t > stim + inter):
  92. h = (b + base + ampl*np.exp(-(inter-delay)*decay)+ (inter - delay - s_start)*k)*np.exp(-(t - stim - inter)*decay_ff)
  93. elif ((t >= stim + delay) and (t < stim + delay + s_start)):
  94. h = b + base + ampl*np.exp(-(t - stim - delay)*decay)
  95. else:
  96. h = b + base + ampl*np.exp(-(t - stim - delay)*decay)+ ((t - stim - delay - s_start)*k)
  97. return h
  98. # %%
  99. def model_step(t,
  100. y,
  101. w_0, w_1, w_2, w_3, w_4, w_5, w_6, w_7, w_8, w_9, w_10, w_11, w_12, w_13, w_14, w_15, w_16, w_17, w_18,
  102. w_19, w_20, w_21, w_22, w_23, tau_0, tau_1, tau_2, tau_3,
  103. threshold,
  104. power,
  105. q,
  106. i_0, i_1, i_2, i_3, i_4,
  107. r_1, decay, delay_1, delay_2, delay_3, ampl, base, decay_s, ampl_1, base_sigm, decay_f, decay_ff, s_start, k
  108. ):
  109. """
  110. Model basis:
  111. ------------------------------------
  112. Systems of first order differential equations that captures activity of populations (df_xdt).
  113. Returns an array of values of the derrivatives at a certain timepoint, calculated from values of functions in previous timepoint.
  114. ------------------------------------
  115. Parameters:
  116. t (running) - time in seconds;
  117. y (running) - values of activities on the previous timepoint;
  118. w_x (variable) - synaptic weights;
  119. tau_x (fixed) - neurons time-constants;
  120. threshold (fixed) = 0 Hz - minimum rectification value;
  121. power (fixed) = 2 - value of the power in the input-output function;
  122. q (fixed) = 1 - normalization coeficient in the input-output function;
  123. i_x (variable) - baseline activity of neurons;
  124. ...
  125. """
  126. f_e, f_p, f_s, f_v_pos, f_v_neg = y
  127. ## Model equations
  128. ff_e = (min(max((i_0 + w_0 * f_e + w_1 * expon(t, ampl = ampl, base = base, decay = decay, delay = delay_1, decay_ff = decay_ff, s_start = s_start, k = k) + w_2 * Sigm(t, ampl = ampl_1, rate = r_1, delay = delay_2, decay_s = decay_s, base = base_sigm) + w_16 * Step(t, k = 0, delay = delay_3, decay_f = decay_f) - w_3 * f_p - w_4 * f_s), threshold), 25))
  129. ff_p = (min(max((i_1 + w_17 * Step(t, k = 0, delay = delay_3, decay_f = decay_f) + w_5 * f_e + w_6 * expon(t, ampl = ampl, base = base, decay = decay, delay = delay_1, decay_ff = decay_ff, s_start = s_start, k = k) + w_7 * Sigm(t, ampl = ampl_1, rate = r_1, delay = delay_2, decay_s = decay_s, base = base_sigm) - w_8 * f_p - w_9 * f_s), threshold), 25))
  130. ff_s = (min(max((i_2 + w_10 * f_e + w_11 * Step(t, k = 0, delay = delay_3, decay_f = decay_f) - w_12 * f_v_pos - w_23 * f_v_neg), threshold), 25))
  131. ff_v_pos = (min(max((i_3 + w_18 * Step(t, k = 0, delay = delay_3, decay_f = decay_f) + w_13 * f_e - w_14 * f_s + w_15 * Sigm(t, ampl = ampl_1, rate = r_1, delay = delay_2, decay_s = decay_s, base = base_sigm)), threshold), 25))
  132. ff_v_neg = (min(max((i_4 + w_19 * Step(t, k = 0, delay = delay_3, decay_f = decay_f) + w_20 * f_e - w_21 * f_s + w_22 * Sigm(t, ampl = ampl_1, rate = r_1, delay = delay_2, decay_s = decay_s, base = base_sigm)), threshold), 25))
  133. df_edt = ((q * ff_e ** power) - f_e) / tau_0
  134. df_pdt = ((q * ff_p ** power) - f_p) / tau_1
  135. df_sdt = ((q * ff_s ** power) - f_s) / tau_2
  136. df_v_posdt = ((q * ff_v_pos ** power) - f_v_pos) / tau_3
  137. df_v_negdt = ((q * ff_v_neg ** power) - f_v_neg) / tau_3
  138. dydt = [df_edt, df_pdt, df_sdt, df_v_posdt, df_v_negdt]
  139. return dydt
  140. # %%
  141. names = ['PC_PC', # w_0
  142. 'FF_PC', # w_1
  143. 'SS_PC', # w_2
  144. 'PV_PC', # w_3
  145. 'SST_PC', # w_4
  146. 'PC_PV', # w_5
  147. 'FF_PV', # w_6
  148. 'SS_PV', # w_7
  149. 'PV_PV', # w_8
  150. 'SST_PV', # w_9
  151. 'PC_SST', # w_10
  152. 'FB_SST', # w_11
  153. 'VIP+_SST', # w_12
  154. 'PC_VIP+', # w_13
  155. 'SST_VIP+', # w_14
  156. 'SS_VIP+', # w_15
  157. 'FB_PC', # w_16
  158. 'FB_PV', # w_17
  159. 'FB_VIP+', # w_18
  160. 'FB_VIP-', # w_19
  161. 'PC_VIP-', # w_20
  162. 'SST_VIP-', # w_21
  163. 'SS_VIP-', # w_22
  164. 'VIP-_SST']# w_23
  165. # %%
  166. def exp_time(start, step, count, endpoint=False):
  167. """
  168. Experimental timepoints calculation:
  169. ------------------------------------
  170. Returns an array of values of the experimental timepoints.
  171. ------------------------------------
  172. Parameters:
  173. start - starting point;
  174. step - value of time step of experimental recordings;
  175. count - number of points;
  176. """
  177. stop = start+(step*count)
  178. return np.linspace(start, stop, count, endpoint=endpoint)
  179. # %%
  180. def odesol_step(tt, init, params):
  181. """
  182. Solves differential equation system defined in model_step() function.
  183. """
  184. y_init = init
  185. w_0 = params['w_0'].value
  186. w_1 = params['w_1'].value
  187. w_2 = params['w_2'].value
  188. w_3 = params['w_3'].value
  189. w_4 = params['w_4'].value
  190. w_5 = params['w_5'].value
  191. w_6 = params['w_6'].value
  192. w_7 = params['w_7'].value
  193. w_8 = params['w_8'].value
  194. w_9 = params['w_9'].value
  195. w_10 = params['w_10'].value
  196. w_11 = params['w_11'].value
  197. w_12 = params['w_12'].value
  198. w_13 = params['w_13'].value
  199. w_14 = params['w_14'].value
  200. w_15 = params['w_15'].value
  201. w_16 = params['w_16'].value
  202. w_17 = params['w_17'].value
  203. w_18 = params['w_18'].value
  204. w_19 = params['w_19'].value
  205. w_20 = params['w_20'].value
  206. w_21 = params['w_21'].value
  207. w_22 = params['w_22'].value
  208. w_23 = params['w_23'].value
  209. tau_0 = params['tau_0'].value
  210. tau_1 = params['tau_1'].value
  211. tau_2 = params['tau_2'].value
  212. tau_3 = params['tau_3'].value
  213. threshold = params['threshold'].value
  214. power = params['power'].value
  215. q = params['q'].value
  216. i_0 = params['i_0'].value
  217. i_1 = params['i_1'].value
  218. i_2 = params['i_2'].value
  219. i_3 = params['i_3'].value
  220. i_4 = params['i_4'].value
  221. ampl_1 = params['ampl_1'].value
  222. r_1 = params['r_1'].value
  223. delay_1 = params['delay_1'].value
  224. delay_2 = params['delay_2'].value
  225. delay_3 = params['delay_3'].value
  226. decay = params['decay'].value
  227. decay_s = params['decay_s'].value
  228. decay_f = params['decay_f'].value
  229. decay_ff = params['decay_ff'].value
  230. ampl = params['ampl'].value
  231. base = params['base'].value
  232. base_sigm = params['base_sigm'].value
  233. s_start = params['s_start'].value
  234. k = params['k'].value
  235. sol = solve_ivp(lambda t, y: model_step(t, y,
  236. w_0, w_1, w_2, w_3, w_4, w_5, w_6, w_7, w_8, w_9, w_10, w_11, w_12, w_13, w_14, w_15, w_16, w_17, w_18,
  237. w_19, w_20, w_21, w_22, w_23, tau_0, tau_1, tau_2, tau_3,
  238. threshold,
  239. power,
  240. q,
  241. i_0, i_1, i_2, i_3, i_4,
  242. r_1, decay, delay_1, delay_2, delay_3, ampl, base, decay_s, ampl_1, base_sigm, decay_f, decay_ff, s_start, k
  243. ),
  244. [tt[0], tt[-1]],
  245. y_init,
  246. method='RK45',
  247. t_eval=tt,
  248. )
  249. return sol
  250. # %%
  251. def simulate_step(tt, init, params):
  252. """
  253. Model simulation:
  254. ------------------------------------
  255. Returns a Pandas DataFrame of timesteps and populational activity traces.
  256. ------------------------------------
  257. Parameters:
  258. tt (running) - current timepoint;
  259. init (fixed) - intial conditions for differential equations;
  260. params - lmfit.Parameters() object with all parameters from the differential equations systems
  261. """
  262. sol = odesol_step(tt, init, params)
  263. dd = np.vstack((sol.t, sol.y[0], sol.y[1], sol.y[2], sol.y[3], sol.y[4])).T
  264. sim = pd.DataFrame(dd, columns=['t', 'f_e', 'f_pv', 'f_sst', 'f_vip_pos', 'f_vip_neg'])
  265. return sim
  266. # %%
  267. def RMSE_full(params, init, data_pc, data_pv, data_sst, data_vip_pos, data_vip_neg):
  268. """
  269. Root:Mean Square Error (RMSE) calculation:
  270. ------------------------------------
  271. Returns RMSE value for full fit of 4 averages of populations: PC, PV, SST, VIP.
  272. ------------------------------------
  273. Parameters:
  274. params - Parameters() object with all parameters from the differential equations systems
  275. init (fixed) - intial conditions for differential equations;
  276. data_pc - PC experimental data trace;
  277. data_pv - PV experimental data trace;
  278. data_sst - SST experimental data trace;
  279. data_vip_pos - VIP Positive experimental data trace;
  280. data_vip_neg - VIP Negative experimental data trace;
  281. """
  282. model = simulate_step(t_exp, init, params)
  283. sum = 0
  284. for i in range(len(data_pc)):
  285. sum += (model['f_e'].values[i] - data_pc[i])**2 + (model['f_pv'].values[i] - data_pv[i])**2 + (model['f_sst'].values[i] - data_sst[i])**2 + (model['f_vip_pos'].values[i] - data_vip_pos[i])**2 + (model['f_vip_neg'].values[i] - data_vip_neg[i])**2
  286. sum_norm = np.sqrt((sum)/(len(data_pc)*5))
  287. return sum_norm
  288. # %% [markdown]
  289. # # Experimental data
  290. # %%
  291. #timepoint
  292. dt = 0.164745
  293. # PC_average (whole population)
  294. pc_all = np.loadtxt(r'Experimental_Data\QA_Nor_PC_All_AvgSess1.txt')
  295. # Experimental time calculation
  296. t_exp_1 = exp_time(start=0.0, step=dt, count=len(pc_all))
  297. # PV_average (whole population)
  298. pv = np.loadtxt(r'Experimental_Data\QA_Nor_PV_AvgSess1.txt')
  299. # SST_average (whole population)
  300. sst = np.loadtxt(r'Experimental_Data\QA_Nor_SST_AvgSess1.txt')
  301. # VIP_Positive (whole population)
  302. vip_pos = np.loadtxt(r'Experimental_Data\QA_Nor_VIP_AvgSess1_Pos.txt')
  303. # VIP_Negative (whole population)
  304. vip_neg = np.loadtxt(r'Experimental_Data\QA_Nor_VIP_AvgSess1_Neg.txt')
  305. # %%
  306. # Inicialization of new arrays to cut traces for suitable range
  307. t_exp_1_new = []
  308. pv_new = []
  309. sst_new = []
  310. vip_pos_new = []
  311. vip_neg_new = []
  312. pc_all_new = []
  313. # Cutting the traces
  314. for ind, time in np.ndenumerate(t_exp_1):
  315. if (time >= 5) and (time <= 25):
  316. t_exp_1_new.append(time - 5)
  317. pv_new.append(pv[ind])
  318. sst_new.append(sst[ind])
  319. vip_pos_new.append(vip_pos[ind])
  320. vip_neg_new.append(vip_neg[ind])
  321. pc_all_new.append(pc_all[ind])
  322. # Adjusting for a missing initial point after deconvolution
  323. pv_new.insert(0, pv_new[0])
  324. sst_new.insert(0, sst_new[0])
  325. vip_pos_new.insert(0, vip_pos_new[0])
  326. vip_neg_new.insert(0, vip_neg_new[0])
  327. pc_all_new.insert(0, pc_all_new[0])
  328. t_exp_1_new.append(t_exp_1_new[-1] + dt)
  329. # %% [markdown]
  330. # # Model parameters
  331. # %%
  332. # ===============================================================
  333. # Setting initial and working parameters
  334. # ===============================================================
  335. #Fixed parameters
  336. t = np.float32(np.array(t_exp_1_new))
  337. t_exp = t
  338. threshold = np.float32(0)
  339. power = np.float32(2.0)
  340. q = np.float32(1.0)
  341. ampl_1 = 1.0
  342. r_1 = np.float32(1.713939)
  343. delay_1 = np.float32(0.1650418)
  344. delay_2 = np.float32(1.73305)
  345. delay_3 = np.float32(0.3695274)
  346. decay = np.float32(3.324089)
  347. decay_s = np.float32(0.2685497)
  348. decay_f = np.float32(0.8342502)
  349. decay_ff = np.float32(2.152722)
  350. ampl = np.float32(1.0)
  351. base = np.float32(1.0)
  352. base_sigm = np.float32(0)
  353. s_start = np.float32(0.1835884)
  354. init = np.float32(np.array([0.055, 0.011, 0.017, 0.208, 1.000]))
  355. tau = np.float32(np.array([0.015, 0.0075, 0.019, 0.019]))
  356. #Variable parameters
  357. k = np.float32(0.027309763)
  358. i = np.float32(np.array([0.284447361, 0.011142876, 0.116241266, 0.50467562, 0.942411609]))
  359. w = np.float32(np.array([
  360. 0.080753061, # w_0 PC -> PC
  361. 1.836526807, # w_1 FF -> PC
  362. 0.784303879, # w_2 SS -> PC
  363. 2.063944459, # w_3 PV -> PC
  364. 0.748021346, # w_4 SST -> PC
  365. 0.388020396, # w_5 PC -> PV
  366. 1.142616121, # w_6 FF -> PV
  367. 1.791791214, # w_7 SS -> PV
  368. 1.595357309, # w_8 PV -> PV
  369. 0.334000211, # w_9 SST -> PV
  370. 0.904594776, # w_10 PC -> SST
  371. 0.493489103, # w_11 FB -> SST
  372. 0.159572032, # w_12 VIP+ -> SST
  373. 0.254720976, # w_13 PC -> VIP+
  374. 0.167011082, # w_14 SST -> VIP+
  375. 0.692450185, # w_15 SS -> VIP+
  376. 1.35949409, # w_16 FB -> PC
  377. 0.304908259, # w_17 FB -> PV
  378. 0.232536359, # w_18 FB -> VIP+
  379. 0.146459393, # w_19 FB -> VIP-
  380. 0.3620719, # w_20 PC -> VIP-
  381. 0.727962823, # w_21 SST -> VIP-
  382. 0.174327124, # w_22 SS -> VIP-
  383. 0.000760818]))# w_23 VIP- -> SST
  384. data_pv = np.float32(np.array(pv_new))
  385. data_sst = np.float32(np.array(sst_new))
  386. data_vip_pos = np.float32(np.array(vip_pos_new))
  387. data_vip_neg = np.float32(np.array(vip_neg_new))
  388. data_pc_all = np.float32(np.array(pc_all_new))
  389. count = 0
  390. # %%
  391. # ============================
  392. # Parameter definition
  393. # ============================
  394. params = Parameters()
  395. params.add('w_0', value = w[0])
  396. params.add('w_1', value = w[1])
  397. params.add('w_2', value = w[2])
  398. params.add('w_3', value = w[3])
  399. params.add('w_4', value = w[4])
  400. params.add('w_5', value = w[5])
  401. params.add('w_6', value = w[6])
  402. params.add('w_7', value = w[7])
  403. params.add('w_8', value = w[8])
  404. params.add('w_9', value = w[9])
  405. params.add('w_10', value = w[10])
  406. params.add('w_11', value = w[11])
  407. params.add('w_12', value = w[12])
  408. params.add('w_13', value = w[13])
  409. params.add('w_14', value = w[14])
  410. params.add('w_15', value = w[15])
  411. params.add('w_16', value = w[16])
  412. params.add('w_17', value = w[17])
  413. params.add('w_18', value = w[18])
  414. params.add('w_19', value = w[19])
  415. params.add('w_20', value = w[20])
  416. params.add('w_21', value = w[21])
  417. params.add('w_22', value = w[22])
  418. params.add('w_23', value = w[23])
  419. params.add('tau_0', value = tau[0])
  420. params.add('tau_1', value = tau[1])
  421. params.add('tau_2', value = tau[2])
  422. params.add('tau_3', value = tau[3])
  423. params.add('threshold', value = threshold)
  424. params.add('power', value = power)
  425. params.add('q', value = q)
  426. params.add('i_0', value = i[0])
  427. params.add('i_1', value = i[1])
  428. params.add('i_2', value = i[2])
  429. params.add('i_3', value = i[3])
  430. params.add('i_4', value = i[4])
  431. params.add('ampl_1', value = ampl_1)
  432. params.add('r_1', value = r_1)
  433. params.add('delay_1', value = delay_1)
  434. params.add('delay_2', value = delay_2)
  435. params.add('delay_3', value = delay_3)
  436. params.add('decay', value = decay)
  437. params.add('decay_s', value = decay_s)
  438. params.add('decay_f', value = decay_f)
  439. params.add('decay_ff', value = decay_ff)
  440. params.add('ampl', value = ampl)
  441. params.add('base', value = base)
  442. params.add('base_sigm', value = base_sigm)
  443. params.add('s_start', value = s_start)
  444. params.add('k', value = k)
  445. # %% [markdown]
  446. # ## Model Simulation
  447. # %% [markdown]
  448. # ### Connection weights (wji)
  449. # %%
  450. vals = []
  451. for _, param in params.items():
  452. vals.append(param.value)
  453. plt.figure(figsize=(15,7.5))
  454. plt.ylabel(r"$w_{ji}$", fontsize=20)
  455. plt.bar(range(len(vals[:24])),vals[:24], color='blue')
  456. plt.xticks(range(len(vals[:24])), names[:24], rotation = 60, fontsize=15)
  457. plt.bar_label(plt.bar(range(len(vals[:24])),vals[:24]), fmt = '{:.2f}', fontsize=15)
  458. plt.yticks(np.arange(0,2.5,0.5), fontsize=15)
  459. plt.show()
  460. # %%
  461. # Simulate the model with parameters defined in params
  462. model = simulate_step(t_exp, init, params)
  463. # %% [markdown]
  464. # ### Fitting to experimental traces
  465. # %%
  466. # ============================
  467. # PC
  468. # ============================
  469. plt.figure(figsize=(4,4))
  470. plt.plot(t_exp, data_pc_all, color='#000000', marker='o', label='PC data')
  471. plt.plot(t_exp, model['f_e'].values, color='#ffaa00', label='fit', linewidth=3)
  472. plt.title('PC')
  473. plt.legend(loc='best')
  474. plt.ylabel("Spike Rate (Hz)", fontsize=14)
  475. plt.xlabel('t', fontsize=14)
  476. plt.xticks(np.arange(0,21,5))
  477. plt.yticks(np.arange(0,1.7,0.5))
  478. plt.show()
  479. # %%
  480. # ============================
  481. # VIP Positive
  482. # ============================
  483. plt.figure(figsize=(4,4))
  484. plt.plot(t_exp, data_vip_pos, color='#02ab81', marker='o', label='VIP Pos data')
  485. plt.plot(t_exp, model['f_vip_pos'].values, color='#ffaa00', label='fit', linewidth=3)
  486. plt.title('VIP Positive')
  487. plt.legend(loc='best')
  488. plt.ylabel("Spike Rate (Hz)", fontsize=14)
  489. plt.xlabel('t', fontsize=14)
  490. plt.xticks(np.arange(0,21,5))
  491. plt.yticks(np.arange(0,2.2,0.5))
  492. plt.show()
  493. # %%
  494. # ============================
  495. # VIP Negative
  496. # ============================
  497. plt.figure(figsize=(4,4))
  498. plt.plot(t_exp, data_vip_neg, color='#02ab81', marker='o', label='VIP Neg data')
  499. plt.plot(t_exp, model['f_vip_neg'].values, color='#ffaa00', label='fit', linewidth=3)
  500. plt.title('VIP Negative')
  501. plt.legend(loc='best')
  502. plt.ylabel("Spike Rate (Hz)", fontsize=14)
  503. plt.xlabel('t', fontsize=14)
  504. plt.xticks(np.arange(0,21,5))
  505. plt.yticks(np.arange(0,2.2,0.5))
  506. plt.show()
  507. # %%
  508. # ============================
  509. # PV
  510. # ============================
  511. plt.figure(figsize=(4,4))
  512. plt.plot(t_exp, data_pv, color='#ae00ff', marker='o', label='PV data')
  513. plt.plot(t_exp, model['f_pv'].values, color='#ffaa00', label='fit', linewidth=3)
  514. plt.title('PV')
  515. plt.legend(loc='best')
  516. plt.ylabel("Spike Rate (Hz)", fontsize=14)
  517. plt.xlabel('t', fontsize=14)
  518. plt.xticks(np.arange(0,21,5))
  519. plt.yticks(np.arange(0,1.7,0.4))
  520. plt.show()
  521. # %%
  522. # ============================
  523. # SST
  524. # ============================
  525. plt.figure(figsize=(4,4))
  526. plt.plot(t_exp, data_sst, color='#d80000', marker='o', label='SST data')
  527. plt.plot(t_exp, model['f_sst'].values, color='#ffaa00', label='fit', linewidth=3)
  528. plt.title('SST')
  529. plt.legend(loc='best')
  530. plt.ylabel("Spike Rate (Hz)", fontsize=14)
  531. plt.xlabel('t', fontsize=14)
  532. plt.xticks(np.arange(0,21,5))
  533. plt.yticks(np.arange(0,2.8,0.5))
  534. plt.show()
  535. # %% [markdown]
  536. # ### Root mean square error calculation (RMSE)
  537. # %%
  538. a_tot = RMSE_full(params, init, data_pc_all, data_pv, data_sst, data_vip_pos, data_vip_neg)
  539. print(a_tot)
  540. # %% [markdown]
  541. # ### Saving Traces
  542. # %%
  543. # Write csv file with output. f_e, f_p, f_s, f_v, f_e_o, f_p_o, f_s_o, f_v_o = y
  544. model[['t', 'f_e']].to_csv('Trace_PC_HabSess1.csv', index=False)
  545. model[['t', 'f_pv']].to_csv('Trace_PV_HabSess1.csv', index=False)
  546. model[['t', 'f_sst']].to_csv('Trace_SST_HabSess1.csv', index=False)
  547. model[['t', 'f_vip_pos']].to_csv('Trace_VIPPos_HabSess1.csv', index=False)
  548. model[['t', 'f_vip_neg']].to_csv('Trace_VIPNeg_HabSess1.csv', index=False)

Model_V1_Hab_Sess1-checkpoint.ipynb at commit 5d14a6b, under Apache-2.0 · at the source

Overview

Authors: A.J. Hinojosa1, S.E. Dominiak1, Ye. Kosiachkin1, L. Lagnado1
  1. Sussex Neuroscience, School of Life Sciences, University of Sussex, Brighton, BN1 9QG, United Kingdom
Institutions: University of Sussex (United Kingdom)
Dates: published online 25 March 2026
Type: Preprint
License: CC BY
Identifiers: DOI 10.64898/2026.03.24.713929 · OpenAlex W7140810994
Open access: green, a free copy (OpenAlex)
Status: code verified (how the code is found and verified)
Methods: Statistics, Connectivity, fMRI & imaging, Single-unit activity, calcium imaging, Physiology & signal measures
Topic: Neural dynamics and brain function (Cognitive Neuroscience, Neuroscience), according to OpenAlex
Funding: Biotechnology and Biological Sciences Research Council (BB/X009386/1)
Citations: not cited yet (Europe PMC); 59 references in the paper

Abstract

Sensory cortices filter repeated inputs through rapid adaptation over seconds and experience-driven learning over days. Although these forms of plasticity occur simultaneously, it is not known how they interact within cortical circuits. We combined two-photon calcium imaging, data-driven circuit modelling and optogenetics to investigate how short-term adaptation in layer 2/3 of mouse V1 is shaped by stimulus familiarity and reward association. Habituation reduced the fraction of pyramidal cells responsive to a visual stimulus, whereas reward association maintained overall responsivity. In contrast, both forms of learning shifted pyramidal cell adaptation from depression toward sensitization, but through distinct circuit mechanisms. Habituation reduced disinhibition through the VIP→SST→PC pathway by weakening feedback activation of VIPs and VIP→SST connections. Reward association counteracted this effect by increasing disinhibition through the SST→PV→PC pathway, strengthening SST→PV connections while reducing SST→PC inputs. Despite engaging distinct disinhibitory circuits and producing divergent effects on pyramidal cell responsivity, both forms of learning converged on a reduced PV:SST input ratio to pyramidal cells, thereby biasing V1 toward sensitizing adaptation. These results identify changes in cortical circuits that link the plasticity of fast adaptation to simple forms of learning.

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

Repository

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

lagnadoLab/CortexModel-Learning

License: Apache-2.0
State: the link answers, verified on 30 September 2026
Evidence: files inventoried
Commit: 5d14a6b64a45586ce2fcdc96376f4d4dfea102eb, 24 March 2026
Languages: Python (24), Jupyter (8), Shell (8)
Size: 94 files, 40 scripts
Software Heritage: not archived
Found in: the text, “Model”
Holds: README, license file, environment (requirements.txt, Fitting/requirements.txt), 4 notebooks
Not found: CITATION.cff, tests, continuous integration, documentation
Tools: pandas (32 files), NumPy (28 files), SciPy (24 files), LMFIT (16 files), Matplotlib (16 files), scikit-learn (12 files), seaborn (8 files)
Availability: 1 check, the latest on 30 September 2026: the link answers
  • 30 September 2026: the link answers
42 files

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;
  • 40 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.

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, 30 September 2026: the first record

Recorded: type, journal, dates, 4 authors, 1 funder, 56 references.

Cite

This paper

Hinojosa, A., Dominiak, S., Kosiachkin, Y., & Lagnado, L. (2026). Distinct Disinhibitory Circuits Link Short-Term Adaptation to Familiarity and Reward Learning in Visual Cortex. bioRxiv (preprint). https://doi.org/10.64898/2026.03.24.713929

BibTeX

@article{hinojosa2026distinct,
author = {Hinojosa, A.J. and Dominiak, S.E. and Kosiachkin, Ye. and Lagnado, L.},
title = {{Distinct Disinhibitory Circuits Link Short-Term Adaptation to Familiarity and Reward Learning in Visual Cortex}},
journal = {bioRxiv (preprint)},
year = {2026},
month = mar,
publisher = {bioRxiv},
issn = {2692-8205},
doi = {10.64898/2026.03.24.713929},
url = {https://doi.org/10.64898/2026.03.24.713929}
}

RIS

TY - JOUR
AU - Hinojosa, A.J.
AU - Dominiak, S.E.
AU - Kosiachkin, Ye.
AU - Lagnado, L.
TI - Distinct Disinhibitory Circuits Link Short-Term Adaptation to Familiarity and Reward Learning in Visual Cortex
T2 - bioRxiv (preprint)
J2 - bioRxiv
PY - 2026
DA - 2026/03/25
SN - 2692-8205
PB - bioRxiv
DO - 10.64898/2026.03.24.713929
UR - https://doi.org/10.64898/2026.03.24.713929
ER -

CSL-JSON

{
"id": "10.64898/2026.03.24.713929",
"type": "article",
"title": "Distinct Disinhibitory Circuits Link Short-Term Adaptation to Familiarity and Reward Learning in Visual Cortex",
"container-title": "bioRxiv (preprint)",
"author": [
{
"family": "Hinojosa",
"given": "A.J."
},
{
"family": "Dominiak",
"given": "S.E."
},
{
"family": "Kosiachkin",
"given": "Ye."
},
{
"family": "Lagnado",
"given": "L."
}
],
"container-title-short": "bioRxiv",
"DOI": "10.64898/2026.03.24.713929",
"ISSN": "2692-8205",
"publisher": "bioRxiv",
"URL": "https://doi.org/10.64898/2026.03.24.713929",
"issued": {
"date-parts": [
[
2026,
3,
25
]
]
}
}

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.pbio.3003518 [code]
Context-dependent activation of V1 parvalbumin interneurons enhances visual discrimination.
Journal: PLoS biology
In common: pandas, SciPy, Matplotlib, 1 other tool, 9 references
[2] 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: seaborn, scikit-learn, pandas, 3 other tools, 6 references
[3] doi:10.1523/jneurosci.0987-25.2026 [code]
Cell-Type-Specific Synaptic Scaling Mechanisms Differentially Contribute to Associative Learning.
Journal: The Journal of neuroscience : the official journal of the Society for Neuroscience
In common: seaborn, pandas, SciPy, 2 other tools, 7 references
[4] doi:10.1101/2025.05.14.654005 [code]
Cell-type-specific synaptic scaling mechanisms differentially contribute to associative learning
Journal: bioRxiv (preprint)
In common: seaborn, pandas, SciPy, 2 other tools, 7 references
[5] doi:10.1093/cercor/bhag047 [code]
Association learning drives synaptic plasticity at feedforward synapses in somatosensory cortex.
Journal: Cerebral cortex (New York, N.Y. : 1991)
In common: scikit-learn, pandas, SciPy, 2 other tools, 6 references
[6] doi:10.1073/pnas.2312898121 [code]
A disinhibitory circuit mechanism explains a general principle of peak performance during mid-level arousal.
Journal: Proceedings of the National Academy of Sciences of the United States of America
In common: LMFIT, seaborn, scikit-learn, 4 other tools, 3 references
[7] doi:10.1016/j.celrep.2023.113088
VIP interneurons regulate cortical size tuning and visual perception.
Journal: Cell reports
In common: 8 references
[8] doi:10.1016/j.isci.2025.114132 [code]
FMRP restoration in parvalbumin interneurons: A circuit-specific improvement of visual learning in fragile X syndrome.
Journal: iScience
In common: seaborn, scikit-learn, pandas, 3 other tools, 4 references
[9] doi:10.1073/pnas.2116895119 [code]
A circuit mechanism for independent modulation of excitatory and inhibitory firing rates after sensory deprivation.
Journal: Proceedings of the National Academy of Sciences of the United States of America
In common: Matplotlib, NumPy, 7 references
[10] doi:10.1038/s41467-025-65665-4 [code]
Disrupted theta synchronization and synaptic connectivity in the visual cortex of Fmr1 KO mice.
Journal: Nature communications
In common: seaborn, scikit-learn, pandas, 3 other tools, 4 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.

Add the badge to the code's README

OSCR: the badge of this paper

If you are an author or a maintainer of this paper's code, you can add this badge. It says what OSCR knows of the paper (its code, its validated tracing map) and links the code to this page. Paste one of these snippets under the README's title. Keep the two marks around it, so that the badge can be replaced in place and is never added twice. OSCR changes nothing in your repository.

Markdown
<!-- oscr-badge:start -->
[![OSCR](https://openscicode.org/badge/doi/10.64898/2026.03.24.713929.svg)](https://openscicode.org/badge/doi/10.64898/2026.03.24.713929)
<!-- oscr-badge:end -->
reStructuredText
.. oscr-badge:start

.. image:: https://openscicode.org/badge/doi/10.64898/2026.03.24.713929.svg
   :target: https://openscicode.org/badge/doi/10.64898/2026.03.24.713929
   :alt: OSCR

.. oscr-badge:end
HTML
<!-- oscr-badge:start -->
<a href="https://openscicode.org/badge/doi/10.64898/2026.03.24.713929"><img src="https://openscicode.org/badge/doi/10.64898/2026.03.24.713929.svg" alt="OSCR"></a>
<!-- oscr-badge:end -->

On GitHub, open the README, choose Edit (the pencil), paste the snippet under the title, then "Commit changes".

If you choose to, you can have the badge kept up to date for you, with oscr badge --write from the command line or with the GitHub Action in your repository's workflows. Every other form and option (a card, AsciiDoc, LaTeX, shields.io) is on the badge 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: code errors and mismatches between the code and the paper about this paper and its code, from readers and its authors, beside the paper and its tracing map.

Report a mismatch between the code and the paper · Report a code error (signed in)

Reproductions: reports from readers who ran the authors' code and did not get the paper's result, what they ran, with which environment, commit and data.

Report a reproduction failure (signed in)

Versions of its code: the releases of its code tied to a version of this paper (the preprint, the accepted manuscript, the version of record…), each with the tracing map versioned with it.

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