added correlation with baseline rate
This commit is contained in:
@@ -117,12 +117,12 @@ def plot_corr(ax, data, xcol, ycol, zcol, zmin, zmax, xpdfmax, cmap, color,
|
||||
ha='right', va='center', fontsize='small')
|
||||
# statistics:
|
||||
r, p = pearsonr(xdata, ydata)
|
||||
ax.text(1, 0.9, f'$R={r:.2f}$ **', ha='right',
|
||||
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',
|
||||
transform=ax.transAxes, fontsize='small')
|
||||
#ax.text(1, 0.77, f'{significance_str(p)}', ha='right',
|
||||
# transform=ax.transAxes, fontsize='small')
|
||||
if 'cvbase' in xcol:
|
||||
ax.text(1, 0.77, f'$n={data.rows()}$', ha='right',
|
||||
ax.text(1, 0.64, f'$n={data.rows()}$', ha='right',
|
||||
transform=ax.transAxes, fontsize='small')
|
||||
print(f' correlation {xcol:<8s} - {ycol}: r={r:5.2f}, p={p:.2g}')
|
||||
return cax
|
||||
@@ -154,6 +154,15 @@ def si_stats(title, data, sicol, si_thresh, nsegscol):
|
||||
contrasts = 100*data['contrast']
|
||||
print(' contrasts: ', ' '.join([f'{c:.2g}%' for c in np.unique(contrasts)]))
|
||||
print(f' contrasts: {np.min(contrasts):.2g}% - {np.max(contrasts):.2g}%, median={np.median(contrasts):.2g}%, mean={np.mean(contrasts):.2g}%, std={np.std(contrasts):.2g}%')
|
||||
cols = ['cvbase', 'respmod2', 'ratebase', 'vsbase', 'serialcorr1', 'burstfrac', 'ratestim', 'cvstim']
|
||||
for i in range(len(cols)):
|
||||
for j in range(i + 1, len(cols)):
|
||||
xcol = cols[i]
|
||||
ycol = cols[j]
|
||||
if xcol not in data or ycol not in data:
|
||||
continue
|
||||
r, p = pearsonr(data[xcol], data[ycol])
|
||||
print(f' correlation {xcol:<11s} - {ycol:<11s}: r={r:5.2f}, p={p:.5f}')
|
||||
|
||||
|
||||
def plot_cvbase_si_punit(ax, data, ycol, si_thresh, color):
|
||||
@@ -204,6 +213,19 @@ def plot_rmod_si_punit(ax, data, ycol, si_thresh, color):
|
||||
cax.set_ylabel('CV$_{\\rm base}$')
|
||||
|
||||
|
||||
def plot_rate_si_punit(ax, data, ycol, si_thresh, color):
|
||||
ax.set_xlabel('Baseline rate $r$', 'Hz')
|
||||
ax.set_xlim(0, 700)
|
||||
ax.set_xticks_delta(200)
|
||||
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, 'ratebase', ycol, 'cvbase', 0, 1.5, 0.016,
|
||||
'coolwarm', color, si_thresh, *examples)
|
||||
cax.set_ylabel('CV$_{\\rm base}$')
|
||||
|
||||
|
||||
def plot_cvbase_si_ampul(ax, data, ycol, si_thresh, color):
|
||||
ax.set_xlabel('CV$_{\\rm base}$')
|
||||
ax.set_xlim(0, 0.2)
|
||||
@@ -248,6 +270,19 @@ def plot_rmod_si_ampul(ax, data, ycol, si_thresh, color):
|
||||
cax.set_ylabel('CV$_{\\rm base}$')
|
||||
cax.set_yticks_delta(0.1)
|
||||
|
||||
|
||||
def plot_rate_si_ampul(ax, data, ycol, si_thresh, color):
|
||||
ax.set_xlabel('Baseline rate $r$', 'Hz')
|
||||
ax.set_xlim(50, 200)
|
||||
ax.set_xticks_delta(50)
|
||||
ax.set_ylabel('SI($r$)')
|
||||
ax.set_ylim(0, 10)
|
||||
ax.set_yticks_delta(2)
|
||||
cax = plot_corr(ax, data, 'ratebase', ycol, 'cvbase', 0, 0.2, 0.06,
|
||||
'coolwarm', color, si_thresh, *ampul_examples)
|
||||
cax.set_ylabel('CV$_{\\rm base}$')
|
||||
cax.set_yticks_delta(0.1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
punit_model = TableData(data_path /
|
||||
@@ -304,8 +339,10 @@ if __name__ == '__main__':
|
||||
s.model_color2)
|
||||
plot_rmod_si_punit(axs[0, 1], punit_model, 'dsinorm100', si_thresh,
|
||||
s.model_color2)
|
||||
plot_cvstim_si_punit(axs[0, 2], punit_model, 'dsinorm100', si_thresh,
|
||||
s.model_color2)
|
||||
#plot_cvstim_si_punit(axs[0, 2], punit_model, 'dsinorm100', si_thresh,
|
||||
# s.model_color2)
|
||||
plot_rate_si_punit(axs[0, 2], punit_model, 'dsinorm100', si_thresh,
|
||||
s.model_color2)
|
||||
print()
|
||||
|
||||
si_stats('P-unit data:', punit_data, 'sinorm' + si, si_thresh,
|
||||
@@ -316,8 +353,10 @@ if __name__ == '__main__':
|
||||
s.punit_color2)
|
||||
plot_rmod_si_punit(axs[1, 1], punit_data, 'sinorm' + si, si_thresh,
|
||||
s.punit_color2)
|
||||
plot_cvstim_si_punit(axs[1, 2], punit_data, 'sinorm' + si, si_thresh,
|
||||
s.punit_color2)
|
||||
#plot_cvstim_si_punit(axs[1, 2], punit_data, 'sinorm' + si, si_thresh,
|
||||
# s.punit_color2)
|
||||
plot_rate_si_punit(axs[1, 2], punit_data, 'sinorm' + si, si_thresh,
|
||||
s.punit_color2)
|
||||
print()
|
||||
|
||||
si_stats('Ampullary data:', ampul_data, 'sinorm' + si, si_thresh,
|
||||
@@ -328,8 +367,10 @@ if __name__ == '__main__':
|
||||
s.ampul_color2)
|
||||
plot_rmod_si_ampul(axs[2, 1], ampul_data, 'sinorm' + si, si_thresh,
|
||||
s.ampul_color2)
|
||||
plot_cvstim_si_ampul(axs[2, 2], ampul_data, 'sinorm' + si, si_thresh,
|
||||
s.ampul_color2)
|
||||
#plot_cvstim_si_ampul(axs[2, 2], ampul_data, 'sinorm' + si, si_thresh,
|
||||
# s.ampul_color2)
|
||||
plot_rate_si_ampul(axs[2, 2], ampul_data, 'sinorm' + si, si_thresh,
|
||||
s.ampul_color2)
|
||||
print()
|
||||
|
||||
fig.common_xticks(axs[:2, 0])
|
||||
|
||||
Reference in New Issue
Block a user