updated captions to new figures
This commit is contained in:
@@ -29,55 +29,57 @@ ampul_examples = (ampul_example, [], ampul_examples)
|
||||
|
||||
def plot_corr(ax, data, xcol, ycol, zcol, zmin, zmax, xpdfmax, cmap, color,
|
||||
si_thresh, example=[], split_example=[], examples=[]):
|
||||
xdata = data[xcol]
|
||||
ydata = data[ycol]
|
||||
ax.axhline(si_thresh, color='k', ls=':', lw=0.5)
|
||||
xmax = ax.get_xlim()[1]
|
||||
ymax = ax.get_ylim()[1]
|
||||
mask = (data[xcol] < xmax) & (data[ycol] < ymax)
|
||||
mask = (xdata < xmax) & (ydata < ymax)
|
||||
if 'stimindex' in data:
|
||||
for cell, run in example + split_example + examples:
|
||||
mask &= ~((data['cell'] == cell) & (data['stimindex'] == run))
|
||||
else: # simulations
|
||||
for cell, alpha in example + split_example + examples:
|
||||
mask &= ~((data['cell'] == cell) & (data['contrast'] == alpha))
|
||||
sc = ax.scatter(data[mask, xcol], data[mask, ycol], c=data[mask, zcol],
|
||||
sc = ax.scatter(xdata[mask], ydata[mask], c=data[mask, zcol],
|
||||
s=4, marker='o', linewidth=0, edgecolors='none',
|
||||
clip_on=False, cmap=cmap, vmin=zmin, vmax=zmax, zorder=20)
|
||||
elw = 0.3
|
||||
if 'stimindex' in data:
|
||||
for cell, run in example:
|
||||
mask = (data['cell'] == cell) & (data['stimindex'] == run)
|
||||
ax.scatter(data[mask, xcol], data[mask, ycol], c=data[mask, zcol],
|
||||
ax.scatter(xdata[mask], ydata[mask], c=data[mask, zcol],
|
||||
s=6, marker='^', linewidth=elw, edgecolors='black',
|
||||
clip_on=False, cmap=cmap, vmin=zmin, vmax=zmax,
|
||||
zorder=20)
|
||||
for cell, run in split_example:
|
||||
mask = (data['cell'] == cell) & (data['stimindex'] == run)
|
||||
ax.scatter(data[mask, xcol], data[mask, ycol], c=data[mask, zcol],
|
||||
ax.scatter(xdata[mask], ydata[mask], c=data[mask, zcol],
|
||||
s=6, marker='s', linewidth=elw, edgecolors='black',
|
||||
clip_on=False, cmap=cmap, vmin=zmin, vmax=zmax,
|
||||
zorder=20)
|
||||
for cell, run in examples:
|
||||
mask = (data['cell'] == cell) & (data['stimindex'] == run)
|
||||
ax.scatter(data[mask, xcol], data[mask, ycol], c=data[mask, zcol],
|
||||
ax.scatter(xdata[mask], ydata[mask], c=data[mask, zcol],
|
||||
s=6, marker='o', linewidth=elw, edgecolors='black',
|
||||
clip_on=False, cmap=cmap, vmin=zmin, vmax=zmax,
|
||||
zorder=20)
|
||||
else: # simulations
|
||||
for cell, alpha in example:
|
||||
mask = (data['cell'] == cell) & (data['contrast'] == alpha)
|
||||
ax.scatter(data[mask, xcol], data[mask, ycol], c=data[mask, zcol],
|
||||
ax.scatter(xdata[mask], ydata[mask], c=data[mask, zcol],
|
||||
s=6, marker='^', linewidth=elw, edgecolors='black',
|
||||
clip_on=False, cmap=cmap, vmin=zmin, vmax=zmax,
|
||||
zorder=20)
|
||||
for cell, alpha in split_example:
|
||||
mask = (data['cell'] == cell) & (data['contrast'] == alpha)
|
||||
ax.scatter(data[mask, xcol], data[mask, ycol], c=data[mask, zcol],
|
||||
ax.scatter(xdata[mask], ydata[mask], c=data[mask, zcol],
|
||||
s=6, marker='s', linewidth=elw, edgecolors='black',
|
||||
clip_on=False, cmap=cmap, vmin=zmin, vmax=zmax,
|
||||
zorder=20)
|
||||
for cell, alpha in examples:
|
||||
mask = (data['cell'] == cell) & (data['contrast'] == alpha)
|
||||
ax.scatter(data[mask, xcol], data[mask, ycol], c=data[mask, zcol],
|
||||
ax.scatter(xdata[mask], ydata[mask], c=data[mask, zcol],
|
||||
s=6, marker='o', linewidth=elw, edgecolors='black',
|
||||
clip_on=False, cmap=cmap, vmin=zmin, vmax=zmax,
|
||||
zorder=20)
|
||||
@@ -89,7 +91,7 @@ def plot_corr(ax, data, xcol, ycol, zcol, zmin, zmax, xpdfmax, cmap, color,
|
||||
cb.outline.set_color('none')
|
||||
cb.outline.set_linewidth(0)
|
||||
# pdf x-axis:
|
||||
kde = gaussian_kde(data[xcol], 0.02*xmax/np.std(data[xcol], ddof=1))
|
||||
kde = gaussian_kde(xdata, 0.02*xmax/np.std(xdata, ddof=1))
|
||||
xx = np.linspace(0, ax.get_xlim()[1], 400)
|
||||
pdf = kde(xx)
|
||||
xax = ax.inset_axes([0, 1.05, 1, 0.2])
|
||||
@@ -99,7 +101,7 @@ def plot_corr(ax, data, xcol, ycol, zcol, zmin, zmax, xpdfmax, cmap, color,
|
||||
xax.set_ylim(bottom=0)
|
||||
xax.set_ylim(0, xpdfmax)
|
||||
# pdf y-axis:
|
||||
kde = gaussian_kde(data[ycol], 0.02*ymax/np.std(data[ycol], ddof=1))
|
||||
kde = gaussian_kde(ydata, 0.02*ymax/np.std(ydata, ddof=1))
|
||||
xx = np.linspace(0, ax.get_ylim()[1], 400)
|
||||
pdf = kde(xx)
|
||||
yax = ax.inset_axes([1.05, 0, 0.2, 1])
|
||||
@@ -109,12 +111,12 @@ def plot_corr(ax, data, xcol, ycol, zcol, zmin, zmax, xpdfmax, cmap, color,
|
||||
yax.set_xlim(left=0)
|
||||
# threshold:
|
||||
if 'cvbase' in xcol:
|
||||
ax.text(xmax, 0.4*ymax, f'{100*np.sum(data[ycol] > si_thresh)/len(data):.0f}\\%',
|
||||
ax.text(xmax, 0.4*ymax, f'{100*np.sum(ydata > si_thresh)/len(data):.0f}\\%',
|
||||
ha='right', va='bottom', fontsize='small')
|
||||
ax.text(xmax, 0.3, f'{100*np.sum(data[ycol] < si_thresh)/len(data):.0f}\\%',
|
||||
ax.text(xmax, 0.3, f'{100*np.sum(ydata < si_thresh)/len(data):.0f}\\%',
|
||||
ha='right', va='center', fontsize='small')
|
||||
# statistics:
|
||||
r, p = pearsonr(data[xcol], data[ycol])
|
||||
r, p = pearsonr(xdata, ydata)
|
||||
ax.text(1, 0.9, f'$R={r:.2f}$ **', ha='right',
|
||||
transform=ax.transAxes, fontsize='small')
|
||||
#ax.text(1, 0.77, f'{significance_str(p)}', ha='right',
|
||||
@@ -128,16 +130,17 @@ def plot_corr(ax, data, xcol, ycol, zcol, zmin, zmax, xpdfmax, cmap, color,
|
||||
|
||||
def si_stats(title, data, sicol, si_thresh, nsegscol):
|
||||
print(title)
|
||||
sidata = data[sicol]
|
||||
cells = np.unique(data['cell'])
|
||||
ncells = len(cells)
|
||||
nrecs = len(data)
|
||||
print(f' cells: {ncells}')
|
||||
print(f' recordings: {nrecs}')
|
||||
print(f' SI threshold: {si_thresh:.1f}')
|
||||
hcells = np.unique(data[data(sicol) > si_thresh, 'cell'])
|
||||
hcells = np.unique(data[sidata > si_thresh, 'cell'])
|
||||
print(f' high SI cells: n={len(hcells):3d}, {100*len(hcells)/ncells:4.1f}%')
|
||||
print(f' high SI recordings: n={np.sum(data(sicol) > si_thresh):3d}, '
|
||||
f'{100*np.sum(data(sicol) > si_thresh)/nrecs:4.1f}%')
|
||||
print(f' high SI recordings: n={np.sum(sidata > si_thresh):3d}, '
|
||||
f'{100*np.sum(sidata > si_thresh)/nrecs:4.1f}%')
|
||||
nsegs = data[nsegscol]
|
||||
print(f' number of segments: {np.min(nsegs):4.0f} - {np.max(nsegs):4.0f}, median={np.median(nsegs):4.0f}, mean={np.mean(nsegs):4.0f}, std={np.std(nsegs):4.0f}')
|
||||
nrecs = []
|
||||
@@ -155,9 +158,10 @@ def si_stats(title, data, sicol, si_thresh, nsegscol):
|
||||
|
||||
def plot_cvbase_si_punit(ax, data, ycol, si_thresh, color):
|
||||
ax.set_xlabel('CV$_{\\rm base}$')
|
||||
ax.set_ylabel('SI($r$)')
|
||||
ax.set_xlim(0, 1.5)
|
||||
ax.set_ylim(0, 7.2)
|
||||
ax.set_xticks_delta(0.5)
|
||||
ax.set_ylabel('SI($r$)')
|
||||
ax.set_ylim(0, 6.5)
|
||||
ax.set_yticks_delta(2)
|
||||
examples = punit_examples if 'stimindex' in data else model_examples
|
||||
cax = plot_corr(ax, data, 'cvbase', ycol, 'respmod2', 0, 250, 3,
|
||||
@@ -167,10 +171,10 @@ def plot_cvbase_si_punit(ax, data, ycol, si_thresh, color):
|
||||
|
||||
def plot_cvstim_si_punit(ax, data, ycol, si_thresh, color):
|
||||
ax.set_xlabel('CV$_{\\rm stim}$')
|
||||
ax.set_ylabel('SI($r$)')
|
||||
ax.set_xlim(0, 1.6)
|
||||
ax.set_ylim(0, 7.2)
|
||||
ax.set_xticks_delta(0.5)
|
||||
ax.set_ylabel('SI($r$)')
|
||||
ax.set_ylim(0, 6.5)
|
||||
ax.set_yticks_delta(2)
|
||||
examples = punit_examples if 'stimindex' in data else model_examples
|
||||
#cax = plot_corr(ax, data, 'cvstim', ycol, 'respmod2', 0, 250, 2,
|
||||
@@ -189,9 +193,10 @@ def plot_cvstim_si_punit(ax, data, ycol, si_thresh, color):
|
||||
|
||||
def plot_rmod_si_punit(ax, data, ycol, si_thresh, color):
|
||||
ax.set_xlabel('Response modulation', 'Hz')
|
||||
ax.set_ylabel('SI($r$)')
|
||||
ax.set_xlim(0, 250)
|
||||
ax.set_ylim(0, 7.2)
|
||||
ax.set_xticks_delta(100)
|
||||
ax.set_ylabel('SI($r$)')
|
||||
ax.set_ylim(0, 6.5)
|
||||
ax.set_yticks_delta(2)
|
||||
examples = punit_examples if 'stimindex' in data else model_examples
|
||||
cax = plot_corr(ax, data, 'respmod2', ycol, 'cvbase', 0, 1.5, 0.016,
|
||||
@@ -201,11 +206,11 @@ def plot_rmod_si_punit(ax, data, ycol, si_thresh, color):
|
||||
|
||||
def plot_cvbase_si_ampul(ax, data, ycol, si_thresh, color):
|
||||
ax.set_xlabel('CV$_{\\rm base}$')
|
||||
ax.set_ylabel('SI($r$)')
|
||||
ax.set_xlim(0, 0.2)
|
||||
ax.set_ylim(0, 15)
|
||||
ax.set_xticks_delta(0.1)
|
||||
ax.set_yticks_delta(5)
|
||||
ax.set_ylabel('SI($r$)')
|
||||
ax.set_ylim(0, 10)
|
||||
ax.set_yticks_delta(2)
|
||||
cax = plot_corr(ax, data, 'cvbase', ycol, 'respmod2', 0, 80, 20,
|
||||
'coolwarm', color, si_thresh, *ampul_examples)
|
||||
cax.set_ylabel('Response mod.', 'Hz')
|
||||
@@ -213,11 +218,11 @@ def plot_cvbase_si_ampul(ax, data, ycol, si_thresh, color):
|
||||
|
||||
def plot_cvstim_si_ampul(ax, data, ycol, si_thresh, color):
|
||||
ax.set_xlabel('CV$_{\\rm stim}$')
|
||||
ax.set_ylabel('SI($r$)')
|
||||
ax.set_xlim(0, 0.85)
|
||||
ax.set_ylim(0, 15)
|
||||
ax.set_xticks_delta(0.2)
|
||||
ax.set_yticks_delta(5)
|
||||
ax.set_ylabel('SI($r$)')
|
||||
ax.set_ylim(0, 10)
|
||||
ax.set_yticks_delta(2)
|
||||
#cax = plot_corr(ax, data, 'cvstim', ycol, 'respmod2', 0, 80, 6,
|
||||
# 'coolwarm', color, si_thresh, *ampul_examples)
|
||||
#cax.set_ylabel('Response mod.', 'Hz')
|
||||
@@ -233,11 +238,11 @@ def plot_cvstim_si_ampul(ax, data, ycol, si_thresh, color):
|
||||
|
||||
def plot_rmod_si_ampul(ax, data, ycol, si_thresh, color):
|
||||
ax.set_xlabel('Response modulation', 'Hz')
|
||||
ax.set_ylabel('SI($r$)')
|
||||
ax.set_xlim(0, 80)
|
||||
ax.set_ylim(0, 15)
|
||||
ax.set_xticks_delta(20)
|
||||
ax.set_yticks_delta(5)
|
||||
ax.set_ylabel('SI($r$)')
|
||||
ax.set_ylim(0, 10)
|
||||
ax.set_yticks_delta(2)
|
||||
cax = plot_corr(ax, data, 'respmod2', ycol, 'cvbase', 0, 0.2, 0.06,
|
||||
'coolwarm', color, si_thresh, *ampul_examples)
|
||||
cax.set_ylabel('CV$_{\\rm base}$')
|
||||
@@ -255,6 +260,7 @@ if __name__ == '__main__':
|
||||
ampul_data = TableData(data_path /
|
||||
'Apteronotus_leptorhynchus-Ampullary-data.csv',
|
||||
sep=';')
|
||||
|
||||
#si = ''
|
||||
si = '_nmax'
|
||||
si_thresh = 1.8
|
||||
|
||||
Reference in New Issue
Block a user