Dexterous single sniffs for ethological active olfaction.
One block of code here has a permanent identifier (oscr:b:…), listed with the matches below: citable for good, with a page of its own. Select a match and press Cite to copy it. What a block identifier is.
The 5 matches
- [1] § MATERIALS AND METHODS › Data acquisition and analysis: Breathing signals ↔ fig2_figS2.ipynb, lines 185 to 261 · score 0.70 · bandpass filtered, instantaneous phase, Hilbert, analytic, angle, PLVs · Report a mismatch
- [2] § MATERIALS AND METHODS › Data acquisition and analysis: Breathing signals ↔ fig2GHI_S3BC_Sniff_nonsniff_phase_cophase_analysis_clean.ipynb, lines 236 to 321 · score 0.63 · resetting model, cophase, regression, R2, iteration, slope · Report a mismatch
- [3] § MATERIALS AND METHODS › Data acquisition and analysis: Breathing signals ↔ sniff_analysis.py, lines 8 to 138 · score 0.61 · search window, filtered signal, extrema, amplitude, 500 ms, Breathing · block
oscr:b:0V6G53HDS1NY7-1· Report a mismatch - [4] § RESULTS › The breathing rhythm adjusts abruptly around food sniffs ↔ fig2GHI_S3BC_Sniff_nonsniff_phase_cophase_analysis_clean.ipynb, lines 236 to 321 · score 0.54 · resetting model, cophase, regression, S3, R2, slope · Report a mismatch
- [5] § RESULTS › The breathing rhythm adjusts abruptly around food sniffs ↔ fig2_figS2.ipynb, lines 449 to 517 · score 0.51 · instantaneous phase, breathing phase, S2, inspirations, Figure 2 · Report a mismatch
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 · 580 lines · 20 KB · CC-BY-4.0 · 2 matches
- # %%
- import numpy as np
- from matplotlib import pyplot as plt
- import matplotlib as mpl
- import scipy.signal as signal
- import pandas as pd
- import glob
- import seaborn as sns
- import scipy.ndimage as filters#changed from scipy.ndimage.filters as the namespace was deprecated 05/24/2023
- import pickle
- import scipy.stats as stats
- import astropy.stats.circstats as circstats
- # %%
- %matplotlib ipympl
- # %%
- from ploting import *
- # %%
- from extented_stats_tools import *
- # %%
- from signal_processing import *
- # %%
- set_plot_style()
- set_pub_plots()
- # %%
- out_folder='.\\source_data'
- # %%
- INSP_df_all2=pd.read_pickle(out_folder+'\\INSP_df_all2.pkl')
- # %%
- sniff_df=INSP_df_all2[(INSP_df_all2['IsSniff']==True)]
- # %%
- sniff_df_P=pd.read_pickle(out_folder+'\\sniff_df_P_6mice.pkl')
- trace_array_p=np.load(out_folder+'\\trace_array_6mice_all_pelltes.npy')
- # %%
- HN_d_interped_all_P=np.load(out_folder+'\\HN_d_interped_all_P.npy')
- # %%
- dt_p=sniff_df_P['hand_sniff']-sniff_df_P['t0']
- # %%
- def shuffle_trace(data,window_size=1,sr=10000):#data: 2d-array
- #random shuffling
- shuffle_point=np.random.randint(0,data.shape[-1]-int(sr*window_size),data.shape[0])
- window_array_x=np.stack([np.arange(data.shape[0])]*int(sr*window_size),axis=1)
- window_array_y=np.stack([np.arange(int(sr*window_size))]*data.shape[0])+shuffle_point[:,None]
- shuffled_data=data[(window_array_x,window_array_y)]
- return shuffled_data
- # %%
- def re_align_trace(data,event_times,insptimes,window_size=1,sr=10000):#data.shape[0]==len(event_times),
- #randomly choose peri-sniff insp time and use as mock sniff time wile perserve the "delta t" fro each real event
- all_time_shifts=[]
- for i in range (data.shape[0]):
- re_align_point_range=[(event_times.iloc[i]-window_size/2),(event_times.iloc[i]+window_size/2)]
- mask=np.logical_and(insptimes>re_align_point_range[0],insptimes<re_align_point_range[1])
- time_shifts=insptimes-event_times.iloc[i]
- time_shift=np.random.choice(time_shifts[mask])
- all_time_shifts.append(time_shift)
- all_time_shifts=(np.asarray(all_time_shifts)*sr).astype(int)
- window_array_x=np.stack([np.arange(data.shape[0])]*int(sr*window_size),axis=1)
- window_array_y=np.stack([np.arange(int(sr*window_size))]*data.shape[0])+all_time_shifts[:,None]+int(sr*window_size/2)
- aligned_data=data[(window_array_x,window_array_y)]
- return aligned_data
- # %%
- mice_ids=sniff_df_P['mouse_id'].unique()
- # %%
- trace_array_ave=[]
- HN_d_interped_ave=[]
- dt_p_mice=[]
- trace_array_allmice=[]
- HN_d_interped_trace_array_allmice=[]
- trace_array_p_min_sub=trace_array_p-trace_array_p[:,10000][:,None]
- for mouse_id in mice_ids:
- mouse_ind=sniff_df_P['mouse_id']==mouse_id
- trace_mouse=trace_array_p_min_sub[mouse_ind]
- HN_d_interped_mouse=HN_d_interped_all_P[mouse_ind]
- dt_p_mouse=dt_p[mouse_ind]
- trace_array_mouseave=np.mean(trace_mouse,axis=0)
- HN_d_interped_mouseave=np.mean(HN_d_interped_mouse,axis=0)
- trace_array_ave.append(trace_array_mouseave)
- HN_d_interped_ave.append(HN_d_interped_mouseave)
- trace_array_allmice.append(trace_mouse)
- HN_d_interped_trace_array_allmice.append(HN_d_interped_mouse)
- dt_p_mice.append(dt_p_mouse)
- # %%
- lowcut=1
- highcut=30
- order=3
- fs=10000
- # %%
- phase_hist_all=[]
- phase_hist_all_shuffled=[]
- phase_hist_all_realigned=[]
- phase_hist_all_realigned=[]
- instantaneous_phase_realigned_all=[]
- instantaneous_phase_mouse_all=[]
- lowcut=2
- γn_all_mice=[]
- for i,mouse_traces in enumerate(trace_array_allmice):
- mouse_id=mice_ids[i]
- mouse_traces_filtered=np.empty((mouse_traces.shape[0],mouse_traces.shape[1]))
- for i3 in range(mouse_traces.shape[0]):
- mouse_traces_filtered[i3]=butter_bandpass_filter(mouse_traces[i3],lowcut, highcut, fs, order)
- analytic_trace_mouse=signal.hilbert(mouse_traces_filtered)
- instantaneous_phase_mouse =np.angle(analytic_trace_mouse)
- instantaneous_phase_mouse = np.rad2deg(instantaneous_phase_mouse)
- instantaneous_phase_t=np.stack([np.arange(instantaneous_phase_mouse.shape[1])*1000/fs-1000]*instantaneous_phase_mouse.shape[0])
- instantaneous_phase_shuffled=shuffle_trace(instantaneous_phase_mouse)
- mouse_sniff_df=sniff_df_P[sniff_df_P['mouse_id']==mouse_id]
- vid_ids=mouse_sniff_df['vid_id'].unique()
- instantaneous_phase_realigned=[]
- for i2 in range(vid_ids.size):
- vid_sniff_df=mouse_sniff_df[mouse_sniff_df['vid_id']==vid_ids[i2]]
- vid_df=INSP_df_all2[INSP_df_all2['vid_id']==vid_ids[i2]]
- instantaneous_phase_mouse_vid=instantaneous_phase_mouse[mouse_sniff_df['vid_id']==vid_ids[i2]]
- event_times=vid_sniff_df['t0']
- insptimes=vid_df['t0'][vid_df['IsSniff']==False]
- instantaneous_phase_realigned_vid=re_align_trace(instantaneous_phase_mouse_vid,event_times,insptimes)
- instantaneous_phase_realigned.append(instantaneous_phase_realigned_vid)
- instantaneous_phase_realigned=np.concatenate(instantaneous_phase_realigned,axis=0)
- instantaneous_phase_realigned_all.append(instantaneous_phase_realigned)
- instantaneous_phase_mouse_all.append(instantaneous_phase_mouse)
- phase_hist_mouse=np.histogram2d(instantaneous_phase_t[:,5000:15000].ravel(),(instantaneous_phase_mouse[:,5000:15000]/180).ravel(),[150,36],density=True)
- phase_hist_mouse_shuffled=np.histogram2d(instantaneous_phase_t[:,5000:15000].ravel(),(instantaneous_phase_shuffled/180).ravel(),[150,36],density=True)
- phase_hist_mouse_realigned=np.histogram2d(instantaneous_phase_t[:,5000:15000].ravel(),(instantaneous_phase_realigned/180).ravel(),[150,36],density=True)
- mids=0.5*(phase_hist_mouse[2][1:] + phase_hist_mouse[2][:-1])
- phase_hist_mouse=phase_hist_mouse[0]/np.sum(phase_hist_mouse[0],axis=1)[:,None]
- phase_hist_mouse_shuffled=phase_hist_mouse_shuffled[0]/np.sum(phase_hist_mouse_shuffled[0],axis=1)[:,None]
- phase_hist_mouse_realigned=phase_hist_mouse_realigned[0]/np.sum(phase_hist_mouse_realigned[0],axis=1)[:,None]
- phase_hist_all_shuffled.append(phase_hist_mouse_shuffled)
- phase_hist_all_realigned.append(phase_hist_mouse_realigned)
- phase_hist_all.append(phase_hist_mouse)
- γn=1/2*np.sqrt(np.pi/(mouse_traces.shape[0]))
- γn_all_mice.append(γn)
- # %%
- iteration_n=10000
- PLV_realigned_allmice_ave_alliterations=[]
- for i in range (iteration_n):
- if i%500==0:
- print ('iteration: '+str(round(i/iteration_n,3)*100)+'%')
- phase_hist_all_shuffled=[]
- phase_hist_all_realigned=[]
- lowcut=2
- for i,mouse_traces in enumerate(trace_array_allmice):
- mouse_id=mice_ids[i]
- mouse_traces_filtered=np.empty((mouse_traces.shape[0],mouse_traces.shape[1]))
- for i3 in range(mouse_traces.shape[0]):
- mouse_traces_filtered[i3]=butter_bandpass_filter(mouse_traces[i3],lowcut, highcut, fs, order)
- analytic_trace_mouse=signal.hilbert(mouse_traces_filtered)
- instantaneous_phase_mouse =np.angle(analytic_trace_mouse)
- instantaneous_phase_mouse = np.rad2deg(instantaneous_phase_mouse)
- instantaneous_phase_t=np.stack([np.arange(instantaneous_phase_mouse.shape[1])*1000/fs-1000]*instantaneous_phase_mouse.shape[0])
- instantaneous_phase_shuffled=shuffle_trace(instantaneous_phase_mouse)
- mouse_sniff_df=sniff_df_P[sniff_df_P['mouse_id']==mouse_id]
- vid_ids=mouse_sniff_df['vid_id'].unique()
- instantaneous_phase_realigned=[]
- for i2 in range(vid_ids.size):
- vid_sniff_df=mouse_sniff_df[mouse_sniff_df['vid_id']==vid_ids[i2]]
- vid_df=INSP_df_all2[INSP_df_all2['vid_id']==vid_ids[i2]]
- instantaneous_phase_mouse_vid=instantaneous_phase_mouse[mouse_sniff_df['vid_id']==vid_ids[i2]]
- event_times=vid_sniff_df['t0']
- insptimes=vid_df['t0'][vid_df['IsSniff']==False]
- instantaneous_phase_realigned_vid=re_align_trace(instantaneous_phase_mouse_vid,event_times,insptimes)
- instantaneous_phase_realigned.append(instantaneous_phase_realigned_vid)
- instantaneous_phase_realigned=np.concatenate(instantaneous_phase_realigned,axis=0)
- phase_hist_mouse=np.histogram2d(instantaneous_phase_t[:,5000:15000].ravel(),(instantaneous_phase_mouse[:,5000:15000]/180).ravel(),[150,36],density=True)
- phase_hist_mouse_shuffled=np.histogram2d(instantaneous_phase_t[:,5000:15000].ravel(),(instantaneous_phase_shuffled/180).ravel(),[150,36],density=True)
- phase_hist_mouse_realigned=np.histogram2d(instantaneous_phase_t[:,5000:15000].ravel(),(instantaneous_phase_realigned/180).ravel(),[150,36],density=True)
- mids=0.5*(phase_hist_mouse[2][1:] + phase_hist_mouse[2][:-1])
- phase_hist_mouse=phase_hist_mouse[0]/np.sum(phase_hist_mouse[0],axis=1)[:,None]
- phase_hist_mouse_shuffled=phase_hist_mouse_shuffled[0]/np.sum(phase_hist_mouse_shuffled[0],axis=1)[:,None]
- phase_hist_mouse_realigned=phase_hist_mouse_realigned[0]/np.sum(phase_hist_mouse_realigned[0],axis=1)[:,None]
- phase_hist_all_shuffled.append(phase_hist_mouse_shuffled)
- phase_hist_all_realigned.append(phase_hist_mouse_realigned)
- phase_2dhist_realigned_ave=np.average(np.stack(phase_hist_all_realigned),axis=0)
- PLV_realigned_allmice=[]
- for i in range(len(phase_hist_all_realigned)):
- phase_2dhist_realigned_mouse=phase_hist_all_realigned[i]
- PLV_mouse_realigned=1-circstats.circvar(np.stack([mids*np.pi]*phase_2dhist_realigned_mouse.shape[0]),weights=phase_2dhist_realigned_mouse,axis=-1)
- PLV_realigned_allmice.append(PLV_mouse_realigned)
- PLV_realigned_allmice_ave=np.mean(np.array(PLV_realigned_allmice),axis=0)
- PLV_realigned_allmice_ave_alliterations.append(PLV_realigned_allmice_ave)
- PLV_realigned_allmice_ave_alliterations=np.stack(PLV_realigned_allmice_ave_alliterations)
- # %%
- phase_2dhist_ave=np.average(np.stack(phase_hist_all),axis=0)
- phase_2dhist_shuffled_ave=np.average(np.stack(phase_hist_all_shuffled),axis=0)
- phase_2dhist_realigned_ave=np.average(np.stack(phase_hist_all_realigned),axis=0)
- # %%
- phase_hist_mouse_realigned=np.load(out_folder+'\\phase_hist_mouse_realigned.npy')
- # %%
- phase_2dhist_shuffled_ave=np.load(out_folder+'\\phase_2dhist_shuffled_ave.npy')
- # %%
- PLV_realigned_allmice_ave_alliterations=np.load(out_folder+'\\10000iter_PLV_realigned_allmice_ave_alliterations.npy')
- # %%
- phase_hist_all_shuffled=np.load(out_folder+'\\phase_hist_all_shuffled.npy')
- # %%
- phase_hist_all_shuffled.shape
- # %%
- # %%
- real_PLV=1-circstats.circvar(np.stack([mids*np.pi]*phase_2dhist_ave.shape[0]),weights=phase_2dhist_ave,axis=1)
- # %%
- γn_all=1/2*np.sqrt(np.pi/344)
- # %%
- real_PLV_corected=(real_PLV-γn_all)/(1-γn_all)
- # %%
- PLV_realigned_allmice_ave_alliterations_corrected=(PLV_realigned_allmice_ave_alliterations-γn_all)/(1-γn_all)
- # %%
- cvar_data=np.stack([[mids*np.pi]*phase_hist_all_shuffled.shape[2]]*phase_hist_all_shuffled.shape[1])
- PLV_mice_avehist_shuffled=1-circstats.circvar(cvar_data,weights=np.mean(phase_hist_all_shuffled,axis=0),axis=-1)
- # %%
- PLV_mice_avehist_shuffled_corrected=(PLV_mice_avehist_shuffled-γn_all)/(1-γn_all)
- # %%
- PLV_mice_avehist_shuffled=PLV_mice_avehist_shuffled_corrected
- real_PLV=real_PLV_corected
- PLV_realigned_allmice_ave_alliterations=PLV_realigned_allmice_ave_alliterations_corrected
- # %%
- y1=weighted_quantiles_ndarray(values=PLV_mice_avehist_shuffled, weights=np.array([1]*PLV_mice_avehist_shuffled.shape[0]), axis=0,quantiles=0.999, interpolate=True)
- y2=weighted_quantiles_ndarray(values=PLV_mice_avehist_shuffled, weights=np.array([1]*PLV_mice_avehist_shuffled.shape[0]), axis=0,quantiles=0.001, interpolate=True)
- median=weighted_quantiles_ndarray(values=PLV_mice_avehist_shuffled, weights=np.array([1]*PLV_mice_avehist_shuffled.shape[0]), axis=0,quantiles=0.5, interpolate=True)
- # %%
- phase_hist_all[0].shape
- # %%
- zoom=1
- fig,axearr=plt.subplots(nrows=2,ncols=3,figsize=(5*zoom,3.2*zoom))
- ax1 = axearr[0, 0]
- ax4 = axearr[1,0]
- ax3 = axearr[0, 2]
- ax2 =axearr[0, 1]
- ax5 =axearr[1, 1]
- ax6 =axearr[1, 2]
- t_plot=np.array((instantaneous_phase_mouse_all[3].shape[0])*[np.arange(instantaneous_phase_mouse_all[3].shape[1])/fs-1])*1000
- set_ax_style(ax1)
- ax1.plot(t_plot.T,(instantaneous_phase_mouse_all[3].T)/180,'purple',alpha=0.05,linewidth=0.5)
- ax1.plot(t_plot[0],np.mean(instantaneous_phase_mouse_all[3],axis=0)/180,'purple',alpha=0.8)
- ax1.set_xbound(-500,500)
- ax1.set_yticks(np.arange(-1,1.1,0.25))
- ax1.set_yticklabels(['-π','','-π/2','','0','','π/2','','π'])
- ax1.set_ybound(-1,1)
- ax1.set_xticks([-400,-200,0,200,400])
- ax1.set_xticklabels([-400,-200,0,200,400])
- set_ax_style(ax2)
- y_plot=np.stack([np.mean(instantaneous_phase_mouse_all[i],axis=0) for i in range(len(instantaneous_phase_mouse_all))])/180
- t_plot=np.array((y_plot.shape[0])*[(np.arange((y_plot.shape[1]))/fs-1)*1000])
- ax2.plot(t_plot.T,y_plot.T,'purple',alpha=0.3)
- ax2.plot(t_plot[0],np.mean(y_plot,axis=0),'purple',alpha=1)
- ax2.set_yticks(np.arange(-1,1.1,0.25))
- ax2.set_yticklabels(['-π','','-π/2','','0','','π/2','','π'])
- ax2.set_xbound(-500,500)
- ax2.set_ybound(-1,1)
- ax2.set_xticks([-400,-200,0,200,400])
- ax2.set_xticklabels([-400,-200,0,200,400])
- set_ax_style(ax4)
- ax4.set_yticks(np.arange(0,36.1,4.5))
- ax4.set_yticklabels(['-π','','-π/2','','0','','π/2','','π'])
- ax4.set_xticklabels([-400,-200,0,200,400])
- ax4.set_xticks([75-60,75-30,75,75+30,75+60])
- ax4.set_xticklabels([-400,-200,0,200,400])
- ax1.set_ylabel('Breathing phase',color='k',fontsize=8)
- set_ax_style(ax5)
- cm_mouse=ax4.pcolormesh((phase_2dhist_ave).T,cmap='seismic',vmin=0,vmax=0.15)
- cm_mouse2=ax5.pcolormesh((phase_2dhist_shuffled_ave).T,cmap='seismic',vmin=0,vmax=0.15)
- ax4.set_title('Observed',color='r',fontsize=8)
- ax5.set_title('Shuffled',color='k',fontsize=8)
- ax5.set_yticks(np.arange(0,36.1,4.5))
- ax5.set_yticklabels(['-π','','-π/2','','0','','π/2','','π'])
- ax5.set_xticklabels([-400,-200,0,200,400])
- ax5.set_xticks([75-60,75-30,75,75+30,75+60])
- ax5.set_xticklabels([-400,-200,0,200,400])
- ax5.set_xlabel('Time (ms)',fontsize=8)
- ax=ax6
- set_ax_style(ax6)
- threshold_plv=0.27
- ax.axvline(np.argmax(real_PLV>threshold_plv)*1000/150-500,color='r')
- weights = np.ones_like(75-(np.argmin((PLV_realigned_allmice_ave_alliterations[:,:75]>threshold_plv)[:,::-1],axis=-1))) / len(75-(np.argmin((PLV_realigned_allmice_ave_alliterations[:,:75]>threshold_plv)[:,::-1],axis=-1)))
- bins=np.arange(50,100,1)*1000/150-500
- hist=ax.hist((75-(np.argmin((PLV_realigned_allmice_ave_alliterations[:,:75]>threshold_plv)[:,::-1],axis=-1)))*1000/150-500,weights=weights,bins=bins,color='grey')
- ax.set_xlabel('Time (s)')
- ax.set_ylabel('probability')
- ax3.plot(np.arange(real_PLV.shape[0]),real_PLV,'r')
- ax3.plot(np.arange(real_PLV.shape[0]),PLV_realigned_allmice_ave_alliterations[3],'b')
- ax3.set_xticks([75-60,75-30,75,75+30,75+60])
- ax3.set_xticklabels([-400,-200,0,200,400])
- ax3.axvline(75,ls='--',color='k')
- ax3.set_ybound([0,1])
- ax3.set_xbound([0,150])
- #axearr[1].set_ylabel('Breathing Phase',color='k',fontsize=8)
- ax3.set_ylabel('PLV',color='k',fontsize=8)
- fig.tight_layout()
- set_ax_style(ax3)
- # #pdf_max_phase_real=np.cumsum(np.max(phase_2dhist_ave,axis=1)/((np.max(phase_2dhist_ave,axis=1).sum()))*100)
- # #pdf_max_phase_shuffled=np.cumsum((np.max(phase_2dhist_shuffled_ave,axis=1)/(np.max(phase_2dhist_shuffled_ave,axis=1).sum())*100))
- for i in range((len(phase_hist_all))):
- ax=ax3
- #set_ax_style(ax)
- PLV=1-circstats.circvar(np.stack([mids*np.pi]*phase_hist_all[i].shape[0]),weights=phase_hist_all[i],axis=1)
- ax.plot(np.arange(PLV.shape[0]),PLV,'r',alpha=0.3)
- ax.fill_between(np.arange(np.mean(PLV_mice_avehist_shuffled,axis=0).shape[0]),y1=y1,y2=y2,color='k',alpha=0.5)
- fig.savefig(out_folder+'\\fig2ABC.pdf')
- # %%
- zoom=1
- fig,axearr=plt.subplots(nrows=2,ncols=3,figsize=(5*zoom,3.2*zoom))
- ax1 = axearr[0, 0]
- ax4 = axearr[1,0]
- ax3 = axearr[0, 2]
- ax2 =axearr[0, 1]
- ax5 =axearr[1, 1]
- ax6 =axearr[1, 2]
- t_plot=np.array((instantaneous_phase_realigned_all[3].shape[0])*[np.arange(instantaneous_phase_realigned_all[3].shape[1])/fs-0.5])*1000
- set_ax_style(ax1)
- ax1.plot(t_plot.T,(instantaneous_phase_realigned_all[3].T)/180,'purple',alpha=0.05,linewidth=0.5)
- ax1.plot(t_plot[0],np.mean(instantaneous_phase_realigned_all[3],axis=0)/180,'purple',alpha=0.8)
- ax1.set_xbound(-500,500)
- ax1.set_yticks(np.arange(-1,1.1,0.25))
- ax1.set_yticklabels(['-π','','-π/2','','0','','π/2','','π'])
- ax1.set_ybound(-1,1)
- ax1.set_xticks([-400,-200,0,200,400])
- ax1.set_xticklabels([-400,-200,0,200,400])
- set_ax_style(ax2)
- y_plot=np.stack([np.mean(instantaneous_phase_realigned_all[i],axis=0) for i in range(len(instantaneous_phase_realigned_all))])/180
- t_plot=np.array((y_plot.shape[0])*[(np.arange((y_plot.shape[1]))/fs-0.5)*1000])
- ax2.plot(t_plot.T,y_plot.T,'purple',alpha=0.3)
- ax2.plot(t_plot[0],np.mean(y_plot,axis=0),'purple',alpha=1)
- ax2.set_yticks(np.arange(-1,1.1,0.25))
- ax2.set_yticklabels(['-π','','-π/2','','0','','π/2','','π'])
- ax2.set_xbound(-500,500)
- ax2.set_ybound(-1,1)
- ax2.set_xticks([-400,-200,0,200,400])
- ax2.set_xticklabels([-400,-200,0,200,400])
- set_ax_style(ax3)
- ax3.set_yticks(np.arange(0,36.1,4.5))
- ax3.set_yticklabels(['-π','','-π/2','','0','','π/2','','π'])
- ax3.set_xticklabels([-400,-200,0,200,400])
- ax3.set_xticks([75-60,75-30,75,75+30,75+60])
- ax3.set_xticklabels([-400,-200,0,200,400])
- ax1.set_ylabel('Breathing phase',color='k',fontsize=8)
- set_ax_style(ax5)
- cm_mouse=ax3.pcolormesh((phase_2dhist_realigned_ave).T,cmap='seismic',vmin=0,vmax=0.15)
- ax3.set_title('Random inspiration',color='r',fontsize=8)
- ax=ax6
- set_ax_style(ax6)
- fig.tight_layout()
- fig.savefig(out_folder+'\\figS2.pdf')
- # %%
- time_intevals=[]
- mouse_df=INSP_df_all2[(INSP_df_all2['mouse_id']=='msn05')]
- for vid_id in mouse_df['vid_id'].unique():
- vid_id_sub=mouse_df[mouse_df['vid_id']==vid_id]
- hand_sniffs=vid_id_sub[vid_id_sub['IsSniff']==True]
- mouse_id=vid_id_sub['mouse_id'].unique()[0]
- hand_sniffs=hand_sniffs[hand_sniffs['foodtype']=='P']['hand_sniff']
- pre_durations=[]
- time_intevals_df_vid=pd.DataFrame()
- for hand_sniff in hand_sniffs:
- insp_time_intervals=vid_id_sub['t0'].values-hand_sniff
- insp_onset_ind=np.argmin(np.abs(insp_time_intervals))
- insp_indexing_arr=insp_onset_ind+np.arange(3)-1
- insp_indexing_arr_inrange_mask=insp_indexing_arr[np.logical_and(insp_indexing_arr<(insp_time_intervals.shape[0]),insp_indexing_arr>=0)]
- insp_indexing_arr_inrange_mask_type=(np.arange(3)-1)[np.logical_and(insp_indexing_arr<(insp_time_intervals.shape[0]),insp_indexing_arr>=0)]
- if (insp_indexing_arr_inrange_mask_type.size>=2) & (insp_indexing_arr_inrange_mask_type[0]==-1):
- time_interval=insp_time_intervals[insp_indexing_arr_inrange_mask[insp_indexing_arr_inrange_mask_type==-1]].round(5)
- time_intevals.append(time_interval)
- else:
- pass
- time_intevals=np.asarray(time_intevals).ravel()
- sorter=np.argsort(time_intevals)
- # %%
- fig,axearr=plt.subplots(nrows=1,ncols=1,figsize=(6.5/3,2))
- fs=10000
- set_ax_style(axearr)
- ax=axearr
- trace_array_plot=trace_array_allmice[3]
- norm_data=trace_array_plot-trace_array_plot[:,10000][:,None]
- data_plot=norm_data[sorter]
- q=10
- data_plot=signal.decimate(data_plot, q,axis=-1)
- data_plot=signal.decimate(data_plot, q,axis=-1)
- data_plot=data_plot*10
- cm0=ax.pcolormesh(data_plot,vmin=(np.mean(np.min(data_plot,axis=-1))),vmax=(np.mean(np.max(data_plot,axis=-1))),cmap='Greens_r')
- ax.axvline(1*fs/q/q,color='black',ls='--',alpha=1)
- ax.set_xticks(np.arange(0,20010/q/q,2000/q/q))
- ax.set_yticks(np.arange(0,155,50))
- ax.set_xticklabels('')
- ax.set_xticks(np.arange(0,20010/q/q,5000/q/q))
- ax.set_xticklabels(np.around(np.arange(-1,1.1,0.5),2).astype(str))
- ax.set_ylabel('Food Sniffs',fontsize=8)
- ax.set_xlabel('Time (s)',fontsize=8)
- ax.set_yticks(np.arange(0,155,50))
- l_limit=(-0.2+1)*fs
- r_limit=(0.2+1)*fs
- fig.tight_layout()
- fig.savefig(out_folder+'\\fig2D.pdf')
- # %%
fig2_figS2.ipynb, under CC-BY-4.0 · at the source
Overview
- Department of Neuroscience, Feinberg School of Medicine, Northwestern University, Chicago, IL, USA
- Department of Pharmacology and Therapeutics, Florida Chemical Senses Institute, University of Florida College of Medicine, Gainesville, FL, USA
- Department of Neuroscience, University of Pennsylvania Perelman School of Medicine, Philadelphia, PA, USA
Abstract
Rhythmic sniffing is considered intrinsic to active olfaction among terrestrial mammals. However, mice are known to briefly hold food under their nares while feeding, suggesting coordination of oromanual dexterity, breathing, and olfaction for nonrhythmic single sniffs. Here, we recorded kinematics and breathing as mice foraged and fed, finding that mice indeed, with clockwork-like dexterity and millisecond timing, synchronize a single inspiration with rapid head and hand movements. These solitary food sniffs are associated with abrupt resetting of the breathing rhythm, differ from stereotypical rhythmic sniffing, and exhibit behavioral modulations for different food properties. Olfactory and motor circuit manipulations demonstrate motor cortical dependence rather than reflexive neural control. Our study extends the concept of active olfaction to include this distinct form of complex motor-sensory coordination, features of which accord with the idea of discrete “snapshot” olfaction.
Reproduced under the paper's license (CC BY), from the paper cited above.
Repository
Its files are read in the Code ↔ Paper reader above, with 5 matches between paragraphs and lines of code.
Zenodo 17065558
Availability: 1 check, the latest on 27 September 2026: the link answers (HTTP 200)
- 27 September 2026: the link answers (HTTP 200)
14 files
- analysis_main_pipline_ex
ample.ipynb , Jupyter, 474 lines - extented_stats_tools.py, Python, 110 lines
- fig1_and_figS1.ipynb, Jupyter, 438 lines
- fig2GHI_S3BC_Sniff_nonsn
iff_phase_cophase_analys , Jupyter, 455 lines, 2 matchesis_clean.ipynb - fig2_figS2.ipynb, Jupyter, 580 lines, 2 matches
- fig3.ipynb, Jupyter, 528 lines
- fig4.ipynb, Jupyter, 773 lines
- fig5.ipynb, Jupyter, 1,610 lines
- fig_S4.ipynb, Jupyter, 105 lines
- image_and_video_tools.py
, Python, 142 lines - misc.py, Python, 50 lines
- ploting.py, Python, 90 lines
- signal_processing.py, Python, 136 lines
- sniff_analysis.py, Python, 305 lines, 1 match
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;
- 14 scripts, each with its path and the digest of its content;
- 5 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), from the paper cited above.
Versions
The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.
Version 1, 27 September 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 7 authors, 7 MeSH terms, 1 funder, 55 references.
Cite
This paper
Gao, M., Barrett, J. M., Fischer, R., McCrimmon, D. R., Wesson, D. W., Ma, M., & Shepherd, G. M. G. (2026). Dexterous single sniffs for ethological active olfaction. Science advances, 12(27), eaed3610. https://
BibTeX
@article{gao2026dexterou
author = {Gao, Mang and Barrett, John M. and Fischer, Rita and McCrimmon, Donald R. and Wesson, Daniel W. and Ma, Minghong and Shepherd, Gordon M. G.},
title = {{Dexterous single sniffs for ethological active olfaction}},
journal = {Science advances},
year = {2026},
month = jul,
volume = {12},
number = {27},
pages = {eaed3610},
publisher = {American Association for the Advancement of Science},
issn = {2375-2548},
doi = {10.1126/
url = {https://
pmid = {42397911},
pmcid = {PMC13339859}
}
RIS
TY - JOUR
AU - Gao, Mang
AU - Barrett, John M.
AU - Fischer, Rita
AU - McCrimmon, Donald R.
AU - Wesson, Daniel W.
AU - Ma, Minghong
AU - Shepherd, Gordon M. G.
TI - Dexterous single sniffs for ethological active olfaction
T2 - Science advances
J2 - Sci Adv
PY - 2026
DA - 2026/
VL - 12
IS - 27
SP - eaed3610
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": "Dexterous single sniffs for ethological active olfaction",
"container-title": "Science advances",
"author": [
{
"family": "Gao",
"given": "Mang"
},
{
"family": "Barrett",
"given": "John M."
},
{
"family": "Fischer",
"given": "Rita"
},
{
"family": "McCrimmon",
"given": "Donald R."
},
{
"family": "Wesson",
"given": "Daniel W."
},
{
"family": "Ma",
"given": "Minghong"
},
{
"family": "Shepherd",
"given": "Gordon M. G."
}
],
"container-title-short":
"volume": "12",
"issue": "27",
"page": "eaed3610",
"DOI": "10.1126/
"PMID": "42397911",
"PMCID": "PMC13339859",
"ISSN": "2375-2548",
"publisher": "American Association for the Advancement of Science",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
7,
3
]
]
}
}
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.1038/s41467-024-55644-6 [code]
- Dopaminergic signaling to ventral striatum neurons initiates sniffing behavior.Journal: Nature communicationsIn common: pandas, SciPy, Matplotlib, 1 other tool, mouse, 11 references, 2 authors
- [2] doi:10.7554/elife.105112
- Cortical dynamics in hand/
forelimb S1 and M1 evoked by brief photostimulation of the mouse's hand. Journal: eLifeIn common: mouse, 2 references, 4 authors - [3] doi:10.1016/j.celrep.2022.110450
- State-dependent olfactory processing in freely behaving mice.Journal: Cell reportsIn common: mouse, 6 references, 2 authors
- [4] doi:10.1016/j.isci.2022.105625
- Machine learning-based clustering and classification of mouse behaviors via respiratory patterns.Journal: iScienceIn common: mouse, 8 references, author Minghong Ma
- [5] doi:10.7554/elife.85303 [code]
- Behavioral discrimination and olfactory bulb encoding of odor plume intermittency.Journal: eLifeIn common: mouse, 9 references
- [6] doi:10.1038/s41467-026-72445-1 [code]
- Perception and neural representation of intermittent odor stimuli in mice.Journal: Nature communicationsIn common: Pingouin, seaborn, pandas, 3 other tools, mouse, 6 references
- [7] doi:10.1016/j.isci.2024.111275 [code]
- Communication subspace dynamics of the canonical olfactory pathway.Journal: iScienceIn common: seaborn, pandas, SciPy, 2 other tools, 6 references
- [8] doi:10.1126/sciadv.aee1002 [code]
- Theta oscillations are an organizational unit of odor processing in the olfactory bulb.Journal: Science advancesIn common: 8 references
- [9] doi:10.1038/s41380-025-03075-0
- Directing negative emotional states through parallel genetically-distinct basolateral amygdala pathways to ventral striatum subregions.Journal: Molecular psychiatryIn common: mouse, 1 reference, 2 authors
- [10] doi:10.1016/j.isci.2024.111285 [code]
- Circuit mechanism underlying fragmented sleep and memory deficits in 16p11.2 deletion mouse model of autism.Journal: iScienceIn common: Pingouin, OpenCV, seaborn, 4 other tools, mouse, author Minghong Ma
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, 14 scripts, and 5 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:8fbe76fa4ab82b27…
Add the badge to the code's README
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 -->
[](https://openscicode.org/badge/doi/10.1126/sciadv.aed3610)
<!-- oscr-badge:end -->reStructuredText
.. oscr-badge:start
.. image:: https://openscicode.org/badge/doi/10.1126/sciadv.aed3610.svg
:target: https://openscicode.org/badge/doi/10.1126/sciadv.aed3610
:alt: OSCR
.. oscr-badge:endHTML
<!-- oscr-badge:start -->
<a href="https://openscicode.org/badge/doi/10.1126/sciadv.aed3610"><img src="https://openscicode.org/badge/doi/10.1126/sciadv.aed3610.svg" alt="OSCR"></a>
<!-- oscr-badge:end -->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)
Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.
