OSCR

Subunit-specific behavioral modulation of sensory tuning in the 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, not stored by OSCR: doi.org · Europe PMC

The paper is loaded when this pane is shown.

The authors' code

Python · 531 lines · 20 KB · no license

  1. import math
  2. import os
  3. import matplotlib as mpl
  4. import matplotlib.pyplot as plt
  5. import numpy as np
  6. import pandas as pd
  7. import seaborn as sns
  8. from alive_progress import alive_it
  9. from matplotlib.ticker import MaxNLocator
  10. os.chdir('/Users/mayerj/repos/behavioral-visual-tuning')
  11. import src.globals as g
  12. import src.utils as ut
  13. from src.data_pipeline import tuning_data
  14. def buffer_array_with_nans(original_array, target_length):
  15. """
  16. Buffers an array with NaNs to a target length.
  17. :param original_array:
  18. :param target_length:
  19. :return:
  20. """
  21. original_array = np.asarray(original_array)
  22. buffered_array = np.full(target_length, np.nan)
  23. original_length = original_array.shape[0]
  24. if target_length < original_length:
  25. warnings.warn(f"Target length {target_length} is less than original length {original_length}")
  26. return
  27. else:
  28. buffered_array[:original_length] = original_array[:]
  29. return buffered_array
  30. def get_xticks(nan_buffer, num_traces=3):
  31. x_ticks_all = []
  32. for i in range(num_traces):
  33. x_ticks = list(np.arange(0, 121, 30) + (120 * i) + (nan_buffer * i))
  34. x_ticks = np.append(x_ticks, np.nan)
  35. x_ticks_all += list(x_ticks)
  36. return x_ticks_all
  37. def get_ax_vspan(nan_buffer, num_traces=3):
  38. ax_vspan_all = []
  39. for i in range(num_traces):
  40. span = np.asarray([30, 90]) + (120 * i) + (nan_buffer * i)
  41. ax_vspan_all.append(span)
  42. return ax_vspan_all
  43. def compute_nan_std_pos_from_sweeps(sweeps):
  44. """
  45. Compute the std of non-negative values across all sweeps for one cell.
  46. """
  47. arrays = [np.asarray(v, dtype=float).ravel() for v in sweeps if v is not None]
  48. if not arrays:
  49. return np.nan
  50. all_vals = np.concatenate(arrays)
  51. all_vals_pos = np.where(all_vals < 0, 0, all_vals)
  52. return np.nanstd(all_vals_pos)
  53. def prepare_raw_traces_from_sweeps(
  54. sweeps,
  55. dx,
  56. stim_table,
  57. conditions=None,
  58. num_conditions=3,
  59. nan_buffer=10,
  60. random_state=None,
  61. ):
  62. """
  63. Args:
  64. sweeps: sequence/Series of dF/F arrays per sweep for one cell.
  65. dx: sequence/Series of dx arrays aligned to sweeps.
  66. stim_table: DataFrame aligned to sweeps with temporal_frequency/orientation columns.
  67. conditions: optional DataFrame or list of dicts with temporal_frequency/orientation and optional trial.
  68. num_conditions: number of random conditions to sample when conditions is None.
  69. nan_buffer: number of NaNs to append between concatenated traces.
  70. random_state: seed for reproducible sampling.
  71. Returns:
  72. raw_dffs, transformed_dff, raw_dxs, condition_info
  73. """
  74. sweeps_series = pd.Series(sweeps).reset_index(drop=True)
  75. dx_series = pd.Series(dx).reset_index(drop=True)
  76. stim_df = stim_table.reset_index(drop=True)
  77. required_cols = {"temporal_frequency", "orientation"}
  78. missing = required_cols - set(stim_df.columns)
  79. if missing:
  80. raise ValueError(f"stim_table is missing required columns: {sorted(missing)}")
  81. df = pd.concat(
  82. [
  83. sweeps_series.rename("dff"),
  84. dx_series.rename("dx"),
  85. stim_df,
  86. ],
  87. axis=1,
  88. )
  89. rng = np.random.default_rng(random_state)
  90. if conditions is None:
  91. if "blank_sweep" in df.columns:
  92. cond_df = df.query("blank_sweep == 0")[["temporal_frequency", "orientation"]]
  93. else:
  94. cond_df = df[["temporal_frequency", "orientation"]]
  95. cond_df = cond_df.sample(num_conditions, random_state=random_state).reset_index(drop=True)
  96. use_trial_col = False
  97. else:
  98. cond_df = pd.DataFrame(conditions)
  99. use_trial_col = "trial" in cond_df.columns
  100. nan_std_pos = compute_nan_std_pos_from_sweeps(sweeps_series)
  101. raw_dffs = []
  102. raw_dxs = []
  103. condition_info = []
  104. for _, row in cond_df.iterrows():
  105. cond_rows = df.query(
  106. "temporal_frequency == @row.temporal_frequency and orientation == @row.orientation"
  107. )
  108. if cond_rows.empty:
  109. continue
  110. if use_trial_col:
  111. trial_idx = int(row.trial)
  112. trial_idx = max(0, min(trial_idx, len(cond_rows) - 1))
  113. else:
  114. trial_idx = int(rng.integers(0, len(cond_rows)))
  115. dff = np.asarray(cond_rows["dff"].iloc[trial_idx], dtype=float)
  116. dff = np.append(dff, [np.nan] * nan_buffer)
  117. raw_dffs.append(dff)
  118. dx_vals = np.asarray(cond_rows["dx"].iloc[trial_idx], dtype=float)
  119. dx_vals = np.append(dx_vals, [np.nan] * nan_buffer)
  120. raw_dxs.append(dx_vals)
  121. condition_info.append((row.temporal_frequency, row.orientation, int(trial_idx)))
  122. raw_dffs = np.asarray(raw_dffs).flatten()
  123. raw_dxs = np.asarray(raw_dxs).flatten()
  124. transformed_dff = np.where(raw_dffs < 0, 0, raw_dffs)
  125. if nan_std_pos and not np.isnan(nan_std_pos):
  126. transformed_dff = transformed_dff / nan_std_pos
  127. return raw_dffs, transformed_dff, raw_dxs, condition_info
  128. def plot_raw_transformed_traces(experiment_id='', cell_indices=None, path=None, condition_and_trials=None,
  129. restarts=10):
  130. assert cell_indices is not None
  131. assert path is not None
  132. if condition_and_trials is not None:
  133. iterate_num = 1 # only one plot per cell and condition instead of random restarts
  134. else:
  135. iterate_num = restarts
  136. dataset = tuning_data.ExperimentData(experiment_id)
  137. nan_buffer = 10
  138. font_size = 16
  139. mpl.rcParams['font.size'] = font_size
  140. figs = []
  141. for j in range(iterate_num):
  142. for i_enum, i in enumerate(cell_indices):
  143. if condition_and_trials is not None:
  144. conditions = condition_and_trials[i_enum]
  145. num_conditions = len(conditions)
  146. conditions = pd.DataFrame(conditions, columns=['temporal_frequency', 'orientation', 'trial'])
  147. non_rand_trial = True
  148. else:
  149. num_conditions = 3
  150. conditions = get_random_conditions_to_be_concatenated(dataset, num_conditions)
  151. non_rand_trial = False
  152. df_ = load_raw_cell_data(path=path, cell_index=i)
  153. nan_std_pos = compute_std_pos_one_cell(df_)
  154. raw_dffs_, transformed_dff_, raw_dxs_, condition_info_ = get_dff_transformeddff_dx_for_conditions(dataset,
  155. conditions,
  156. cell_index=i,
  157. nan_buffer=nan_buffer,
  158. nan_std_pos=nan_std_pos,
  159. non_rand_trial=non_rand_trial)
  160. fig = plot_concated_traces(raw_dffs_, transformed_dff_, raw_dxs_, nan_buffer=nan_buffer,
  161. title=f'{experiment_id} | {i}\n{condition_info_}',
  162. num_traces=num_conditions, svg=False, show=False)
  163. figs.append(fig)
  164. return figs
  165. def get_random_conditions_to_be_concatenated(dataset, num_conditions=3):
  166. return dataset.stim_table.query('blank_sweep == 0').sample(num_conditions) # exclude static frequencies
  167. def load_raw_cell_data(path, cell_index):
  168. test = ut.load_pickle(path) # f'{path}/raw_cells')
  169. # df_test contains all responses of a cell during the trial periods, separated in 2D bins
  170. df_test = pd.DataFrame.from_dict(test[cell_index], orient='index').T
  171. df_test.fillna(value=np.nan, inplace=True)
  172. return df_test
  173. def compute_std_pos_one_cell(df_test):
  174. # convert to 3d numpy array
  175. max_len = math.ceil(df_test.map(lambda x: len(x) if not np.isnan(x).any() else x).max().max())
  176. df_buffered = df_test.map(
  177. lambda x: buffer_array_with_nans(x, max_len) if not np.isnan(x).any() else np.full(max_len, np.nan))
  178. nd_arr = np.array(df_buffered.values.tolist())
  179. # compute standard deviation of positive values for whole cell
  180. nd_arr_pos = np.where(nd_arr < 0, 0, nd_arr) # replace non-negative values with 0
  181. nan_std_pos = np.nanstd(nd_arr_pos)
  182. return nan_std_pos
  183. def get_dff_transformeddff_dx_for_conditions(dataset, conditions, cell_index, nan_buffer, nan_std_pos,
  184. non_rand_trial=False):
  185. raw_dffs = []
  186. raw_dxs = []
  187. condition_info = [] # temp_freq, ori, trial
  188. for index, row in conditions.iterrows():
  189. df = dataset.sweep_response.iloc[
  190. dataset.stim_table.query(f'temporal_frequency == {row.temporal_frequency} '
  191. f'and orientation == {row.orientation}').index]
  192. if non_rand_trial:
  193. randint = int(row.trial) # trial number for this condition, not random
  194. else:
  195. # choose random trial of the 15 avaialable trials for each condition
  196. randint = np.random.randint(0, len(df))
  197. dff = df[str(cell_index)].iloc[randint] # randint-th trial for this cell
  198. dff = np.append(dff, [np.nan] * nan_buffer)
  199. raw_dffs.append(dff)
  200. dx = df['dx'].iloc[randint]
  201. dx = np.append(dx, [np.nan] * nan_buffer)
  202. raw_dxs.append(dx)
  203. condition_info.append((row.temporal_frequency, row.orientation, randint))
  204. raw_dxs = np.asarray(raw_dxs).flatten()
  205. raw_dffs = np.array(raw_dffs).flatten()
  206. transformed_dff = np.where(raw_dffs < 0, 0, raw_dffs) # replace non-negative values with 0
  207. transformed_dff = transformed_dff / nan_std_pos
  208. return raw_dffs, transformed_dff, raw_dxs, condition_info
  209. def plot_concated_traces(raw_dffs, transformed_dff, raw_dxs, nan_buffer, num_traces=3, title='', svg=False, show=False):
  210. x_ticks_all = get_xticks(nan_buffer, num_traces)
  211. x_labels = [-1, 0, 1, 2, 3, " "]
  212. ax_vspan_all = get_ax_vspan(nan_buffer, num_traces)
  213. fig, ax = plt.subplots(3, 1, figsize=(5 * num_traces, 6),
  214. sharex=True, sharey=False,
  215. gridspec_kw={'height_ratios': [1, 1, 0.5]})
  216. plt.xticks(x_ticks_all, x_labels * num_traces, rotation=0)
  217. plt.xlabel("Time in trial (s)")
  218. for span in ax_vspan_all:
  219. ax[0].axvspan(span[0], span[1], color='gray', alpha=0.3, lw=0)
  220. ax[1].axvspan(span[0], span[1], color='gray', alpha=0.3, lw=0)
  221. ax[0].axhline(0, color='gray', lw=0.75, ls='-')
  222. ax[0].set_ylabel('DF/F')
  223. ax[1].axhline(0, color='gray', lw=0.75, ls='-')
  224. ax[1].set_ylabel('DF/F\ntransformed')
  225. i = num_traces
  226. ax[0].plot(raw_dffs[0:120 * i + (i * nan_buffer)], lw=1.5, color='k')
  227. ax[1].plot(transformed_dff[0:120 * i + (i * nan_buffer)], lw=1.5, color='k')
  228. ax[2].plot(raw_dxs[0:120 * i + (i * nan_buffer)], lw=1.5, color='#0075B8') # #a719ca dimgray
  229. ax[2].set_ylabel('velocity\n(cm/s)')
  230. # ax[2].set_ylim(-5, 25)
  231. # ax[2].set_yticks([0, 10, 20])
  232. if title:
  233. plt.suptitle('(temp_fr, orientation, trial)\n' + title)
  234. plt.tight_layout()
  235. if show:
  236. plt.show()
  237. elif svg:
  238. plt.savefig("dff_raw_transformed_velo.svg")
  239. plt.close()
  240. return fig
  241. def plot_single_cell_tuning_figure(experiment_id, cell_index, show=True):
  242. """
  243. Notebook-friendly version of plot_single_cell_to_pdf.
  244. Returns (fig, ax) and optionally shows.
  245. """
  246. dataset = tuning_data.ExperimentData(str(experiment_id))
  247. i = cell_index
  248. style = {
  249. "linewidth": 3,
  250. "ori_axis_label": "Direction (deg)",
  251. "ori_tick_labels": g.HELPER.ORIENTATION_LABELS,
  252. "ori_color": "#E30613",
  253. "ori_color2": "#931912",
  254. "velo_axis_label": "Velocity (cm/s)",
  255. "velo_tick_labels": g.HELPER.VELOCITY_LABELS,
  256. "velo_color": "#009FE3",
  257. "cmap": "Greys",
  258. }
  259. with plt.style.context("seaborn-v0_8-poster"):
  260. fig, ax = plt.subplots(
  261. 4, 2, figsize=(10.5, 14),
  262. gridspec_kw={"height_ratios": [1, 0.3, 0.3, 0.3], "width_ratios": [1, 0.5]}
  263. )
  264. a, b, c, d = (0, 0), (1, 0), (2, 0), (3, 0)
  265. ax[0, 0].set_xticks(range(0, 8))
  266. ax[0, 0].set_yticks(range(0, 8))
  267. for j in range(1, 4):
  268. ax[j, 0].spines["top"].set_visible(False)
  269. ax[j, 0].spines["right"].set_visible(False)
  270. ax[j, 0].spines["bottom"].set_visible(False)
  271. ax[j, 0].spines["left"].set_visible(False)
  272. ax[j, 0].grid(False)
  273. ax[j, 0].set_ylabel("mean\nresponse")
  274. ax[j, 0].set_xticks(range(0, 8))
  275. for l in range(1, 4):
  276. ax[l, 1].axis("off")
  277. # joint tuning
  278. sns.heatmap(
  279. dataset.tuning_2d_transformed_experiment[:, :, i],
  280. cmap=style["cmap"], square=True, cbar=False, ax=ax[a]
  281. )
  282. ax[a].set_title(f"{experiment_id} | cell {cell_index}")
  283. ax[a].set_ylabel(style["ori_axis_label"])
  284. ax[a].set_yticklabels(style["ori_tick_labels"], rotation=0)
  285. ax[a].set_xlabel(style["velo_axis_label"])
  286. ax[a].set_xticklabels(style["velo_tick_labels"], rotation=45)
  287. # single tuning
  288. margin = 0.25
  289. velo = np.mean(dataset.tuning_2d_transformed_experiment[:, :, i], axis=0)
  290. vmin = np.min(velo) - margin * 0.5
  291. vmax = np.max(velo) + margin * 0.5
  292. ax[b].plot(velo, linewidth=style["linewidth"], c=style["velo_color"])
  293. ax[b].set_ylim(vmin, vmax)
  294. ax[b].set_xlabel(style["velo_axis_label"])
  295. ax[b].set_xticklabels(style["velo_tick_labels"], rotation=45)
  296. ori = np.mean(dataset.tuning_2d_transformed_experiment[:, :, i], axis=1)
  297. ori_stat = dataset.tuning_2d_transformed_experiment[:, :1, i]
  298. omin = np.min([np.min(ori_stat), np.min(ori)]) - margin
  299. omax = np.max([np.max(ori_stat), np.max(ori)]) + margin
  300. ax[c].plot(ori, linewidth=style["linewidth"], c=style["ori_color"])
  301. ax[c].set_ylim(omin, omax)
  302. ax[c].set_xlabel(style["ori_axis_label"])
  303. ax[c].set_xticklabels(style["ori_tick_labels"], rotation=90)
  304. ori_loco = np.mean(dataset.tuning_2d_transformed_experiment[:, 1:, i], axis=1)
  305. ori_loco_std = np.std(dataset.tuning_2d_transformed_experiment[:, 1:, i], axis=1)
  306. ax[d].plot(ori_loco, linewidth=style["linewidth"], c=style["ori_color2"], label="Locomotion")
  307. ax[d].errorbar(
  308. np.arange(len(ori_loco)), ori_loco, yerr=ori_loco_std,
  309. linewidth=style["linewidth"], c=style["ori_color2"]
  310. )
  311. ax[d].plot(ori_stat, linewidth=style["linewidth"], c=style["ori_color"], zorder=4, label="Stationary")
  312. ax[d].set_xlabel(style["ori_axis_label"])
  313. ax[d].set_xticklabels(style["ori_tick_labels"], rotation=90)
  314. ax[d].set_ylim(omin, omax)
  315. ax[d].legend(loc="center left", bbox_to_anchor=(1, 0.5))
  316. # colorbar panel
  317. sns.heatmap(
  318. dataset.tuning_2d_transformed_experiment[:, :, i],
  319. cmap=style["cmap"], square=True, cbar=True,
  320. cbar_kws={"shrink": 0.8, "label": "mean response"},
  321. ax=ax[0, 1],
  322. )
  323. cbar = ax[0, 1].collections[0].colorbar
  324. cbar.outline.set_edgecolor("black")
  325. cbar.outline.set_linewidth(1)
  326. ax[0, 1].set_xticks([])
  327. ax[0, 1].set_yticks([])
  328. plt.tight_layout()
  329. if show:
  330. plt.show()
  331. return fig, ax
  332. def plot_single_cell_tuning_figure_minimal(experiment_id, cell_index, show=True):
  333. """
  334. Smaller notebook-friendly variant based on plot_single_cell_to_pdf2 styling.
  335. """
  336. dataset = tuning_data.ExperimentData(str(experiment_id))
  337. i = cell_index
  338. style = {
  339. "linewidth": 3,
  340. "ori_axis_label": "Direction (deg)",
  341. "ori_tick_labels": g.HELPER.ORIENTATION_LABELS,
  342. "ori_tick_rotation": 90,
  343. "ori_color": "#E30613",
  344. "ori_color2": "#931912",
  345. "velo_axis_label": "Velocity (cm/s)",
  346. "velo_tick_labels": [0, "", "", "", "", "", "", 20],
  347. "velo_tick_rotation": 0,
  348. "velo_color": "#009FE3",
  349. "cmap": "Greys",
  350. "font_size": 25,
  351. }
  352. with plt.style.context("seaborn-v0_8-poster"):
  353. fig, ax = plt.subplots(
  354. 4, 2, figsize=(10.5, 15.5),
  355. gridspec_kw={"height_ratios": [1, 0.35, 0.35, 0.35], "width_ratios": [1, 0.5]}
  356. )
  357. ax[0, 0].set_xticks(range(0, 8))
  358. ax[0, 0].set_yticks(range(0, 8))
  359. for j in range(1, 4):
  360. ax[j, 0].spines["top"].set_visible(False)
  361. ax[j, 0].spines["right"].set_visible(False)
  362. ax[j, 0].spines["bottom"].set_visible(False)
  363. ax[j, 0].spines["left"].set_visible(False)
  364. ax[j, 0].grid(False)
  365. ax[j, 0].set_ylabel("mean\nresponse", fontsize=style["font_size"])
  366. ax[j, 0].set_xticks(range(0, 8))
  367. ax[j, 0].axhline(0, color="grey", linewidth=3)
  368. for l in range(1, 4):
  369. ax[l, 1].axis("off")
  370. sns.heatmap(
  371. dataset.tuning_2d_transformed_experiment[:, :, i],
  372. cmap=style["cmap"], square=True, cbar=False, ax=ax[0, 0]
  373. )
  374. ax[0, 0].set_title(f"{experiment_id} | cell {cell_index}")
  375. ax[0, 0].set_ylabel(style["ori_axis_label"], fontsize=style["font_size"])
  376. ax[0, 0].set_yticklabels(style["ori_tick_labels"], rotation=0, fontsize=style["font_size"])
  377. ax[0, 0].set_xlabel(style["velo_axis_label"], fontsize=style["font_size"])
  378. ax[0, 0].set_xticklabels(
  379. style["velo_tick_labels"], rotation=style["velo_tick_rotation"], fontsize=style["font_size"]
  380. )
  381. margin = 0.25
  382. velo = np.mean(dataset.tuning_2d_transformed_experiment[:, :, i], axis=0)
  383. vmax = np.max(velo)
  384. ax[1, 0].axhline(vmax, color="grey", linewidth=3)
  385. ax[1, 0].plot(velo, linewidth=style["linewidth"], c=style["velo_color"])
  386. ax[1, 0].set_ylim(0, vmax + margin * 0.5)
  387. ax[1, 0].set_xlabel(style["velo_axis_label"], fontsize=style["font_size"])
  388. ax[1, 0].set_xticklabels(
  389. style["velo_tick_labels"], rotation=style["velo_tick_rotation"], fontsize=style["font_size"]
  390. )
  391. ori = np.mean(dataset.tuning_2d_transformed_experiment[:, :, i], axis=1)
  392. omax = np.max(ori)
  393. ax[2, 0].axhline(omax, color="grey", linewidth=3)
  394. ax[2, 0].plot(ori, linewidth=style["linewidth"], c=style["ori_color"])
  395. ax[2, 0].set_ylim(0, omax + margin)
  396. ax[2, 0].set_xlabel(style["ori_axis_label"], fontsize=style["font_size"])
  397. ax[2, 0].set_xticklabels(
  398. style["ori_tick_labels"], rotation=style["ori_tick_rotation"], fontsize=style["font_size"]
  399. )
  400. ori_stat = dataset.tuning_2d_transformed_experiment[:, :1, i]
  401. ori_loco = np.mean(dataset.tuning_2d_transformed_experiment[:, 1:, i], axis=1)
  402. omax2 = np.max([np.max(ori_stat), np.max(ori_loco)])
  403. ax[3, 0].axhline(omax2, color="grey", linewidth=3)
  404. ax[3, 0].plot(ori_loco, linewidth=style["linewidth"], c=style["ori_color2"], label="Locomotion")
  405. ax[3, 0].plot(ori_stat, linewidth=style["linewidth"], c=style["ori_color"], zorder=4, label="Stationary")
  406. ax[3, 0].set_xlabel(style["ori_axis_label"], fontsize=style["font_size"])
  407. ax[3, 0].set_xticklabels(
  408. style["ori_tick_labels"], rotation=style["ori_tick_rotation"], fontsize=style["font_size"]
  409. )
  410. ax[3, 0].set_ylim(0, omax2 + margin)
  411. ax[3, 0].legend(loc="center left", bbox_to_anchor=(1, 0.5))
  412. sns.heatmap(
  413. dataset.tuning_2d_transformed_experiment[:, :, i],
  414. cmap=style["cmap"], square=True, cbar=True,
  415. cbar_kws={"shrink": 0.8, "label": "mean response"},
  416. ax=ax[0, 1],
  417. )
  418. cbar = ax[0, 1].collections[0].colorbar
  419. cbar.outline.set_edgecolor("black")
  420. cbar.outline.set_linewidth(1)
  421. ax[0, 1].set_xticks([])
  422. ax[0, 1].set_yticks([])
  423. plt.tight_layout()
  424. if show:
  425. plt.show()
  426. return fig, ax

demo_plotting.py at commit 97b2e4a, no license · at the source

Overview

  1. Faculty of Biology, Ludwig Maximilian University of Munich, Munich, Germany
  2. Graduate School of Systemic Neurosciences, Munich, Germany
  3. Bernstein Center for Computational Neuroscience Munich, Munich, Germany
Journal: PLoS computational biology, volume 22, issue 4, article e1014123
Dates: received 3 September 2025; accepted 12 March 2026; published online 6 April 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI 10.1371/journal.pcbi.1014123 · PMID 41941411 · PMCID PMC13082715 · OpenAlex W7150916594
Open access: gold, a free copy (OpenAlex)
Status: code verified
Categories: computational modeling (no new data) (modality), mouse (organism), systems (subfield)
Methods: Connectivity, Machine learning, Statistics, Single-unit activity, calcium imaging
MeSH: Behavior, Animal*, Models, Neurological*, Sensory Receptor Cells*, Visual Cortex*, Animals, Computational Biology, Computer Simulation, Locomotion, Mice (* major topic)
Journal subjects: Biology and Life Sciences, Neuroscience, Neuronal Tuning, Cell Biology, Cellular Types, Animal Cells, Neurons, Cellular Neuroscience, Cognitive Science, Cognitive Psychology, Perception, Sensory Perception, Psychology, Social Sciences, Behavior, Anatomy, Brain, Visual Cortex, Medicine and Health Sciences, Animal Behavior, Zoology, Physiology, Biological Locomotion, Running, Vision
Topic: Neural dynamics and brain function (Cognitive Neuroscience, Neuroscience), according to OpenAlex
Citations: cited by 2 papers (Europe PMC); 40 references in the paper

Abstract

Activity of sensory neurons is influenced not only by external stimuli but also by the animal’s behavioral state. It is well documented that behavior influences the general properties of neural activity, such as response gain. However, it is not known whether it could affect the sensory tuning of individual neurons in a more refined way and what the functional benefit of such nuanced modulation might be. Here, we investigate this in the mouse visual cortex using the data made available by the Allen Brain Observatory. Our analysis indicates that locomotion can modulate not only the gain of the entire neuronal response, but also more selectively control responses to specific stimuli. This modulation results in changes of neuronal tuning in different behavioral states. Using numerical simulations, we demonstrate that such patterns of gain modulation can multiplex behavioral information in sensory populations without compromising the accuracy of sensory coding. In that way, the visual cortex could instantiate an accurate, joint representation of sensory and movement-related signals and support computations that simultaneously require both types of information.

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

Repository

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

Mlynarski-Group/behavioral-visual-tuning

License: none: the authors keep all their rights
State: the link answers, verified on 29 September 2026
Evidence: files inventoried
Commit: 97b2e4ad341253b7fc6ca34457ea8df2751cbd15, 7 January 2026
Languages: Python (1)
Size: 5 files, 1 script
Software Heritage: not archived
Found in: “Data Availability”
Holds: README, environment (requirements.txt)
Not found: license file, CITATION.cff, tests, continuous integration, documentation
Tools: Matplotlib (1 file), NumPy (1 file), pandas (1 file), seaborn (1 file)
Availability: 1 check, the latest on 29 September 2026: the link answers
  • 29 September 2026: the link answers
2 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;
  • 1 script, 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

Datasets cited

Data Availability

The code is available on the group’s GitHub account: https://github.com/Mlynarski-Group/behavioral-visual-tuning.

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

Recorded: type, language, journal, volume, issue, pages, dates, 2 authors, 9 MeSH terms, 36 references.

Cite

This paper

Mayer, J. M., & Młynarski, W. F. (2026). Subunit-specific behavioral modulation of sensory tuning in the visual cortex. PLoS computational biology, 22(4), e1014123. https://doi.org/10.1371/journal.pcbi.1014123

BibTeX

@article{mayer2026subunit,
author = {Mayer, Julia M. and Młynarski, Wiktor F.},
title = {{Subunit-specific behavioral modulation of sensory tuning in the visual cortex}},
journal = {PLoS computational biology},
year = {2026},
month = apr,
volume = {22},
number = {4},
pages = {e1014123},
publisher = {PLOS},
issn = {1553-734X},
doi = {10.1371/journal.pcbi.1014123},
url = {https://doi.org/10.1371/journal.pcbi.1014123},
pmid = {41941411},
pmcid = {PMC13082715}
}

RIS

TY - JOUR
AU - Mayer, Julia M.
AU - Młynarski, Wiktor F.
TI - Subunit-specific behavioral modulation of sensory tuning in the visual cortex
T2 - PLoS computational biology
J2 - PLoS Comput Biol
PY - 2026
DA - 2026/04/06
VL - 22
IS - 4
SP - e1014123
SN - 1553-734X
PB - PLOS
DO - 10.1371/journal.pcbi.1014123
UR - https://doi.org/10.1371/journal.pcbi.1014123
LA - en
ER -

CSL-JSON

{
"id": "10.1371/journal.pcbi.1014123",
"type": "article-journal",
"title": "Subunit-specific behavioral modulation of sensory tuning in the visual cortex",
"container-title": "PLoS computational biology",
"author": [
{
"family": "Mayer",
"given": "Julia M."
},
{
"family": "Młynarski",
"given": "Wiktor F."
}
],
"container-title-short": "PLoS Comput Biol",
"volume": "22",
"issue": "4",
"page": "e1014123",
"DOI": "10.1371/journal.pcbi.1014123",
"PMID": "41941411",
"PMCID": "PMC13082715",
"ISSN": "1553-734X",
"publisher": "PLOS",
"URL": "https://doi.org/10.1371/journal.pcbi.1014123",
"language": "en",
"issued": {
"date-parts": [
[
2026,
4,
6
]
]
}
}

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.1126/sciadv.aed4172 [code]
Locomotion optimizes sensory representations through a computational principle shared by rodents and primates.
Journal: Science advances
In common: pandas, Matplotlib, NumPy, 10 references, author Wiktor F. Młynarski
[2] doi:10.1371/journal.pcbi.1014157 [code]
Modeling spatial contrast sensitivity in responses of primate retinal ganglion cells to natural movies.
Journal: PLoS computational biology
In common: pandas, NumPy, computational modeling (no new data), 4 references
[3] doi:10.1126/sciadv.adv5652 [code]
The anterior cingulate cortex modulates pupil-linked arousal.
Journal: Science advances
In common: seaborn, pandas, Matplotlib, 1 other tool, systems, 4 references
[4] doi:10.1038/s41467-026-71725-0 [code]
Interactions across hemispheres in prefrontal cortex reflect global cognitive processing.
Journal: Nature communications
In common: pandas, Matplotlib, NumPy, 5 references
[5] doi:10.1038/s41467-026-71667-7
Behavioural states control binocular vision through input-specific mechanisms.
Journal: Nature communications
In common: mouse, 6 references
[6] doi:10.1038/s41467-026-75347-4 [code]
Sleep reveals dynamics integrating and segregating movement and stimulus representations in V1.
Journal: Nature communications
In common: pandas, Matplotlib, NumPy, systems, mouse, 4 references
[7] doi:10.1038/s41467-026-74227-1 [code]
Age-related changes in behavioural and neural variability in a decision-making task.
Journal: Nature communications
In common: seaborn, pandas, Matplotlib, 1 other tool, mouse, 3 references
[8] 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, Matplotlib, 1 other tool, 3 references
[9] doi:10.1371/journal.pone.0356243 [code]
Functional organization and natural scene responses across mouse visual cortical areas revealed with encoding manifolds.
Journal: PloS one
In common: pandas, Matplotlib, NumPy, mouse, 3 references
[10] doi:10.1016/j.neuron.2026.07.016 [code]
Inferring brain-wide interactions using data-constrained recurrent neural network models.
Journal: Neuron
In common: Matplotlib, NumPy, computational modeling (no new data), systems, mouse, 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.