-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwaveform_stats.py
57 lines (45 loc) · 2.26 KB
/
waveform_stats.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
This script generates Figure S1C-D in the manuscript
"Graded Remapping of Hippocampal Ensembles under Sensory Conflicts" written by
D. Fetterhoff, A. Sobolev & C. Leibold.
All analysis code was written by D. Fetterhoff
"""
import os
import pandas as pd
import numpy as np
import matplotlib.pyplot as pl
import seaborn as sns
# Load data from this folder
hdf5Dir = r'/home/fetterhoff/Documents/graded_remapping_data/Graded_Remapping/'
combinedResultDir = hdf5Dir+'waveform_stats/' # Save in subdirectory
if not os.path.exists(combinedResultDir):
os.makedirs(combinedResultDir)
wavedf = pd.read_csv(hdf5Dir+'allwavecombined_final.csv')
wavedf['neuron_type'] = 0
fil=(wavedf.spike_ratio < 1.5)
wavedf.loc[fil, 'neuron_type'] = 'INT'
fil=(wavedf.spike_ratio >= 1.5)
wavedf.loc[fil,'neuron_type'] = 'PC'
pl.rcParams.update({'font.size': 6, 'xtick.labelsize':6, 'ytick.labelsize':6, 'legend.fontsize':6, 'axes.facecolor':'white', 'lines.linewidth': 0.75, 'lines.markersize': 1.0, 'axes.labelsize': 6, 'figure.titlesize' : 6, 'axes.titlesize' : 'medium'})
#%% scatter spike ratio vs firing rate
ajp = sns.jointplot(x=wavedf.spike_ratio[wavedf.spike_ratio < 10],y=np.log10(wavedf.mfr[wavedf.spike_ratio < 10]),alpha=0.25,joint_kws={"s": 3}, height=2.2)
yl1, yl2 = ajp.ax_joint.get_ylim()
ajp.ax_joint.fill_between([0,1.5],yl1, yl2, facecolor='C1',alpha=0.2)
ajp.ax_joint.fill_between([1.5,10],np.log10(5.0), yl2, facecolor='C1',alpha=0.2)
ajp.ax_joint.set_ylim(yl1, yl2)
ajp.ax_joint.set_xlabel('Spike Ratio')
ajp.ax_joint.set_ylabel('Log of Mean Firing Rate (Hz)')
ajp.ax_marg_x.axvline(1.5,color='C1',alpha=0.5)
ajp.ax_joint.set_ylim(yl1, yl2)
ajp.savefig(combinedResultDir+'fig_S1C_mfr_spike_ratio.pdf',format='pdf', dpi=300, bbox_inches = 'tight', pad_inches = 0.05)
pl.close()
perc_lost = (wavedf.spike_ratio > 10).sum() / float(len(wavedf)) *100
print('{}% of neurons not shown (SR > 10)'.format(perc_lost))
#%% Box plot of spike width by neuron group (PC vs INT)
ax = sns.catplot(x='neuron_type', y='spike_width_ms', kind='boxen', data=wavedf, height=2.2)
ax.set_ylabels('Spike Width (ms)')
ax.set_xlabels('Neuron Type')
ax.savefig(combinedResultDir+'fig_S1D_spike_width.pdf',format='pdf', dpi=300, bbox_inches = 'tight', pad_inches = 0.05)
pl.close()