The anterior cingulate cortex modulates pupil-linked arousal.
The 4 matches
- [1] § MATERIALS AND METHODS › Pupil event and facial movement event classification ↔ 4.ipynb, lines 217–367 · score 0.68 · Pupil trace, pupil dilation events, Event amplitude, lowest, median, facial movement
- [2] § MATERIALS AND METHODS › Pupil event and facial movement event classification ↔ 7.ipynb, lines 36–188 · score 0.68 · Pupil trace, pupil dilation events, Event amplitude, lowest, median, facial movement
- [3] § RESULTS › Pupil-linked autonomic arousal is associated with facial movements and locomotion ↔ 1.ipynb, lines 528–565 · score 0.57 · pupil face correlation, median filter, smooth, Facial movement, speed, frame
- [4] § MATERIALS AND METHODS › Heart rate measurement ↔ S1.ipynb, lines 97–124 · score 0.51 · Heart rate, scalar, mapped, error
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
Jupyter notebook · 1,046 lines · 42 KB · CC-BY-4.0 · 1 match
- # %%
- import numpy as np
- from scipy import stats
- import seaborn as sns
- import matplotlib.pyplot as plt
- import pandas as pd
- from scipy.signal import find_peaks, peak_widths,resample,correlate, correlation_lags,peak_prominences,resample,butter, lfilter, freqz,medfilt
- from matplotlib import rcParams
- from scipy.stats import ttest_ind,ttest_rel,zscore
- params = {
- "font.family" : "Arial",
- 'pdf.fonttype' : 42,
- 'axes.labelsize': 10,
- 'axes.titlesize': 11,
- 'axes.linewidth': 0.5,
- 'xtick.labelsize':9,
- 'xtick.major.width':0.5,
- 'ytick.major.width':0.5,
- 'ytick.labelsize':9,
- 'axes.spines.top':False,
- 'axes.spines.right':False
- }
- rcParams['figure.figsize'] = 21.7,8.27
- rcParams.update(params)
- def format_ax(ax,xlim,ylim,xspace,yspace):
- ax.set_xticks(np.arange(xlim[0],xlim[1]+ xspace,xspace))
- ax.set_yticks(np.arange(ylim[0],ylim[1]+ yspace,yspace))
- ax.set(ylim=(ylim[0], ylim[1]))
- ax.set(xlim=(xlim[0], xlim[1]))
- # %%
- ### Functions to low pass filter pupil and face data
- ###low pass filter pupil
- def filter_pupil(pupil,order = 1,cutoff = 1,fs = 20):
- def butter_lowpass(cutoff, fs, order=5):
- return butter(order, cutoff, fs=fs, btype='low', analog=False)
- def butter_lowpass_filter(data, cutoff, fs, order=5):
- b, a = butter_lowpass(cutoff, fs, order=order)
- y = lfilter(b, a, data)
- return y
- return butter_lowpass_filter(pupil, cutoff, fs, order)
- ###low pass filter face
- def filter_face(face,order = 1,cutoff = 0.1,fs = 20):
- def butter_lowpass(cutoff, fs, order=5):
- return butter(order, cutoff, fs=fs, btype='low', analog=False)
- def butter_lowpass_filter(data, cutoff, fs, order=5):
- b, a = butter_lowpass(cutoff, fs, order=order)
- y = lfilter(b, a, data)
- return y
- return butter_lowpass_filter(face, cutoff, fs, order)
- # %%
- ### get face aligned events
- def get_face_events(id,date):
- id = id
- date = date
- #face_path = f"/Users/nithik/Library/CloudStorage/Box-Box/HUDA_LAB_DATA/ethanol_data/{id}/{date}/{date}_{id}_sess_1_FaceProcessed.csv"
- #path = f"/Users/nithik/Library/CloudStorage/Box-Box/HUDA_LAB_DATA/ethanol_data/{id}/{date}/{date}_{id}_sess_1_ProcessedData.csv"
- face_path = f"{base_dir}/{id}/{date}/{date}_{id}_sess_1_FaceProcessed.csv"
- path = f"{base_dir}/{id}/{date}/{date}_{id}_sess_1_ProcessedData.csv"
- df = pd.read_csv(path)
- pupil = np.array(df["Pupil Size"])
- time = np.array(df["Time"])
- speed = np.array(df["Running Speed"])
- speed[0] = 0
- dff = np.array(df["dFF"])
- face = np.array(pd.read_csv(face_path)["Facial Movement"])
- ###Onset detection alogrithm
- filter = filter_face(face) ###first apply low pass filter to face trace
- def groupSequence(x):
- it = iter(x)
- prev, res = next(it), []
- while prev is not None:
- start = next(it, None)
- if start and start > prev:
- res.append(prev)
- elif res:
- yield list(res + [prev])
- res = []
- prev = start
- regions = list(groupSequence(filter))
- corrected_regions = [region for region in regions if len(region) >=15 ] ###only include regions that are >750ms
- corrected_regions = [region for region in corrected_regions if region[0]<np.median(filter) ] ###only include onsets that occur below z = median
- region_ix = [[np.where(filter == val)[0][0] for val in region] for region in corrected_regions] ### get indices for each region
- ##join regions that are near eachother
- new = []
- for i,first in enumerate(region_ix):
- if i < len(region_ix)-1:
- second = region_ix[i + 1]
- end = first[-1]
- start = second[0]
- if first[0] - region_ix[i - 1][-1]>20:
- if start-end<= 20:
- #print(first[0]/20,second[0]/20)
- new.append(first + second)
- else:
- new.append(first)
- region_ix = new
- corrected_regions = [filter[region[0]:region[-1]] for region in region_ix]
- new = []
- for i,first in enumerate(region_ix):
- if i < len(region_ix)-1:
- second = region_ix[i + 1]
- end = first[-1]
- start = second[0]
- if first[0] - region_ix[i - 1][-1]>10:
- if start-end<= 10:
- new.append(first + second)
- else:
- new.append(first)
- region_ix = new
- corrected_regions = [filter[region[0]:region[-1]] for region in region_ix]
- onsets_ix = [region[0] for region in region_ix]
- ###get offsets and durations for pupil event
- offset_ix = []
- durations = []
- for i,(region,index) in enumerate(zip(corrected_regions,region_ix)):
- if i < len(region_ix)-1:
- start = index[-1] ###end of region
- end = region_ix[i+1][0] ### start of next region
- onset_y = region[0]
- offsets = np.where(filter[start:end] <= onset_y) ###find ix of first point that goes below onset
- if len(offsets[0]) == 0: ###if it never goes below onset then use lowest value
- offset = start + np.argmin(filter[start:end])
- else:
- offset = start + offsets[0][0]
- offset_ix.append(offset)
- durations.append((offset-index[0])/20)
- ###handle last face event
- start = region_ix[-1][-1]
- end = 36000
- onset_y = corrected_regions[-1][0]
- offsets = np.where(filter[start:end] <= onset_y)
- if len(offsets[0]) == 0:
- offset = end-1
- else:
- offset = start + np.argmin(filter[start:end])
- offset_ix[-1] = offset
- durations[-1] = (offset-region_ix[-1][0])/20
- ###get face event amplitudes
- amplitudes = []
- amplitudes_ix = []
- ###change to align to raw peak
- for on,off in zip(onsets_ix,offset_ix):
- #print(on,off)
- amplitudes.append(max(filter[on:off])-filter[on])
- amplitudes_ix.append(on + np.argmax(face[on:off]))
- ###get face event slopes
- slopes = []
- for region in corrected_regions:
- run = len(region)/20
- rise = region[-1]-region[0]
- slopes.append(rise/run)
- ###get dff data
- aucs = []
- peak_dffs = []
- mean_dffs = []
- for onset,offset in zip(onsets_ix,offset_ix):
- baseline = np.mean(dff[onset-40:onset-10])
- peak_dffs.append(max(dff[onset:offset]) - np.mean(dff[onset-30:onset]))
- mean_dffs.append(np.mean(dff[onset:offset])- np.mean(dff[onset-20:onset]))
- ###create dictionary
- events_dict = {"durations" :durations,
- "amplitudes": amplitudes,
- "slopes" : slopes,
- "onsets" : onsets_ix,
- "offsets" : offset_ix,
- "peak_ix" : amplitudes_ix,
- "ID" : [id] * len(durations),
- "Date" : [date] * len(durations),
- "peak_dff" : peak_dffs,
- "mean_dff" : mean_dffs,
- }
- return pd.DataFrame.from_dict(events_dict)
- # %%
- ### Function to extract pupil dilation events
- def get_pupil_events(id,date):
- id = id
- date = date
- face_path = f"{base_dir}/{id}/{date}/{date}_{id}_sess_1_FaceProcessed.csv"
- path = f"{base_dir}/{id}/{date}/{date}_{id}_sess_1_ProcessedData.csv"
- df = pd.read_csv(path)
- pupil = np.array(df["Pupil Size"])
- time = np.array(df["Time"])
- speed = np.array(df["Running Speed"])
- speed[0] = 0
- dff = np.array(df["dFF"])
- face = np.array(pd.read_csv(face_path)["Facial Movement"])
- ###Onset detection alogrithm
- filter = filter_pupil(pupil) ###first apply low pass filter to pupil trace
- def groupSequence(x):
- it = iter(x)
- prev, res = next(it), []
- while prev is not None:
- start = next(it, None)
- if start and start > prev:
- res.append(prev)
- elif res:
- yield list(res + [prev])
- res = []
- prev = start
- regions = list(groupSequence(filter))
- corrected_regions = [region for region in regions if len(region) >=15 ] ###only include regions that are >750ms
- corrected_regions = [region for region in corrected_regions if region[0]<np.median(filter) ] ###only include onsets that occur below z = median
- region_ix = [[np.where(filter == val)[0][0] for val in region] for region in corrected_regions] ### get indices for each region
- ##join regions that are near eachother
- new = []
- for i,first in enumerate(region_ix):
- if i < len(region_ix)-1:
- second = region_ix[i + 1]
- end = first[-1]
- start = second[0]
- if first[0] - region_ix[i - 1][-1]>20:
- if start-end<= 20:
- #print(first[0]/20,second[0]/20)
- new.append(first + second)
- else:
- new.append(first)
- region_ix = new
- corrected_regions = [filter[region[0]:region[-1]] for region in region_ix]
- new = []
- for i,first in enumerate(region_ix):
- if i < len(region_ix)-1:
- second = region_ix[i + 1]
- end = first[-1]
- start = second[0]
- if first[0] - region_ix[i - 1][-1]>10:
- if start-end<= 10:
- #print(first[0]/20,second[0]/20)
- new.append(first + second)
- else:
- new.append(first)
- region_ix = new
- corrected_regions = [filter[region[0]:region[-1]] for region in region_ix]
- onsets_ix = [region[0] for region in region_ix]
- ###get offsets and durations for pupil event
- offset_ix = []
- durations = []
- for i,(region,index) in enumerate(zip(corrected_regions,region_ix)):
- if i < len(region_ix)-1:
- start = index[-1] ###end of region
- end = region_ix[i+1][0] ### start of next region
- onset_y = region[0]
- offsets = np.where(filter[start:end] <= onset_y) ###find ix of first point that goes below onset
- if len(offsets[0]) == 0: ###if it never goes below onset then use lowest value
- offset = start + np.argmin(filter[start:end])
- else:
- offset = start + offsets[0][0]
- offset_ix.append(offset)
- durations.append((offset-index[0])/20)
- ###handle last pupil event
- start = region_ix[-1][-1]
- end = 36000
- onset_y = corrected_regions[-1][0]
- offsets = np.where(filter[start:end] <= onset_y)
- if len(offsets[0]) == 0:
- offset = end-1
- else:
- offset = start + np.argmin(filter[start:end])
- offset_ix[-1] = offset
- durations[-1] = (offset-region_ix[-1][0])/20
- ###get pupil event amplitudes
- amplitudes = []
- amplitudes_ix = []
- for on,off in zip(onsets_ix,offset_ix):
- #print(on,off)
- amplitudes.append(max(filter[on:off])-filter[on])
- amplitudes_ix.append(on + np.argmax(filter[on:off]))
- ###get pupil event slopes
- slopes = []
- for region in corrected_regions:
- run = len(region)/20
- rise = region[-1]-region[0]
- slopes.append(rise/run)
- ###get dff data
- aucs = []
- peak_dffs = []
- mean_dffs = []
- for onset,offset in zip(onsets_ix,offset_ix):
- peak_dffs.append(max(dff[onset:offset]) - np.mean(dff[onset-30:onset]))
- aucs.append(np.trapz(dff[onset:offset]))
- mean_dffs.append(np.mean(dff[onset:offset])- np.mean(dff[onset-20:onset]))
- ###create dictionary
- events_dict = {"durations" :durations,
- "amplitudes": amplitudes,
- "slopes" : slopes,
- "onsets" : onsets_ix,
- "offsets" : offset_ix,
- "peak_ix" : amplitudes_ix,
- "ID" : [id] * len(durations),
- "Date" : [date] * len(durations),
- "peak_dff" : peak_dffs,
- "aucs" : aucs,
- "mean_dff" : mean_dffs,
- }
- return pd.DataFrame.from_dict(events_dict)
- # %%
- ### Function to align trials to event onsets, adapted from https://www.tdt.com/docs/sdk/offline-data-analysis/offline-data-python/examples/LickBouts/#time-filter-around-lick-bout-epocs
- def trial_align(event_on,time,values,fps = 20,pre = 2, post = 10):
- TRANGE = [-pre*np.floor(fps), post*np.floor(fps)]
- trial_snips = []
- array_ind = []
- pre_stim = []
- post_stim = []
- for on in event_on:
- # If the bout cannot include pre-time seconds before event, make zero
- if on < pre:
- pass
- else:
- # find first time index after bout onset
- array_ind.append(np.where(time > on)[0][0])
- # find index corresponding to pre and post stim durations
- pre_stim.append(array_ind[-1] + TRANGE[0])
- post_stim.append(array_ind[-1] + TRANGE[1])
- trial_snips.append(values[int(pre_stim[-1]):int(post_stim[-1])])
- # If some snippets are less than max length, add nans to end of array
- max1 = np.max([np.size(x) for x in trial_snips])
- for i,x in enumerate(trial_snips):
- if np.size(x) < max1:
- trial_snips[i] = np.concatenate((trial_snips[i],np.full((max1-np.size(trial_snips[i])), np.nan)))
- mean_trial_snips = np.mean(trial_snips, axis=0)
- peri_time = np.linspace(1, len(mean_trial_snips), len(mean_trial_snips))/fps - pre
- return trial_snips,peri_time
- # %%
- ### Path to data. RENAME THIS TO YOUR PATH
- base_dir = "/Users/nithik/Library/CloudStorage/Box-Box/SAS-DLS-HudaLab/Nithik-SciAdv2026-alldata"
- # %%
- ### Get data for Fig4A
- id = "004116"
- date = "20230815"
- face_path = f"{base_dir}/{id}/{date}/{date}_{id}_sess_1_FaceProcessed.csv"
- path = f"{base_dir}/{id}/{date}/{date}_{id}_sess_1_ProcessedData.csv"
- df = pd.read_csv(path)
- pupil = np.array(df["Pupil Size"])
- time = np.array(df["Time"])
- speed = zscore(np.array(df["Running Speed"]))
- dff = np.array(df["dFF"])
- face = np.array(pd.read_csv(face_path)["Facial Movement"])
- df["Facial Movement"] = face
- df["Running Speed"] = speed
- events = get_pupil_events(id,date)
- # %%
- ### Plot Fig4A
- ax2,(ax1,ax2,ax4) = plt.subplots(3,figsize = (20,10))
- onsets = [on/20 for on in events["onsets"]]
- sns.lineplot(data = df, x = "Time", y = "Pupil Size", ax = ax1,color = "dodgerblue",linewidth = 1)
- sns.lineplot(data = df, x = "Time", y = "Facial Movement", ax = ax2,linewidth = 1,color = "purple")
- sns.lineplot(data = df, x = "Time", y = "dFF", ax = ax4,linewidth = 1,color = "green")
- x_start = 1510
- x_end = 1585
- x_space = 5
- ylim = [-4,4]
- for ax in [ax1,ax2,ax4]:
- ax.set_xlim(x_start,x_end)
- ax.set_xticks(np.arange(x_start,x_end + x_space,x_space))
- ax.set_ylim(ylim)
- ax1.set_ylim(-2,2)
- ax2.set_ylim(-2,5)
- ax1.spines[['bottom']].set_visible(False)
- ax1.spines[['left']].set_visible(False)
- ax1.get_xaxis().set_visible(False)
- ax1.get_yaxis().set_visible(False)
- ax2.spines[['bottom']].set_visible(False)
- ax2.spines[['left']].set_visible(False)
- ax2.get_xaxis().set_visible(False)
- ax2.get_yaxis().set_visible(False)
- ax4.spines[['bottom']].set_visible(False)
- ax4.spines[['left']].set_visible(False)
- ax4.get_xaxis().set_visible(False)
- ax4.get_yaxis().set_visible(False)
- ax1.plot([1540,1545], [1, 1],color = "black",linewidth = 1)
- ax1.plot([1512,1512], [0, 1],color = "dodgerblue",linewidth = 1)
- ax2.plot([1512,1512], [0, 2],color = "purple",linewidth = 1)
- ax4.plot([1512,1512], [0, 2],color = "green",linewidth = 1)
- # %%
- ### Get data for Fig4B
- id_date = {
- "004113":["20230808"],
- "004114":["20230808","20230815"],
- "004115":["20230804","20230808","20230815"],
- "004116":["20230804","20230808","20230815"],
- "004117":["20230804","20230808","20230815"],
- "004118":["20230804","20230808","20230815"]
- }
- df_list = []
- for id,dates in id_date.items():
- for date in dates:
- events = get_pupil_events(id,date)
- onsets = [on/20 for on in events["onsets"]] ###get pupil onsets
- onsets_ix = events["onsets"]
- face_path = f"{base_dir}/{id}/{date}/{date}_{id}_sess_1_FaceProcessed.csv"
- path = f"{base_dir}/{id}/{date}/{date}_{id}_sess_1_ProcessedData.csv"
- df = pd.read_csv(path)
- pupil = filter_pupil(np.array(df["Pupil Size"]))
- time = np.array(df["Time"])
- speed = zscore(np.array(df["Running Speed"]))
- dff = np.array(df["dFF"])
- face = np.array(pd.read_csv(face_path)["Facial Movement"])
- onsets = [time[on] for on in events["onsets"]]
- dil_matrix,dil_times = trial_align(onsets,time,pupil,fps = 20,pre = 2, post = 10 )
- trial_matrix,trial_times = trial_align(onsets,time,dff,fps = 20,pre = 2, post = 10)
- face_matrix,face_times = trial_align(onsets,time,face,fps = 20,pre = 2, post = 10)
- for j,trial in enumerate(dil_matrix):
- baseline = np.mean(pupil[onsets_ix[j] - 40:onsets_ix[j] - 10])
- trial = trial - baseline
- for i,Time in enumerate(dil_times):
- new_dict = {"Time from Onset (s)" : Time, "trial" : j, "value" : trial[i], "type" : "Pupil","ID" : id, "Date": date}
- df_list.append(new_dict)
- for j,trial in enumerate(trial_matrix):
- baseline = np.mean(dff[onsets_ix[j] - 40:onsets_ix[j] - 10])
- trial = trial - baseline
- for i,Time in enumerate(trial_times):
- new_dict = {"Time from Onset (s)" : Time, "trial" : j, "value" : trial[i], "type" : "dff","ID" : id, "Date": date}
- df_list.append(new_dict)
- for j,trial in enumerate(face_matrix):
- baseline = np.mean(face[onsets_ix[j] - 40:onsets_ix[j] - 10])
- trial = trial - baseline
- for i,Time in enumerate(face_times):
- new_dict = {"Time from Onset (s)" : Time, "trial" : j, "value" : trial[i], "type" : "Face","ID" : id, "Date": date}
- df_list.append(new_dict)
- pupil_align_df = pd.DataFrame.from_dict(df_list)
- # %%
- ### Plot Fig4B
- plt.figure(figsize = (1.5,1.2))
- ax = sns.lineplot(data = pupil_align_df.groupby(["ID","Time from Onset (s)","type"]).mean().reset_index(), x = "Time from Onset (s)", y = "value", hue = "type",errorbar = "se",palette= ["purple","dodgerblue","green"],legend= None,linewidth = 1)
- format_ax(ax,(-1,2),(-0.5,1.5),1,0.5)
- ax.set_xlabel("Time from dilation onset (s)")
- ax.set_ylabel('Z-Score')
- ax.axvline(0,linestyle = "dashed", color = "black",linewidth = 0.5)
- # %%
- ### Get data for Fig4C
- id_date = {
- "004113":["20230808"],
- "004114":["20230808","20230815"],
- "004115":["20230804","20230808","20230815"],
- "004116":["20230804","20230808","20230815"],
- "004117":["20230804","20230808","20230815"],
- "004118":["20230804","20230808","20230815"]
- }
- df_list = []
- for id,dates in id_date.items():
- for date in dates:
- events = get_face_events(id,date)
- onsets = [on/20 for on in events["onsets"]] ###get face onsets
- onsets_ix = events["onsets"]
- face_path = f"{base_dir}/{id}/{date}/{date}_{id}_sess_1_FaceProcessed.csv"
- path = f"{base_dir}/{id}/{date}/{date}_{id}_sess_1_ProcessedData.csv"
- df = pd.read_csv(path)
- pupil = filter_pupil(np.array(df["Pupil Size"]))
- time = np.array(df["Time"])
- speed = zscore(np.array(df["Running Speed"]))
- dff = np.array(df["dFF"])
- face = np.array(pd.read_csv(face_path)["Facial Movement"])
- dil_matrix,dil_times = trial_align(onsets,time,pupil,fps = 20,pre = 2, post = 10 )
- trial_matrix,trial_times = trial_align(onsets,time,dff,fps = 20,pre = 2, post = 10)
- face_matrix,face_times = trial_align(onsets,time,face,fps = 20,pre = 2, post = 10)
- for j,trial in enumerate(dil_matrix):
- baseline = np.mean(pupil[onsets_ix[j] - 40:onsets_ix[j] - 10])
- trial = trial - baseline
- for i,Time in enumerate(dil_times):
- new_dict = {"Time from Onset (s)" : Time, "trial" : j, "value" : trial[i], "type" : "Pupil","ID" : id, "Date": date}
- df_list.append(new_dict)
- for j,trial in enumerate(trial_matrix):
- baseline = np.mean(dff[onsets_ix[j] - 40:onsets_ix[j] - 10])
- trial = trial - baseline
- for i,Time in enumerate(trial_times):
- new_dict = {"Time from Onset (s)" : Time, "trial" : j, "value" : trial[i], "type" : "dff","ID" : id, "Date": date}
- df_list.append(new_dict)
- for j,trial in enumerate(face_matrix):
- baseline = np.mean(face[onsets_ix[j] - 40:onsets_ix[j] - 10])
- trial = trial - baseline
- for i,Time in enumerate(face_times):
- new_dict = {"Time from Onset (s)" : Time, "trial" : j, "value" : trial[i], "type" : "Face","ID" : id, "Date": date}
- df_list.append(new_dict)
- face_align_df = pd.DataFrame.from_dict(df_list)
- # %%
- ### Plot Fig4C
- plt.figure(figsize = (1.5,1.2))
- ax = sns.lineplot(data = face_align_df.groupby(["ID","Time from Onset (s)","type"]).mean().reset_index(), x = "Time from Onset (s)", y = "value", hue = "type",errorbar = "se",palette= ["purple","dodgerblue","green"],legend= None,linewidth = 1)
- format_ax(ax,(-1,2),(-0.5,1.5),1,0.5)
- ax.set_xlabel("Time from facial movement onset (s)")
- ax.set_ylabel('Z-Score')
- ax.axvline(0,linestyle = "dashed", color = "black",linewidth = 0.5)
- # %%
- ### Get data for Fig4D (Left)
- id_date = {
- "004113":["20230808"],
- "004114":["20230808","20230815"],
- "004115":["20230804","20230808","20230815"],
- "004116":["20230804","20230808","20230815"],
- "004117":["20230804","20230808","20230815"],
- "004118":["20230804","20230808","20230815"]
- }
- df_list = []
- for id,dates in id_date.items():
- for date in dates:
- events = get_pupil_events(id,date)
- onsets_ix = events["onsets"]
- amplitudes = events["amplitudes"]
- binned_amps = np.array(pd.qcut(amplitudes,q = 4,labels = [1,2,3,4]))
- face_path = f"{base_dir}/{id}/{date}/{date}_{id}_sess_1_FaceProcessed.csv"
- path = f"{base_dir}/{id}/{date}/{date}_{id}_sess_1_ProcessedData.csv"
- df = pd.read_csv(path)
- pupil = filter_pupil(np.array(df["Pupil Size"]))
- time = np.array(df["Time"])
- speed = zscore((np.array(df["Running Speed"])))
- dff = np.array(df["dFF"])
- face = np.array(pd.read_csv(face_path)["Facial Movement"])
- onsets = [time[on]for on in events["onsets"]] ###get pupil onsets
- dil_matrix,dil_times = trial_align(onsets,time,pupil,fps = 20,pre = 10, post = 10 )
- for j,trial in enumerate(dil_matrix):
- baseline = np.mean(pupil[onsets_ix[j] - 40:onsets_ix[j] - 10])
- trial = trial - baseline
- for i,Time in enumerate(dil_times):
- new_dict = {"Time from Onset (s)" : Time, "trial" : j, "value" : trial[i], "type" : "Pupil","ID" : id, "Date": date,"amp":amplitudes[j],"animal_amp_bin":binned_amps[j]}
- df_list.append(new_dict)
- trial_matrix,trial_times = trial_align(onsets,time,dff,fps = 20,pre = 10, post = 10)
- for j,trial in enumerate(trial_matrix):
- baseline = np.mean(dff[onsets_ix[j] - 40:onsets_ix[j] - 10])
- trial = trial - baseline
- for i,Time in enumerate(trial_times):
- new_dict = {"Time from Onset (s)" : Time, "trial" : j, "value" : trial[i], "type" : "dff","ID" : id, "Date": date,"amp":amplitudes[j],"animal_amp_bin":binned_amps[j]}
- df_list.append(new_dict)
- face_matrix,face_times = trial_align(onsets,time,face,fps = 20,pre = 10, post = 10)
- for j,trial in enumerate(face_matrix):
- baseline = np.mean(face[onsets_ix[j] - 40:onsets_ix[j] - 10])
- trial = trial - baseline
- for i,Time in enumerate(face_times):
- new_dict = {"Time from Onset (s)" : Time, "trial" : j, "value" : trial[i], "type" : "face","ID" : id, "Date": date,"amp":amplitudes[j],"animal_amp_bin":binned_amps[j]}
- df_list.append(new_dict)
- pupil_onset_df = pd.DataFrame.from_dict(df_list)
- # %%
- ### Get data for Fig4D (Right)
- id_date = {
- "004113":["20230808"],
- "004114":["20230808","20230815"],
- "004115":["20230804","20230808","20230815"],
- "004116":["20230804","20230808","20230815"],
- "004117":["20230804","20230808","20230815"],
- "004118":["20230804","20230808","20230815"]
- }
- df_list = []
- for id,dates in id_date.items():
- for date in dates:
- events = get_pupil_events(id,date)
- onsets_ix = events["onsets"]
- amplitudes = events["amplitudes"]
- binned_amps = np.array(pd.qcut(amplitudes,q = 4,labels = [1,2,3,4]))
- face_path = f"{base_dir}/{id}/{date}/{date}_{id}_sess_1_FaceProcessed.csv"
- path = f"{base_dir}/{id}/{date}/{date}_{id}_sess_1_ProcessedData.csv"
- df = pd.read_csv(path)
- pupil = filter_pupil(np.array(df["Pupil Size"]))
- time = np.array(df["Time"])
- speed = zscore((np.array(df["Running Speed"])))
- dff = np.array(df["dFF"])
- face = np.array(pd.read_csv(face_path)["Facial Movement"])
- peaks = [time[ix] for ix in events["peak_ix"]] ### get pupil peaks
- dil_matrix,dil_times = trial_align(peaks,time,pupil,fps = 20,pre = 10, post = 10 )
- for j,trial in enumerate(dil_matrix):
- baseline = np.mean(pupil[onsets_ix[j] - 40:onsets_ix[j] - 10])
- trial = trial - baseline
- for i,Time in enumerate(dil_times):
- new_dict = {"Time from Onset (s)" : Time, "trial" : j, "value" : trial[i], "type" : "Pupil","ID" : id, "Date": date,"amp":amplitudes[j],"animal_amp_bin":binned_amps[j]}
- df_list.append(new_dict)
- trial_matrix,trial_times = trial_align(peaks,time,dff,fps = 20,pre = 10, post = 10)
- for j,trial in enumerate(trial_matrix):
- baseline = np.mean(dff[onsets_ix[j] - 40:onsets_ix[j] - 10])
- trial = trial - baseline
- for i,Time in enumerate(trial_times):
- new_dict = {"Time from Onset (s)" : Time, "trial" : j, "value" : trial[i], "type" : "dff","ID" : id, "Date": date,"amp":amplitudes[j],"animal_amp_bin":binned_amps[j]}
- df_list.append(new_dict)
- face_matrix,face_times = trial_align(peaks,time,face,fps = 20,pre = 10, post = 10)
- for j,trial in enumerate(face_matrix):
- baseline = np.mean(face[onsets_ix[j] - 40:onsets_ix[j] - 10])
- trial = trial - baseline
- for i,Time in enumerate(face_times):
- new_dict = {"Time from Onset (s)" : Time, "trial" : j, "value" : trial[i], "type" : "face","ID" : id, "Date": date,"amp":amplitudes[j],"animal_amp_bin":binned_amps[j]}
- df_list.append(new_dict)
- pupil_peak_df = pd.DataFrame.from_dict(df_list)
- # %%
- ### Plot Fig4D (Top Left)
- plt.figure(figsize = (1.25,1))
- ax = sns.lineplot(data = pupil_onset_df.groupby(["ID","Time from Onset (s)","type","animal_amp_bin"]).mean().reset_index().query("type == 'Pupil'").query("animal_amp_bin == [1,4]"), x = "Time from Onset (s)", y = "value",errorbar = "se",hue = "animal_amp_bin",palette= ["cornflowerblue","darkblue"],legend = None,linewidth = 1)
- ax.xaxis.label.set_visible(False)
- ax.set_ylabel("Pupil size \n(z-scr)")
- ax.axvline(0,linestyle = "dashed", color = "black",linewidth = 0.5)
- format_ax(ax,(-0.5,0.5),(-0.5,3),0.5,0.5)
- # %%
- ### Plot Fig4D (Bottom Left)
- plt.figure(figsize = (1.25,1.25))
- ax = sns.lineplot(data = pupil_onset_df.groupby(["ID","Time from Onset (s)","type","animal_amp_bin"]).mean().reset_index().query("type == 'dff'").query("animal_amp_bin == [1,4]"), x = "Time from Onset (s)", y = "value",errorbar = "se",hue = "animal_amp_bin",palette= ["palegreen","darkgreen"],legend = None,linewidth = 1)
- ax.set_xlabel("Time from \nDilation Onset (s)")
- ax.set_ylabel("∆ F/F (z-scr)")
- ax.axvline(0,linestyle = "dashed", color = "black",linewidth = 0.5)
- format_ax(ax,(-0.5,0.5),(-0.5,2),0.5,0.5)
- # %%
- ### Plot Fig4D (Top Right)
- plt.figure(figsize = (1.25,1))
- ax = sns.lineplot(data = pupil_peak_df.groupby(["ID","Time from Onset (s)","type","animal_amp_bin"]).mean().reset_index().query("type == 'Pupil'").query("animal_amp_bin == [1,4]"), x = "Time from Onset (s)", y = "value",errorbar = "se",hue = "animal_amp_bin",palette= ["cornflowerblue","darkblue"],legend = None,linewidth = 1)
- ax.xaxis.label.set_visible(False)
- ax.set_ylabel("Pupil Size \n(z-scr)")
- ax.axvline(0,linestyle = "dashed", color = "black",linewidth = 0.5)
- format_ax(ax,(-0.5,1),(-0.5,3),0.5,0.5)
- ax.spines[['left']].set_visible(False)
- ax.get_yaxis().set_visible(False)
- # %%
- ### Plot Fig4D (Bottom Right)
- plt.figure(figsize = (1.25,1.25))
- ax = sns.lineplot(data = pupil_peak_df.groupby(["ID","Time from Onset (s)","type","animal_amp_bin"]).mean().reset_index().query("type == 'dff'").query("animal_amp_bin == [1,4]"), x = "Time from Onset (s)", y = "value",errorbar = "se",hue = "animal_amp_bin",palette= ["palegreen","darkgreen"],legend = None,linewidth = 1)
- ax.set_xlabel("Time from \nDilation Peak (s)")
- ax.set_ylabel("∆ F/F (z-scr)")
- ax.axvline(0,linestyle = "dashed", color = "black",linewidth = 0.5)
- format_ax(ax,(-0.5,1),(-0.5,2),0.5,0.5)
- ax.spines[['left']].set_visible(False)
- ax.get_yaxis().set_visible(False)
- # %%
- ### Get data for Fig4E
- id_date = {
- "004113":["20230808"],
- "004114":["20230808","20230815"],
- "004115":["20230804","20230808","20230815"],
- "004116":["20230804","20230808","20230815"],
- "004117":["20230804","20230808","20230815"],
- "004118":["20230804","20230808","20230815"]
- }
- labels = ["1","2","3","4"]
- df_list = []
- for id,dates in id_date.items():
- for date in dates:
- events = get_pupil_events(id,date)
- peak_ix = events["peak_ix"]
- onsets = [on for on in events["onsets"]] ###get pupil onsets ix
- onsets_ix = events["onsets"]
- offsets = [off for off in events["offsets"]] ###get pupil offsets ix
- amplitudes = events["amplitudes"]
- binned_amps = np.array(pd.qcut(amplitudes,q = 4,labels = labels))
- face_path = f"{base_dir}/{id}/{date}/{date}_{id}_sess_1_FaceProcessed.csv"
- path = f"{base_dir}/{id}/{date}/{date}_{id}_sess_1_ProcessedData.csv"
- df = pd.read_csv(path)
- pupil = np.array(df["Pupil Size"])
- time = np.array(df["Time"])
- speed = zscore((np.array(df["Running Speed"])))
- dff = np.array(df["dFF"])
- face = np.array(pd.read_csv(face_path)["Facial Movement"])
- for i,(on,off) in enumerate(zip(onsets,offsets)):
- baseline = np.mean(dff[on - 40:on - 10])
- pre_dff =np.mean(dff[on-5:on]) - baseline
- during_dff = np.mean(dff[on:off]) - baseline
- new_dict = { "trial" : i,"ID" : id, "Date": date,"amp":amplitudes[i],"animal_amp_bin":binned_amps[i],"Pre Onset ∆ F/F":pre_dff,"∆ F/F": during_dff}
- df_list.append(new_dict)
- pupil_bar_df = pd.DataFrame.from_dict(df_list)
- # %%
- ### Plot Fig4E (Left)
- plt.figure(figsize = (1,1.25))
- g = sns.pointplot(data = pupil_bar_df.groupby(["ID",'animal_amp_bin']).mean().reset_index(), x = "animal_amp_bin", y = "Pre Onset ∆ F/F",errorbar = "se",scale = 0.5, errwidth= 1.2,color ="black")
- sns.lineplot(data = pupil_bar_df.groupby(["ID",'animal_amp_bin']).mean().reset_index(), x = "animal_amp_bin", y = "Pre Onset ∆ F/F",units = "ID",estimator = None,color = "black",alpha = 0.3,linewidth = 0.5)
- g.set_xlabel("Dilation Amplitude\n Quartile")
- g.set_yticks(np.arange(-0.25,1,0.25))
- g.set(ylim=(-0.25,0.75))
- # %%
- ### Plot Fig4E (Right)
- plt.figure(figsize = (1,1.25))
- g = sns.pointplot(data = pupil_bar_df.groupby(["ID",'animal_amp_bin']).mean().reset_index(), x = "animal_amp_bin", y = "∆ F/F",errorbar = "se",scale = 0.5, errwidth= 1.2,color ="black")
- sns.lineplot(data = pupil_bar_df.groupby(["ID",'animal_amp_bin']).mean().reset_index(), x = "animal_amp_bin", y = "∆ F/F",units = "ID",estimator = None,color = "black",alpha = 0.3,linewidth = 0.5)
- g.set_xlabel("Dilation Amplitude\n Quartile")
- g.set_yticks(np.arange(-0.25,1.5,0.25))
- g.set(ylim=(0,1))
- # %%
- ### Get data for Fig 4F (Left)
- id_date = {
- "004113":["20230808"],
- "004114":["20230808","20230815"],
- "004115":["20230804","20230808","20230815"],
- "004116":["20230804","20230808","20230815"],
- "004117":["20230804","20230808","20230815"],
- "004118":["20230804","20230808","20230815"]
- }
- df_list = []
- for id,dates in id_date.items():
- for date in dates:
- events = get_face_events(id,date)
- onsets_ix = events["onsets"]
- amplitudes = events["amplitudes"]
- binned_amps = np.array(pd.qcut(amplitudes,q = 4,labels = [1,2,3,4]))
- face_path = f"{base_dir}/{id}/{date}/{date}_{id}_sess_1_FaceProcessed.csv"
- path = f"{base_dir}/{id}/{date}/{date}_{id}_sess_1_ProcessedData.csv"
- df = pd.read_csv(path)
- pupil = np.array(df["Pupil Size"])
- time = np.array(df["Time"])
- speed = zscore((np.array(df["Running Speed"])))
- dff = np.array(df["dFF"])
- face = np.array(pd.read_csv(face_path)["Facial Movement"])
- onsets = [time[on] for on in events["onsets"]]
- dil_matrix,dil_times = trial_align(onsets,time,pupil,fps = 20,pre = 10, post = 10 )
- for j,trial in enumerate(dil_matrix):
- baseline = np.mean(pupil[onsets_ix[j] - 40:onsets_ix[j] - 10])
- trial = trial - baseline
- for i,Time in enumerate(dil_times):
- new_dict = {"Time from Onset (s)" : Time, "trial" : j, "value" : trial[i], "type" : "Pupil","ID" : id, "Date": date,"amp":amplitudes[j],"animal_amp_bin":binned_amps[j]}
- df_list.append(new_dict)
- trial_matrix,trial_times = trial_align(onsets,time,dff,fps = 20,pre = 10, post = 10)
- for j,trial in enumerate(trial_matrix):
- baseline = np.mean(dff[onsets_ix[j] - 40:onsets_ix[j] - 10])
- trial = trial - baseline
- for i,Time in enumerate(trial_times):
- new_dict = {"Time from Onset (s)" : Time, "trial" : j, "value" : trial[i], "type" : "dff","ID" : id, "Date": date,"amp":amplitudes[j],"animal_amp_bin":binned_amps[j]}
- df_list.append(new_dict)
- face_matrix,face_times = trial_align(onsets,time,face,fps = 20,pre = 10, post = 10)
- for j,trial in enumerate(face_matrix):
- baseline = np.mean(face[onsets_ix[j] - 40:onsets_ix[j] - 10])
- trial = trial - baseline
- for i,Time in enumerate(face_times):
- new_dict = {"Time from Onset (s)" : Time, "trial" : j, "value" : trial[i], "type" : "face","ID" : id, "Date": date,"amp":amplitudes[j],"animal_amp_bin":binned_amps[j]}
- df_list.append(new_dict)
- face_onset_df = pd.DataFrame.from_dict(df_list)
- # %%
- ### Get data for Fig 4F (Right)
- id_date = {
- "004113":["20230808"],
- "004114":["20230808","20230815"],
- "004115":["20230804","20230808","20230815"],
- "004116":["20230804","20230808","20230815"],
- "004117":["20230804","20230808","20230815"],
- "004118":["20230804","20230808","20230815"]
- }
- df_list = []
- for id,dates in id_date.items():
- for date in dates:
- events = get_face_events(id,date)
- onsets_ix = events["onsets"]
- amplitudes = events["amplitudes"]
- binned_amps = np.array(pd.qcut(amplitudes,q = 4,labels = [1,2,3,4]))
- face_path = f"{base_dir}/{id}/{date}/{date}_{id}_sess_1_FaceProcessed.csv"
- path = f"{base_dir}/{id}/{date}/{date}_{id}_sess_1_ProcessedData.csv"
- df = pd.read_csv(path)
- pupil = filter_pupil(np.array(df["Pupil Size"]))
- time = np.array(df["Time"])
- speed = zscore((np.array(df["Running Speed"])))
- dff = np.array(df["dFF"])
- face = np.array(pd.read_csv(face_path)["Facial Movement"])
- peaks = [time[ix] for ix in events["peak_ix"]] ### get pupil peaks
- dil_matrix,dil_times = trial_align(peaks,time,pupil,fps = 20,pre = 10, post = 10 )
- for j,trial in enumerate(dil_matrix):
- baseline = np.mean(pupil[onsets_ix[j] - 40:onsets_ix[j] - 10])
- trial = trial - baseline
- for i,Time in enumerate(dil_times):
- new_dict = {"Time from Onset (s)" : Time, "trial" : j, "value" : trial[i], "type" : "Pupil","ID" : id, "Date": date,"amp":amplitudes[j],"animal_amp_bin":binned_amps[j]}
- df_list.append(new_dict)
- trial_matrix,trial_times = trial_align(peaks,time,dff,fps = 20,pre = 10, post = 10)
- for j,trial in enumerate(trial_matrix):
- baseline = np.mean(dff[onsets_ix[j] - 40:onsets_ix[j] - 10])
- trial = trial - baseline
- for i,Time in enumerate(trial_times):
- new_dict = {"Time from Onset (s)" : Time, "trial" : j, "value" : trial[i], "type" : "dff","ID" : id, "Date": date,"amp":amplitudes[j],"animal_amp_bin":binned_amps[j]}
- df_list.append(new_dict)
- face_matrix,face_times = trial_align(peaks,time,face,fps = 20,pre = 10, post = 10)
- for j,trial in enumerate(face_matrix):
- baseline = np.mean(face[onsets_ix[j] - 40:onsets_ix[j] - 10])
- trial = trial - baseline
- for i,Time in enumerate(trial_times):
- new_dict = {"Time from Onset (s)" : Time, "trial" : j, "value" : trial[i], "type" : "face","ID" : id, "Date": date,"amp":amplitudes[j],"animal_amp_bin":binned_amps[j]}
- df_list.append(new_dict)
- face_peak_df = pd.DataFrame.from_dict(df_list)
- # %%
- ### Plot Fig4F (Top Left)
- plt.figure(figsize = (1.25,1))
- ax = sns.lineplot(data = face_onset_df.groupby(["ID","Time from Onset (s)","type","animal_amp_bin"]).mean().reset_index().query("type == 'face'").query("animal_amp_bin == [1,4]"), x = "Time from Onset (s)", y = "value",errorbar = "se",hue = "animal_amp_bin",palette= ["violet","purple"],legend = None,linewidth = 1)
- ax.xaxis.label.set_visible(False)
- ax.set_ylabel("Facial\nmovement (z-scr)")
- ax.axvline(0,linestyle = "dashed", color = "black",linewidth = 0.5)
- format_ax(ax,(-0.5,0.5),(-0.5,8),0.5,0.5)
- # %%
- ### Plot Fig4F (Bottom Left)
- plt.figure(figsize = (1.25,1.25))
- ax = sns.lineplot(data = face_onset_df.groupby(["ID","Time from Onset (s)","type","animal_amp_bin"]).mean().reset_index().query("type == 'dff'").query("animal_amp_bin == [1,4]"), x = "Time from Onset (s)", y = "value",errorbar = "se",hue = "animal_amp_bin",palette= ["palegreen","darkgreen"],legend = None,linewidth = 1)
- ax.set_xlabel("Time from \nfacial movement onset (s)")
- ax.set_ylabel("∆ F/F (z-scr)")
- ax.axvline(0,linestyle = "dashed", color = "black",linewidth = 0.5)
- format_ax(ax,(-0.5,0.5),(-0.5,2),0.5,0.5)
- # %%
- ### Plot Fig4F (Top Right)
- plt.figure(figsize = (1.25,1))
- ax = sns.lineplot(data = face_peak_df.groupby(["ID","Time from Onset (s)","type","animal_amp_bin"]).mean().reset_index().query("type == 'face'").query("animal_amp_bin == [1,4]"), x = "Time from Onset (s)", y = "value",errorbar = "se",hue = "animal_amp_bin",palette= ["violet","purple"],legend = None,linewidth = 1)
- ax.xaxis.label.set_visible(False)
- ax.set_ylabel("Facial movement \n(z-scr)")
- ax.axvline(0,linestyle = "dashed", color = "black",linewidth = 0.5)
- format_ax(ax,(-0.5,1),(-0.5,8),0.5,0.5)
- ax.spines[['left']].set_visible(False)
- ax.get_yaxis().set_visible(False)
- # %%
- ### Plot Fig4F (Bottom Right)
- plt.figure(figsize = (1.25,1.25))
- ax = sns.lineplot(data = face_peak_df.groupby(["ID","Time from Onset (s)","type","animal_amp_bin"]).mean().reset_index().query("type == 'dff'").query("animal_amp_bin == [1,4]"), x = "Time from Onset (s)", y = "value",errorbar = "se",hue = "animal_amp_bin",palette= ["palegreen","darkgreen"],legend = None,linewidth = 1)
- ax.set_xlabel("Time from \nface movement peak (s)")
- ax.set_ylabel("∆ F/F (z-scr)")
- ax.axvline(0,linestyle = "dashed", color = "black",linewidth = 0.5)
- format_ax(ax,(-0.5,1),(-0.5,2),0.5,0.5)
- ax.spines[['left']].set_visible(False)
- ax.get_yaxis().set_visible(False)
- # %%
- ### Get data for Fig4G
- id_date = {
- "004113":["20230808"],
- "004114":["20230808","20230815"],
- "004115":["20230804","20230808","20230815"],
- "004116":["20230804","20230808","20230815"],
- "004117":["20230804","20230808","20230815"],
- "004118":["20230804","20230808","20230815"]
- }
- labels = ["1","2","3","4"]
- df_list = []
- for id,dates in id_date.items():
- for date in dates:
- events = get_face_events(id,date)
- peak_ix = events["peak_ix"]
- onsets = [on for on in events["onsets"]] ###get pupil onsets ix
- onsets_ix = events["onsets"]
- offsets = [off for off in events["offsets"]] ###get pupil offsets ix
- amplitudes = events["amplitudes"]
- binned_amps = np.array(pd.qcut(amplitudes,q = 4,labels = labels))
- face_path = f"{base_dir}/{id}/{date}/{date}_{id}_sess_1_FaceProcessed.csv"
- path = f"{base_dir}/{id}/{date}/{date}_{id}_sess_1_ProcessedData.csv"
- df = pd.read_csv(path)
- pupil = np.array(df["Pupil Size"])
- time = np.array(df["Time"])
- speed = zscore((np.array(df["Running Speed"])))
- dff = np.array(df["dFF"])
- face = np.array(pd.read_csv(face_path)["Facial Movement"])
- for i,(on,off) in enumerate(zip(onsets,offsets)):
- baseline = np.mean(dff[on - 40:on - 10])
- pre_dff =np.mean(dff[on-5:on]) - baseline
- during_dff = np.mean(dff[on:off]) - baseline
- new_dict = { "trial" : i,"ID" : id, "Date": date,"amp":amplitudes[i],"animal_amp_bin":binned_amps[i],"Pre Onset ∆ F/F":pre_dff,"∆ F/F": during_dff}
- df_list.append(new_dict)
- face_bar_df = pd.DataFrame.from_dict(df_list)
- # %%
- ### Plot Fig4G (Left)
- plt.figure(figsize = (1,1.25))
- g = sns.pointplot(data = face_bar_df.groupby(["ID",'animal_amp_bin']).mean().reset_index(), x = "animal_amp_bin", y = "Pre Onset ∆ F/F",errorbar = "se",scale = 0.5, errwidth= 1.2,color ="black")
- sns.lineplot(data = face_bar_df.groupby(["ID",'animal_amp_bin']).mean().reset_index(), x = "animal_amp_bin", y = "Pre Onset ∆ F/F",units = "ID",estimator = None,color = "black",alpha = 0.3,linewidth = 0.5)
- g.set_xlabel("Facial movement amplitude\n quartile")
- g.set_yticks(np.arange(-0.25,1,0.25))
- g.set(ylim=(-0.25,0.75))
- # %%
- ### Plot Fig4G (Right)
- plt.figure(figsize = (1,1.25))
- g = sns.pointplot(data = face_bar_df.groupby(["ID",'animal_amp_bin']).mean().reset_index(), x = "animal_amp_bin", y = "∆ F/F",errorbar = "se", scale = 0.5,errwidth= 1.2,color = "black")
- sns.lineplot(data = face_bar_df.groupby(["ID",'animal_amp_bin']).mean().reset_index(), x = "animal_amp_bin", y = "∆ F/F",units = "ID",estimator = None,color = "black",alpha = 0.3,linewidth = 0.5)
- g.set_ylabel("Peri-event ∆ F/F")
- g.set_xlabel("Facial movement amplitude\n quartile")
- g.set_yticks(np.arange(0,2,0.5))
- g.set(ylim=(0,1))
4.ipynb, under CC-BY-4.0 · at the source
Overview
- WM Keck Center for Collaborative Neuroscience, Department of Cell Biology and Neuroscience, Rutgers University–New Brunswick, Piscataway, NJ, USA
- Department of Psychiatry and Neuroscience, CERVO Brain Research Center, Université Laval, Québec City, Québec, Canada
Abstract
Subcortical structures like the locus coeruleus (LC) are well known to regulate pupil-linked autonomic arousal, while the role of cortical circuits in this process remains largely unclear. We designed a closed-loop optogenetic system to inactivate the anterior cingulate cortex (ACC) in real time during pupil dilations. ACC inactivation decreased the magnitude of spontaneous pupil events. In parallel, ACC population activity scaled with the magnitude of spontaneously occurring pupil dilations. In addition to modulating spontaneous arousal, ACC responses to salient sensory stimuli scaled with the size of evoked pupil dilations and ACC inactivation suppressed saliency-linked pupil events. Last, we show that LC norepinephrine neurons signal arousal faster than the ACC. However, unlike the ACC, LC responses did not scale with the magnitude of pupil dilations. Collectively, our experiments identify the ACC as a key cortical site for sustaining momentary increases in pupil-linked arousal.
Reproduced under the paper's license (CC BY-NC), from the paper cited above.
Repository
Its files are read in the Code ↔ Paper reader above, with 4 matches between paragraphs and lines of code.
Zenodo 19410291
Availability: 1 check, the latest on 28 September 2026: the link answers (HTTP 200)
- 28 September 2026: the link answers (HTTP 200)
16 files
- 1.ipynb, Jupyter, 986 lines, 1 match
- 2.ipynb, Jupyter, 722 lines
- 3.ipynb, Jupyter, 500 lines
- 4.ipynb, Jupyter, 1,046 lines, 1 match
- 5.ipynb, Jupyter, 411 lines
- 6.ipynb, Jupyter, 1,032 lines
- 7.ipynb, Jupyter, 1,587 lines, 1 match
- 8.ipynb, Jupyter, 1,444 lines
- S1.ipynb, Jupyter, 262 lines, 1 match
- S2.ipynb, Jupyter, 447 lines
- S3.ipynb, Jupyter, 443 lines
- S4.ipynb, Jupyter, 626 lines
- S5.ipynb, Jupyter, 881 lines
- S6.ipynb, Jupyter, 609 lines
- S7.ipynb, Jupyter, 321 lines
- S8.ipynb, Jupyter, 835 lines
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;
- 16 scripts, each with its path and the digest of its content;
- 4 matches between paragraphs of the paper and lines of the code (method lexical-v1);
- 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, code, and materials availability
All data and code needed to evaluate and reproduce the results in the paper are present in the paper and/
Reproduced under the paper's license (CC BY-NC), 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, 28 September 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 6 authors, 8 MeSH terms, 7 funders, 78 references.
Cite
This paper
Chintalacheruvu, N., Kalelkar, A., Alatriste-León, H., Boutin, J., Breton-Provencher, V., & Huda, R. (2026). The anterior cingulate cortex modulates pupil-linked arousal. Science advances, 12(19), eadv5652. https://
BibTeX
@article{chintalacheruvu
author = {Chintalacheruvu, Nithik and Kalelkar, Anagha and Alatriste-León, Hector and Boutin, Joël and Breton-Provencher, Vincent and Huda, Rafiq},
title = {{The anterior cingulate cortex modulates pupil-linked arousal}},
journal = {Science advances},
year = {2026},
month = may,
volume = {12},
number = {19},
pages = {eadv5652},
publisher = {American Association for the Advancement of Science},
issn = {2375-2548},
doi = {10.1126/
url = {https://
pmid = {42102204},
pmcid = {PMC13155339}
}
RIS
TY - JOUR
AU - Chintalacheruvu, Nithik
AU - Kalelkar, Anagha
AU - Alatriste-León, Hector
AU - Boutin, Joël
AU - Breton-Provencher, Vincent
AU - Huda, Rafiq
TI - The anterior cingulate cortex modulates pupil-linked arousal
T2 - Science advances
J2 - Sci Adv
PY - 2026
DA - 2026/
VL - 12
IS - 19
SP - eadv5652
SN - 2375-2548
PB - American Association for the Advancement of Science
DO - 10.1126/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1126/
"type": "article-journal",
"title": "The anterior cingulate cortex modulates pupil-linked arousal",
"container-title": "Science advances",
"author": [
{
"family": "Chintalacheruvu",
"given": "Nithik"
},
{
"family": "Kalelkar",
"given": "Anagha"
},
{
"family": "Alatriste-León",
"given": "Hector"
},
{
"family": "Boutin",
"given": "Joël"
},
{
"family": "Breton-Provencher",
"given": "Vincent"
},
{
"family": "Huda",
"given": "Rafiq"
}
],
"container-title-short":
"volume": "12",
"issue": "19",
"page": "eadv5652",
"DOI": "10.1126/
"PMID": "42102204",
"PMCID": "PMC13155339",
"ISSN": "2375-2548",
"publisher": "American Association for the Advancement of Science",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
5,
8
]
]
}
}
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.adz6495
- Pupil-linked arousal heterogeneously modulates cell-type-specific sensory processing.Journal: Science advancesIn common: systems, 15 references
- [2] doi:10.1038/s41467-026-71725-0 [code]
- Interactions across hemispheres in prefrontal cortex reflect global cognitive processing.Journal: Nature communicationsIn common: pandas, SciPy, Matplotlib, 1 other tool, 9 references
- [3] doi:10.1038/s41562-026-02533-1 [code]
- Fluctuations in arousal reflect latent state transitions that facilitate behavioural optimization.Journal: Nature human behaviourIn common: 10 references
- [4] doi:10.7554/elife.109717 [code]
- Retrosplenial cortex enables context-dependent goal-directed sensorimotor transformation.Journal: eLifeIn common: OpenCV, seaborn, pandas, 3 other tools, systems, 5 references
- [5] doi:10.1038/s41467-026-75492-w [code]
- Place and behavioral modulation of hippocampal neurons during immobility.Journal: Nature communicationsIn common: systems, 8 references
- [6] doi:10.1523/eneuro.0417-25.2026 [code]
- Learning and Motivation State Fluctuations from Motoric and Neurophysiologic Metrics during a Somatosensory Task in Mice.Journal: eNeuroIn common: 8 references
- [7] doi:10.7554/elife.110294 [code]
- Arousal modulates functional connectivity through structured and hemispherically asymmetric community architecture during wakefulness.Journal: eLifeIn common: seaborn, pandas, SciPy, 2 other tools, 5 references
- [8] doi:10.1016/j.crmeth.2026.101421 [code]
- EthoPy provides an accessible platform for reproducible behavioral neuroscience.Journal: Cell reports methodsIn common: OpenCV, seaborn, pandas, 3 other tools, 4 references
- [9] doi:10.7554/elife.99278 [code]
- Brain-wide arousal signals are segregated from movement planning in the superior colliculus of the macaque.Journal: eLifeIn common: NumPy, systems, 6 references
- [10] doi:10.1126/sciadv.aed3610 [code]
- Dexterous single sniffs for ethological active olfaction.Journal: Science advancesIn common: OpenCV, seaborn, pandas, 3 other tools, 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.
Claim this paper
Correct its record
Say what each link of this record is, remove the ones that are not the paper's, add the ones that are missing. The correction becomes a new version of the record, in its Versions section.
Validate its tracing map
You validate the map as this page shows it: 1 repository of the authors' code, each at its verified commit and with its license, 16 scripts, and 4 matches between paragraphs and code (see the Code and Map sections). It then receives a DOI on Zenodo, with you (your ORCID iD) and OSCR as its creators; the code itself is not deposited.
The map's fingerprint: sha256:8f6ed7a827fcc408…
Add the badge to its README
The badge links the code to this page. Copy one of these into the README of the paper's code: only you decide where it goes, and nothing is changed for you.
Markdown
[.
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.
