dada
This commit is contained in:
parent
e2c284ea76
commit
96cb4b607c
@ -154,7 +154,6 @@ def get_temperature(folder_path):
|
||||
temp_t = np.array(temp_t)
|
||||
temp = np.array(temp)
|
||||
|
||||
|
||||
if type(temp[-1]).__name__== 'str':
|
||||
temp = np.array(temp[:-1], dtype=float)
|
||||
temp_t = np.array(temp_t[:-1], dtype=int)
|
||||
@ -166,8 +165,8 @@ def main(base_path=None):
|
||||
female_color, male_color = '#e74c3c', '#3498db'
|
||||
Wc, Lc = 'darkgreen', '#3673A4'
|
||||
|
||||
if not os.path.exists(os.path.join(os.path.split(__file__)[0], 'figures')):
|
||||
os.makedirs(os.path.join(os.path.split(__file__)[0], 'figures'))
|
||||
if not os.path.exists(os.path.join(os.path.split(__file__)[0], 'figures', 'example_trials')):
|
||||
os.makedirs(os.path.join(os.path.split(__file__)[0], 'figures', 'example_trials'))
|
||||
|
||||
# trials_meta = pd.read_csv('order_meta.csv')
|
||||
trials_meta = pd.read_csv(os.path.join(base_path, 'order_meta.csv'))
|
||||
@ -385,7 +384,7 @@ def main(base_path=None):
|
||||
|
||||
fig.suptitle(f'{recording}')
|
||||
|
||||
plt.savefig(os.path.join(os.path.split(__file__)[0], 'figures', f'{recording}.png'), dpi=300)
|
||||
plt.savefig(os.path.join(os.path.split(__file__)[0], 'figures', 'example_trials', f'{recording}.png'), dpi=300)
|
||||
# plt.savefig(os.path.join(os.path.join(os.path.split(__file__)[0], 'figures', f'{recording}.png')), dpi=300)
|
||||
plt.close()
|
||||
|
||||
|
@ -64,7 +64,7 @@ def iei_analysis(event_times, win_sex, lose_sex, kernal_w, title=''):
|
||||
plt.setp(ax[0].get_xticklabels(), visible=False)
|
||||
plt.setp(ax[1].get_xticklabels(), visible=False)
|
||||
|
||||
plt.savefig(os.path.join(os.path.split(__file__)[0], 'figures', f'{title}_iei.png'), dpi=300)
|
||||
plt.savefig(os.path.join(os.path.split(__file__)[0], 'figures', 'event_meta', f'{title}_iei.png'), dpi=300)
|
||||
plt.close()
|
||||
# plt.show()
|
||||
|
||||
@ -154,7 +154,7 @@ def relative_rate_progression(all_event_t, title=''):
|
||||
ax.set_xlim(0, 3)
|
||||
ax.set_ylim(0, 5)
|
||||
|
||||
plt.savefig(os.path.join(os.path.split(__file__)[0], 'figures', f'{title}_progression.png'), dpi=300)
|
||||
plt.savefig(os.path.join(os.path.split(__file__)[0], 'figures', 'event_meta', f'{title}_progression.png'), dpi=300)
|
||||
plt.close()
|
||||
# plt.show()
|
||||
|
||||
@ -163,7 +163,7 @@ def relative_rate_progression(all_event_t, title=''):
|
||||
|
||||
r, p = scp.pearsonr(x, y)
|
||||
|
||||
print(f'{title}: pearson-r={r:.2f} p={p:.3f}')
|
||||
print(f'Progression {title}: pearson-r={r:.2f} p={p:.3f}')
|
||||
|
||||
|
||||
|
||||
@ -171,6 +171,14 @@ def relative_rate_progression(all_event_t, title=''):
|
||||
|
||||
def main(base_path):
|
||||
# ToDo: for chirp and rise analysis different datasets!!!
|
||||
if not os.path.exists(os.path.join(os.path.split(__file__)[0], 'figures', 'event_meta')):
|
||||
os.makedirs(os.path.join(os.path.split(__file__)[0], 'figures', 'event_meta'))
|
||||
|
||||
if not os.path.exists(os.path.join(os.path.split(__file__)[0], 'figures', 'event_time_corr')):
|
||||
os.makedirs(os.path.join(os.path.split(__file__)[0], 'figures', 'event_time_corr'))
|
||||
|
||||
|
||||
|
||||
trial_summary = pd.read_csv(os.path.join(base_path, 'trial_summary.csv'), index_col=0)
|
||||
chirp_notes = pd.read_csv(os.path.join(base_path, 'chirp_notes.csv'), index_col=0)
|
||||
trial_mask = chirp_notes['good'] == 1
|
||||
@ -269,13 +277,15 @@ def main(base_path):
|
||||
all_chase_event_mask = []
|
||||
all_end_chase_event_mask = []
|
||||
all_after_chase_event_mask = []
|
||||
all_around_countact_event_mask = []
|
||||
all_before_contact_event_mask = []
|
||||
all_after_contact_event_mask = []
|
||||
|
||||
all_pre_chase_time = []
|
||||
all_chase_time = []
|
||||
all_end_chase_time = []
|
||||
all_after_chase_time = []
|
||||
all_around_countact_time = []
|
||||
all_before_contact_time = []
|
||||
all_after_contact_time = []
|
||||
|
||||
video_trial_win_sex = []
|
||||
video_trial_lose_sex = []
|
||||
@ -317,17 +327,23 @@ def main(base_path):
|
||||
all_end_chase_time.append(len(ag_on_t) * time_tol)
|
||||
all_after_chase_time.append(len(ag_on_t) * time_tol)
|
||||
|
||||
around_countact_event_mask = np.zeros_like(event_times)
|
||||
before_countact_event_mask = np.zeros_like(event_times)
|
||||
after_countact_event_mask = np.zeros_like(event_times)
|
||||
for ct in contact_t:
|
||||
around_countact_event_mask[(event_times >= ct-time_tol) & (event_times < ct+time_tol)] = 1
|
||||
all_around_countact_event_mask.append(around_countact_event_mask)
|
||||
all_around_countact_time.append(len(contact_t) * time_tol*2)
|
||||
before_countact_event_mask[(event_times >= ct-time_tol) & (event_times < ct)] = 1
|
||||
after_countact_event_mask[(event_times >= ct) & (event_times < ct+time_tol)] = 1
|
||||
all_before_contact_event_mask.append(before_countact_event_mask)
|
||||
all_after_contact_event_mask.append(after_countact_event_mask)
|
||||
|
||||
all_before_contact_time.append(len(contact_t) * time_tol)
|
||||
all_after_contact_time.append(len(contact_t) * time_tol)
|
||||
|
||||
all_pre_chase_time = np.array(all_pre_chase_time)
|
||||
all_chase_time = np.array(all_chase_time)
|
||||
all_end_chase_time = np.array(all_end_chase_time)
|
||||
all_after_chase_time = np.array(all_after_chase_time)
|
||||
all_around_countact_time = np.array(all_around_countact_time)
|
||||
all_before_contact_time = np.array(all_before_contact_time)
|
||||
all_after_contact_time = np.array(all_after_contact_time)
|
||||
|
||||
video_trial_win_sex = np.array(video_trial_win_sex)
|
||||
video_trial_lose_sex = np.array(video_trial_lose_sex)
|
||||
@ -336,19 +352,22 @@ def main(base_path):
|
||||
all_chase_time_ratio = all_chase_time / (3*60*60)
|
||||
all_end_chase_time_ratio = all_end_chase_time / (3*60*60)
|
||||
all_after_chase_time_ratio = all_after_chase_time / (3*60*60)
|
||||
all_around_countact_time_ratio = all_around_countact_time / (3*60*60)
|
||||
all_before_countact_time_ratio = all_before_contact_time / (3*60*60)
|
||||
all_after_countact_time_ratio = all_after_contact_time / (3*60*60)
|
||||
|
||||
all_pre_chase_event_ratio = np.array(list(map(lambda x: np.sum(x)/len(x), all_pre_chase_event_mask)))
|
||||
all_chase_event_ratio = np.array(list(map(lambda x: np.sum(x)/len(x), all_chase_event_mask)))
|
||||
all_end_chase_event_ratio = np.array(list(map(lambda x: np.sum(x)/len(x), all_end_chase_event_mask)))
|
||||
all_after_chase_event_ratio = np.array(list(map(lambda x: np.sum(x)/len(x), all_after_chase_event_mask)))
|
||||
all_around_countact_event_ratio = np.array(list(map(lambda x: np.sum(x)/len(x), all_around_countact_event_mask)))
|
||||
all_before_countact_event_ratio = np.array(list(map(lambda x: np.sum(x)/len(x), all_before_contact_event_mask)))
|
||||
all_after_countact_event_ratio = np.array(list(map(lambda x: np.sum(x)/len(x), all_after_contact_event_mask)))
|
||||
|
||||
for x, y, name in [[all_pre_chase_event_ratio, all_pre_chase_time_ratio, 'pre chase'],
|
||||
[all_chase_event_ratio, all_chase_time_ratio, 'while chase'],
|
||||
[all_end_chase_event_ratio, all_end_chase_time_ratio, 'end chase'],
|
||||
[all_after_chase_event_ratio, all_after_chase_time_ratio, 'after chase'],
|
||||
[all_around_countact_event_ratio, all_around_countact_time_ratio, 'aroung contact']]:
|
||||
[all_before_countact_event_ratio, all_before_countact_time_ratio, 'pre contact'],
|
||||
[all_after_countact_event_ratio, all_after_countact_time_ratio, 'post contact']]:
|
||||
t, p = scp.ttest_rel(x, y)
|
||||
print(f'{event_name} {name}: t={t:.2f} p={p:.3f}')
|
||||
|
||||
@ -362,7 +381,8 @@ def main(base_path):
|
||||
all_chase_event_ratio/all_chase_time_ratio,
|
||||
all_end_chase_event_ratio/all_end_chase_time_ratio,
|
||||
all_after_chase_event_ratio/all_after_chase_time_ratio,
|
||||
all_around_countact_event_ratio/all_around_countact_time_ratio], positions=np.arange(5), sym='', zorder=2)
|
||||
all_before_countact_event_ratio/all_before_countact_time_ratio,
|
||||
all_after_countact_event_ratio/all_after_countact_time_ratio], positions=np.arange(6), sym='', zorder=2)
|
||||
|
||||
ylim = list(ax.get_ylim())
|
||||
ylim[0] = -.1 if ylim[0] < -.1 else ylim[0]
|
||||
@ -392,24 +412,27 @@ def main(base_path):
|
||||
values = np.array(all_after_chase_event_ratio/all_after_chase_time_ratio)[(video_trial_win_sex == sex_w) & (video_trial_lose_sex == sex_l)]
|
||||
ax.plot(np.ones_like(values) * 3, values, marker=marker, linestyle='None', color=c, mec=mec, markersize=8, zorder=1)
|
||||
|
||||
values = np.array(all_around_countact_event_ratio/all_around_countact_time_ratio)[(video_trial_win_sex == sex_w) & (video_trial_lose_sex == sex_l)]
|
||||
values = np.array(all_before_countact_event_ratio/all_before_countact_time_ratio)[(video_trial_win_sex == sex_w) & (video_trial_lose_sex == sex_l)]
|
||||
ax.plot(np.ones_like(values) * 4, values, marker=marker, linestyle='None', color=c, mec=mec, markersize=8, zorder=1)
|
||||
|
||||
values = np.array(all_after_countact_event_ratio/all_after_countact_time_ratio)[(video_trial_win_sex == sex_w) & (video_trial_lose_sex == sex_l)]
|
||||
ax.plot(np.ones_like(values) * 5, values, marker=marker, linestyle='None', color=c, mec=mec, markersize=8, zorder=1)
|
||||
|
||||
# ax.plot(np.ones_like(all_pre_chase_event_ratio) * 0, all_pre_chase_event_ratio/all_pre_chase_time_ratio, 'ok')
|
||||
# ax.plot(np.ones_like(all_chase_event_ratio) * 1, all_chase_event_ratio/all_chase_time_ratio, 'ok')
|
||||
# ax.plot(np.ones_like(all_end_chase_event_ratio) * 2, all_end_chase_event_ratio/all_end_chase_time_ratio, 'ok')
|
||||
# ax.plot(np.ones_like(all_after_chase_event_ratio) * 3, all_after_chase_event_ratio/all_after_chase_time_ratio, 'ok')
|
||||
|
||||
# ax.plot(np.ones_like(all_around_countact_event_ratio) * 4, all_around_countact_event_ratio/all_around_countact_time_ratio, 'ok')
|
||||
# ax.plot(np.ones_like(all_before_countact_event_ratio) * 4, all_before_countact_event_ratio/all_before_countact_time_ratio, 'ok')
|
||||
##############################################################################
|
||||
|
||||
ax.plot(np.arange(7)-1, np.ones(7), linestyle='dotted', lw=2, color='k')
|
||||
ax.set_xlim(-0.5, 4.5)
|
||||
ax.set_xlim(-0.5, 5.5)
|
||||
ax.set_ylim(ylim[0], ylim[1])
|
||||
|
||||
ax.set_ylabel(r'rel. count$_{event}$ / rel. time$_{event}$', fontsize=12)
|
||||
ax.set_xticks(np.arange(5))
|
||||
ax.set_xticklabels([r'chase$_{before}$', r'chasing', r'chase$_{end}$', r'chase$_{after}$', 'contact'], rotation=45)
|
||||
ax.set_xticks(np.arange(6))
|
||||
ax.set_xticklabels([r'chase$_{before}$', r'chasing', r'chase$_{end}$', r'chase$_{after}$', 'contact$_{before}$', 'contact$_{after}$'], rotation=45)
|
||||
ax.tick_params(labelsize=10)
|
||||
# ax.set_title(event_name)
|
||||
fig.suptitle(f'{event_name}: n={len(np.hstack(all_event_t))}')
|
||||
@ -420,30 +443,32 @@ def main(base_path):
|
||||
flat_chase_event_mask = np.hstack(all_chase_event_mask)
|
||||
flat_end_chase_event_mask = np.hstack(all_end_chase_event_mask)
|
||||
flat_after_chase_event_mask = np.hstack(all_after_chase_event_mask)
|
||||
flat_around_countact_event_mask = np.hstack(all_around_countact_event_mask)
|
||||
flat_before_countact_event_mask = np.hstack(all_before_contact_event_mask)
|
||||
flat_after_countact_event_mask = np.hstack(all_after_contact_event_mask)
|
||||
|
||||
flat_pre_chase_event_mask[flat_around_countact_event_mask == 1] = 0
|
||||
flat_chase_event_mask[flat_around_countact_event_mask == 1] = 0
|
||||
flat_end_chase_event_mask[flat_around_countact_event_mask == 1] = 0
|
||||
flat_after_chase_event_mask[flat_around_countact_event_mask == 1] = 0
|
||||
flat_pre_chase_event_mask[(flat_before_countact_event_mask == 1) | (flat_after_countact_event_mask == 1)] = 0
|
||||
flat_chase_event_mask[(flat_before_countact_event_mask == 1) | (flat_after_countact_event_mask == 1)] = 0
|
||||
flat_end_chase_event_mask[(flat_before_countact_event_mask == 1) | (flat_after_countact_event_mask == 1)] = 0
|
||||
flat_after_chase_event_mask[(flat_before_countact_event_mask == 1) | (flat_after_countact_event_mask == 1)] = 0
|
||||
|
||||
event_context_values = [np.sum(flat_pre_chase_event_mask) / len(flat_pre_chase_event_mask),
|
||||
np.sum(flat_chase_event_mask) / len(flat_chase_event_mask),
|
||||
np.sum(flat_end_chase_event_mask) / len(flat_end_chase_event_mask),
|
||||
np.sum(flat_after_chase_event_mask) / len(flat_after_chase_event_mask),
|
||||
np.sum(flat_around_countact_event_mask) / len(flat_around_countact_event_mask)]
|
||||
np.sum(flat_before_countact_event_mask) / len(flat_before_countact_event_mask),
|
||||
np.sum(flat_after_countact_event_mask) / len(flat_after_countact_event_mask)]
|
||||
|
||||
event_context_values.append(1 - np.sum(event_context_values))
|
||||
|
||||
time_context_values = [np.sum(all_pre_chase_time), np.sum(all_chase_time), np.sum(all_end_chase_time),
|
||||
np.sum(all_after_chase_time), np.sum(all_around_countact_time)]
|
||||
np.sum(all_after_chase_time), np.sum(all_before_contact_time), np.sum(all_after_contact_time)]
|
||||
|
||||
time_context_values.append(len(all_pre_chase_time) * 3*60*60 - np.sum(time_context_values))
|
||||
time_context_values /= np.sum(time_context_values)
|
||||
|
||||
# fig, ax = plt.subplots(figsize=(12/2.54,12/2.54))
|
||||
size = 0.3
|
||||
outer_colors = ['tab:red', 'tab:orange', 'yellow', 'tab:green', 'k', 'tab:grey']
|
||||
outer_colors = ['tab:red', 'tab:orange', 'yellow', 'tab:green', 'k','tab:brown', 'tab:grey']
|
||||
ax_pie.pie(event_context_values, radius=1, colors=outer_colors,
|
||||
wedgeprops=dict(width=size, edgecolor='w'), startangle=90, center=(0, 1))
|
||||
ax_pie.pie(time_context_values, radius=1-size, colors=outer_colors,
|
||||
@ -455,15 +480,17 @@ def main(base_path):
|
||||
Patch(facecolor='yellow', edgecolor='w', label='%.1f' % (event_context_values[2] * 100) + '%'),
|
||||
Patch(facecolor='tab:green', edgecolor='w', label='%.1f' % (event_context_values[3] * 100) + '%'),
|
||||
Patch(facecolor='k', edgecolor='w', label='%.1f' % (event_context_values[4] * 100) + '%'),
|
||||
Patch(facecolor='tab:brown', edgecolor='w', label='%.1f' % (event_context_values[5] * 100) + '%'),
|
||||
Patch(facecolor='tab:red', alpha=0.6, edgecolor='w', label='%.1f' % (time_context_values[0] * 100) + '%'),
|
||||
Patch(facecolor='tab:orange', alpha=0.6, edgecolor='w', label='%.1f' % (time_context_values[1] * 100) + '%'),
|
||||
Patch(facecolor='yellow', alpha=0.6, edgecolor='w', label='%.1f' % (time_context_values[2] * 100) + '%'),
|
||||
Patch(facecolor='tab:green', alpha=0.6, edgecolor='w', label='%.1f' % (time_context_values[3] * 100) + '%'),
|
||||
Patch(facecolor='k', alpha=0.6, edgecolor='w', label='%.1f' % (time_context_values[4] * 100) + '%')]
|
||||
Patch(facecolor='k', alpha=0.6, edgecolor='w', label='%.1f' % (time_context_values[4] * 100) + '%'),
|
||||
Patch(facecolor='tab:brown', alpha=0.6, edgecolor='w', label='%.1f' % (time_context_values[5] * 100) + '%')]
|
||||
|
||||
ax_pie.legend(handles=legend_elements, loc='lower right', ncol=2, bbox_to_anchor=(1.15, -0.25), frameon=False, fontsize=9)
|
||||
|
||||
plt.savefig(os.path.join(os.path.split(__file__)[0], 'figures', f'{event_name}_categories.png'), dpi=300)
|
||||
plt.savefig(os.path.join(os.path.split(__file__)[0], 'figures', 'event_time_corr', f'{event_name}_categories.png'), dpi=300)
|
||||
plt.close()
|
||||
# plt.show()
|
||||
|
||||
|
@ -241,7 +241,9 @@ def single_kde(event_dt, conv_t, kernal_w = 1, kernal_h = 0.2):
|
||||
return cp.asnumpy(single_kdes)
|
||||
|
||||
def main(base_path):
|
||||
# ToDo: for chirp and rise analysis different datasets!!!
|
||||
if not os.path.exists(os.path.join(os.path.split(__file__)[0], 'figures', 'event_time_corr')):
|
||||
os.makedirs(os.path.join(os.path.split(__file__)[0], 'figures', 'event_time_corr'))
|
||||
|
||||
trial_summary = pd.read_csv('trial_summary.csv', index_col=0)
|
||||
chirp_notes = pd.read_csv(os.path.join(base_path, 'chirp_notes.csv'), index_col=0)
|
||||
# trial_summary = trial_summary[chirp_notes['good'] == 1]
|
||||
@ -381,8 +383,6 @@ def main(base_path):
|
||||
[win_rises_centered_on_contact_t, win_rises_count, r'rise$_{win}$ on contact'],
|
||||
[win_rises_centered_on_lose_chirps, win_rises_count, r'rise$_{win}$ on chirp$_{lose}$']]:
|
||||
|
||||
if not os.path.exists(os.path.join(os.path.split(__file__)[0], 'figures')):
|
||||
os.makedirs(os.path.join(os.path.split(__file__)[0], 'figures'))
|
||||
save_str = title.replace('$', '').replace('{', '').replace('}', '').replace(' ', '_')
|
||||
|
||||
###########################################################################################################
|
||||
@ -451,7 +451,7 @@ def main(base_path):
|
||||
ax[2].set_ylabel('event rate [Hz]', fontsize=12)
|
||||
fig.suptitle(title)
|
||||
|
||||
plt.savefig(os.path.join(os.path.split(__file__)[0], 'figures', f'{save_str}_by_sexes.png'), dpi=300)
|
||||
plt.savefig(os.path.join(os.path.split(__file__)[0], 'figures', 'event_time_corr', f'{save_str}_by_sexes.png'), dpi=300)
|
||||
plt.close()
|
||||
|
||||
###########################################################################################################
|
||||
@ -490,7 +490,7 @@ def main(base_path):
|
||||
ax.set_xlim(-max_dt, max_dt)
|
||||
ax.tick_params(labelsize=10)
|
||||
|
||||
plt.savefig(os.path.join(os.path.split(__file__)[0], 'figures', f'{save_str}.png'), dpi=300)
|
||||
plt.savefig(os.path.join(os.path.split(__file__)[0], 'figures', 'event_time_corr', f'{save_str}.png'), dpi=300)
|
||||
plt.close()
|
||||
|
||||
|
||||
|
@ -136,31 +136,32 @@ def plot_meta_correlation(trial_summary, trial_mask, key1, key2, key1_name, key2
|
||||
if True:
|
||||
r_coll = []
|
||||
p_coll = []
|
||||
print(f'\n{key1_name} - {key2_name}')
|
||||
# print(f'\n{key1_name} - {key2_name}')
|
||||
for win_lose_key, sex in itertools.product(['sex_win', 'sex_lose'], ['m', 'f']):
|
||||
print(win_lose_key, sex)
|
||||
k1 = trial_summary[key1][(trial_summary[win_lose_key] == sex) & (trial_summary["draw"] == 0) & trial_mask].to_numpy()
|
||||
k2 = trial_summary[key2][(trial_summary[win_lose_key] == sex) & (trial_summary["draw"] == 0) & trial_mask].to_numpy()
|
||||
mask = np.ones_like(k1, dtype=bool)
|
||||
mask[np.isnan(k1) | np.isnan(k2)] = 0
|
||||
r, p = scp.spearmanr(k1[mask], k2[mask])
|
||||
r, p = scp.pearsonr(k1[mask], k2[mask])
|
||||
r_coll.append(r)
|
||||
p_coll.append(p)
|
||||
print(f'{win_lose_key}: {sex} --> spearman-r={r:.2f} p={p:.3f}')
|
||||
# print(f'{win_lose_key}: {sex} --> spearman-r={r:.2f} p={p:.3f}')
|
||||
k1 = trial_summary[key1][(trial_summary["draw"] == 0) & trial_mask].to_numpy()
|
||||
k2 = trial_summary[key2][(trial_summary["draw"] == 0) & trial_mask].to_numpy()
|
||||
mask = np.ones_like(k1, dtype=bool)
|
||||
mask[np.isnan(k1) | np.isnan(k2)] = 0
|
||||
r, p = scp.spearmanr(k1[mask], k2[mask])
|
||||
r, p = scp.pearsonr(k1[mask], k2[mask])
|
||||
|
||||
ax[0].text(1, 1, f'male win: spaerman-r = {r_coll[0]:.2f} p={p_coll[0]:.3f}\n'
|
||||
f'female win: spaerman-r = {r_coll[1]:.2f} p={p_coll[1]:.3f}', ha='right', va='bottom', transform = ax[0].transAxes)
|
||||
ax[1].text(1, 1, f'male lose: spaerman-r = {r_coll[2]:.2f} p={p_coll[2]:.3f}\n'
|
||||
f'female lose: spaerman-r = {r_coll[3]:.2f} p={p_coll[3]:.3f}', ha='right', va='bottom', transform = ax[1].transAxes)
|
||||
ax[1].text(1, -.1, f'all: spaerman-r = {r:.2f} p={p:.3f}', ha='right', va='top', transform = ax[1].transAxes)
|
||||
print(f'all --> spearman-r={r:.2f} p={p:.3f}')
|
||||
ax[0].text(1, 1, f'male win: pearson-r = {r_coll[0]:.2f} p={p_coll[0]:.3f}\n'
|
||||
f'female win: pearson-r = {r_coll[1]:.2f} p={p_coll[1]:.3f}', ha='right', va='bottom', transform = ax[0].transAxes)
|
||||
ax[1].text(1, 1, f'male lose: pearson-r = {r_coll[2]:.2f} p={p_coll[2]:.3f}\n'
|
||||
f'female lose: pearson-r = {r_coll[3]:.2f} p={p_coll[3]:.3f}', ha='right', va='bottom', transform = ax[1].transAxes)
|
||||
ax[1].text(1, -.1, f'all: pearson-r = {r:.2f} p={p:.3f}', ha='right', va='top', transform = ax[1].transAxes)
|
||||
# print(f'all --> spearman-r={r:.2f} p={p:.3f}')
|
||||
|
||||
plt.setp(ax[0].get_xticklabels(), visible=False)
|
||||
plt.savefig(os.path.join(os.path.split(__file__)[0], 'figures', f'correlations_{key1}_{key2}.png'), dpi=300)
|
||||
plt.savefig(os.path.join(os.path.split(__file__)[0], 'figures', 'meta_correlations', f'corr_{key1}_{key2}.png'), dpi=300)
|
||||
plt.close()
|
||||
|
||||
def plot_beh_count_vs_dmeta(trial_summary, trial_mask=None,
|
||||
@ -223,7 +224,7 @@ def plot_beh_count_vs_dmeta(trial_summary, trial_mask=None,
|
||||
plt.setp(ax[3].get_yticklabels(), visible=False)
|
||||
plt.tick_params(labelsize=10)
|
||||
|
||||
plt.savefig(os.path.join(os.path.split(__file__)[0], 'figures', f'{save_str}.png'), dpi=300)
|
||||
plt.savefig(os.path.join(os.path.split(__file__)[0], 'figures', 'meta_correlations', f'{save_str}.png'), dpi=300)
|
||||
plt.close()
|
||||
|
||||
|
||||
@ -288,7 +289,9 @@ def plot_beh_conut_vs_experience(trial_summary, trial_mask = None, beh_key_win='
|
||||
|
||||
|
||||
def main(base_path):
|
||||
# ToDo: for chirp and rise analysis different datasets!!!
|
||||
if not os.path.exists(os.path.join(os.path.split(__file__)[0], 'figures', 'meta_correlations')):
|
||||
os.makedirs(os.path.join(os.path.split(__file__)[0], 'figures', 'meta_correlations'))
|
||||
|
||||
# trial_summary = pd.read_csv(os.path.join(base_path, 'trial_summary.csv'), index_col=0)
|
||||
trial_summary = pd.read_csv(os.path.join(base_path, 'trial_summary.csv'), index_col=0)
|
||||
chirp_notes = pd.read_csv(os.path.join(base_path, 'chirp_notes.csv'), index_col=0)
|
||||
@ -301,14 +304,14 @@ def main(base_path):
|
||||
trial_summary['rises_lose'][(trial_summary["draw"] == 0) & trial_mask]))
|
||||
cc = np.concatenate((trial_summary['chirps_win'][(trial_summary["draw"] == 0) & trial_mask],
|
||||
trial_summary['chirps_lose'][(trial_summary["draw"] == 0) & trial_mask]))
|
||||
r, p = scp.spearmanr(rc, cc)
|
||||
r, p = scp.pearsonr(rc, cc)
|
||||
print(f'Risescount - Chirpscount - all: Pearson-r={r:.2f} p={p:.3f}')
|
||||
|
||||
r, p = scp.spearmanr(trial_summary['rises_win'][(trial_summary["draw"] == 0) & trial_mask],
|
||||
r, p = scp.pearsonr(trial_summary['rises_win'][(trial_summary["draw"] == 0) & trial_mask],
|
||||
trial_summary['chirps_win'][(trial_summary["draw"] == 0) & trial_mask])
|
||||
print(f'Risescount - Chirpscount - win: Pearson-r={r:.2f} p={p:.3f}')
|
||||
|
||||
r, p = scp.spearmanr(trial_summary['rises_lose'][(trial_summary["draw"] == 0) & trial_mask],
|
||||
r, p = scp.pearsonr(trial_summary['rises_lose'][(trial_summary["draw"] == 0) & trial_mask],
|
||||
trial_summary['chirps_lose'][(trial_summary["draw"] == 0) & trial_mask])
|
||||
print(f'Risescount - Chirpscount - lose: Pearson-r={r:.2f} p={p:.3f}')
|
||||
plot_rise_vs_chirp_count(trial_summary, trial_mask)
|
||||
@ -370,50 +373,6 @@ def main(base_path):
|
||||
plot_meta_correlation(trial_summary, trial_mask, key1=keys[i], key2=keys[j],
|
||||
key1_name=keys_names[i], key2_name=keys_names[j])
|
||||
|
||||
# plot_meta_correlation(trial_summary, key1='med_chase_dur', key2='chirps_lose',
|
||||
# key1_name=r'chase duration$_{median}$ [s]', key2_name=r'chirps$_{lose}$')
|
||||
# plot_meta_correlation(trial_summary, key1='med_chase_dur', key2='rises_lose',
|
||||
# key1_name=r'chase duration$_{median}$ [s]', key2_name=r'rises$_{lose}$')
|
||||
|
||||
# if True:
|
||||
# ### chirp count vs. dSize ###
|
||||
# for key in ['chirps_lose', 'chirps_win', 'rises_win', 'rises_lose']:
|
||||
# print('')
|
||||
# lose_chirps_male_win = trial_summary[key][(trial_summary['sex_win'] == 'm') & (trial_summary["draw"] == 0)]
|
||||
# lose_size_male_win = trial_summary['size_lose'][(trial_summary['sex_win'] == 'm') & (trial_summary["draw"] == 0)]
|
||||
# win_size_male_win = trial_summary['size_win'][(trial_summary['sex_win'] == 'm') & (trial_summary["draw"] == 0)]
|
||||
#
|
||||
# r, p = scp.pearsonr((lose_size_male_win - win_size_male_win)*-1, lose_chirps_male_win)
|
||||
# print(f'(Male win) {key} - dSize: Pearson-r={r:.2f} p={p:.3f}')
|
||||
#
|
||||
# lose_chirps_female_win = trial_summary[key][(trial_summary['sex_win'] == 'f') & (trial_summary["draw"] == 0)]
|
||||
# lose_size_female_win = trial_summary['size_lose'][(trial_summary['sex_win'] == 'f') & (trial_summary["draw"] == 0)]
|
||||
# win_size_female_win = trial_summary['size_win'][(trial_summary['sex_win'] == 'f') & (trial_summary["draw"] == 0)]
|
||||
#
|
||||
# r, p = scp.pearsonr(lose_chirps_female_win, lose_size_female_win - win_size_female_win)
|
||||
# print(f'(Female win) {key} - dSize: Pearson-r={r:.2f} p={p:.3f}')
|
||||
#
|
||||
# lose_chirps_male_lose = trial_summary[key][(trial_summary['sex_lose'] == 'm') & (trial_summary["draw"] == 0)]
|
||||
# lose_size_male_lose = trial_summary['size_lose'][(trial_summary['sex_lose'] == 'm') & (trial_summary["draw"] == 0)]
|
||||
# win_size_male_lose = trial_summary['size_win'][(trial_summary['sex_lose'] == 'm') & (trial_summary["draw"] == 0)]
|
||||
#
|
||||
# r, p = scp.pearsonr(lose_chirps_male_lose, lose_size_male_lose - win_size_male_lose)
|
||||
# print(f'(Male lose) {key} - dSize: Pearson-r={r:.2f} p={p:.3f}')
|
||||
#
|
||||
# lose_chirps_female_lose = trial_summary[key][(trial_summary['sex_lose'] == 'f') & (trial_summary["draw"] == 0)]
|
||||
# lose_size_female_lose = trial_summary['size_lose'][(trial_summary['sex_lose'] == 'f') & (trial_summary["draw"] == 0)]
|
||||
# win_size_female_lose = trial_summary['size_win'][(trial_summary['sex_lose'] == 'f') & (trial_summary["draw"] == 0)]
|
||||
#
|
||||
# r, p = scp.pearsonr(lose_chirps_female_lose, lose_size_female_lose - win_size_female_lose)
|
||||
# print(f'(Female lose) {key} - dSize: Pearson-r={r:.2f} p={p:.3f}')
|
||||
#
|
||||
# all_lose_chrips = trial_summary[key][(trial_summary["draw"] == 0)]
|
||||
# all_lose_size = trial_summary['size_lose'][(trial_summary["draw"] == 0)]
|
||||
# all_win_size = trial_summary['size_win'][(trial_summary["draw"] == 0)]
|
||||
# r, p = scp.pearsonr(all_lose_chrips, all_lose_size - all_win_size)
|
||||
#
|
||||
# print(f'(all) {key} - dSize: Pearson-r={r:.2f} p={p:.3f}')
|
||||
|
||||
plot_beh_conut_vs_experience(trial_summary, trial_mask, beh_key_win='chirps_win', beh_key_lose='chirps_lose',
|
||||
ylabel='chirps [n]', save_str='chirps_by_experince')
|
||||
plot_beh_conut_vs_experience(trial_summary, trial_mask=None, beh_key_win='rises_win', beh_key_lose='rises_lose', ylabel='rises [n]',
|
||||
|
Loading…
Reference in New Issue
Block a user