Package: pyibt
pyibtpyibt is a Python module that extends the functionality of the ECCELES Electrophysiology Suite with a simple and intuitive API for the analysis and visualization of electrophysiology data in Python.ECCELES is an online electrophysiology acquisition program developed for the IGOR Pro data analysis platform (WaveMetrics) that allows for conducting and and analyzing highly customizable and flexible electrophysiological experiments. ELLECES however requires a very specific computing environment to run correctly, requires proprietary software (Igor Pro), and has a limited ability to implement automated and repetitive analyses.pyibt was developed to read the custom binary files generated by ECCELES (ibt files) and provide a simple API to interact with the data stored with them. At its core, pyibt provides an easy access to ibt data to facilitate custom analysis in Python. However, pyibt also includes a set of native methods to quickly and easily plot and analyze ephys data. Please see the examples below to learn how to get started with pyibt.Loading datafrompyibt.read_ibtimportRead_IBTibt=Read_IBT('demo.ibt')Accessing file informationprint('ibt file name:',ibt.name)print('Number of sweeps:',len(ibt.sweeps))ibt file name: demo
Number of sweeps: 28Accessing sweep datasweep=ibt.sweeps[0]print('Recording mode:',sweep.rec_mode)print('Sweep data:',sweep.data)print('Recording mode:',sweep.y_label)print('Sweep time:',sweep.time)print('Recording mode:',sweep.x_label)print('Sweep command:',sweep.command)Recording mode: current clamp
Sweep data: [-63.18666667 -62.98666667 -62.89333333 ... -62.98666667 -62.98666667 -63.18666667]
Recording mode: Membrane Potential (mV)
Sweep time: [0.0000e+00 2.0000e-05 4.0000e-05 ... 9.9994e-01 9.9996e-01 9.9998e-01]
Recording mode: Time (seconds)
Sweep command: [0. 0. 0. ... 0. 0. 0.]Quick plot functionsfig=plt.figure(figsize=(8,7))ax1=fig.add_subplot(211)ax1=ibt.plot_sweep(sweep_num=16,ax=ax1)ax2=fig.add_subplot(212)ax2=ibt.plot_command(sweep_num=16,ax=ax2)fig=plt.figure(figsize=(5,5))ax=ibt.plot_sweep_phase_plane(sweep_num=16)ax.set_xlim(-50,60)fig=plt.figure(figsize=(8,5))ax=ibt.plot_all_sweeps()Get Creativesweeps=ibt.sweeps[9:25]cm=plt.get_cmap("winter")colors=[cm(i/len(sweeps))fori,xinenumerate(sweeps)]plt.figure(figsize=(12,8))fori,sweepinenumerate(sweeps):num_pnts=int(0.5/sweep.dx)x=sweep.time[:num_pnts]+0.02*iy=sweep.data[:num_pnts]+10*iplt.plot(x,y,color=colors[i],alpha=0.5)plt.gca().axis('off')Automatic detection of action potentialscommand=4sweeps=ibt.sweeps[9:25]num_APs=[]current=[]forsweepinsweeps:num_APs.append(len(sweep.spike_times_during_command(command)))current.append(sweep.commands[4]['value'])fig=plt.figure(figsize=(8,5))plt.plot(current,num_APs,'-o',markersize=10)plt.ylabel('Number of Action potentials')plt.xlabel('Applied current (pA)')plt.savefig('example_plots/FI_curve.png')importnumpyasnpsweep=ibt.sweeps[25]spikes=sweep.spike_properties()spike_num=[xforxinrange(len(spikes))]spike_height=[spike['height']forspikeinspikes]spike_width=[spike['half_width']forspikeinspikes]spike_thresh=[spike['thresh']forspikeinspikes]spike_dVdt=[spike['peak_dVdt']forspikeinspikes]fig=plt.figure(figsize=(12,8))ax1=fig.add_subplot(231)ax1.set_ylabel('Membrane Potential (mV)')ax1.set_xlabel('Time (ms)')ax4=fig.add_subplot(234)ax4.set_ylabel('dVdt (V/s')ax4.set_xlabel('Membrane Potential (mV)')cm=plt.cm.magmacolors=[cm(i/len(sweeps))fori,xinenumerate(sweeps)]fori,spikeinenumerate(spikes):ax1.plot(spike['time']*1000,spike['Vm'],color=colors[i])dVdt=np.gradient(spike['Vm'],spike['time'])/1000ax4.plot(spike['Vm'],dVdt,color=colors[i])ax2=fig.add_subplot(232)ax2.set_ylabel('AP half width (ms)')ax2.set_xlabel('AP number')ax2.set_xticks(spike_num)ax2.plot(spike_num,spike_width,'-o',markersize=8,color='tab:blue')ax3=fig.add_subplot(233,sharex=ax2)ax3.set_ylabel('AP Height (mV)')ax3.set_xlabel('AP number')ax3.plot(spike_num,spike_height,'-o',markersize=8,color='tab:orange')ax2=fig.add_subplot(235,sharex=ax2)ax2.set_ylabel('Threshold (mV)')ax2.set_xlabel('AP number')ax2.plot(spike_num,spike_thresh,'-o',markersize=8,color='tab:green')ax3=fig.add_subplot(236,sharex=ax2)ax3.set_ylabel('dVdt (V/s)')ax3.set_xlabel('AP number')ax3.plot(spike_num,spike_dVdt,'-o',markersize=8,color='tab:red')Details of the ibt file structure can be foundherepyibt was inspired by thepyABF module written by Scott Hardenfor Axon Binary Format (ABF) files.AuthorPerry SprattPhD Candidate, Bender LabUniversity of California, San Franciscoperrywespratt@gmail.com