meta analysis continues... next step would be to load the time series data and calculate cross correlations

This commit is contained in:
Till Raab 2023-05-23 14:53:46 +02:00
parent 8c1f85f89e
commit d9d9982635
3 changed files with 77 additions and 206 deletions

View File

@ -129,7 +129,7 @@ def frequency_q10_compensation(baseline_freqs : np.ndarray,
# q10 with same values is useless
continue
if baseline_freq_times[i] < light_start_sec or baseline_freq_times[j] < light_start_sec:
# too much frequency changes due to rises in first part of rec !!!
# too much frequency changes due to rises in first part of rec !!!
continue
# if np.abs(Ctemp[i] - Ctemp[j]) < 0.5:
# continue
@ -387,7 +387,7 @@ def main(data_folder=None):
for f in fish_no:
fish_EODf25 = np.concatenate((trial_summary['EODf_lose'][(trial_summary['group'] == g) & (trial_summary['lose_fish'] == f)],
trial_summary['EODf_win'][(trial_summary['group'] == g) & (trial_summary['win_fish'] == f)]))
if np.nanmedian(fish_EODf25) < 740:
if np.nanmedian(fish_EODf25) < 730:
sex = 'f'
else:
sex = 'm'

View File

@ -1,17 +1,17 @@
,recording,group,win_fish,lose_fish,sex_win,sex_lose,size_win,size_lose,EODf_win,EODf_lose,exp_win,exp_lose,chirps_win,chirps_lose,rises_win,rises_lose,draw
0,2019-11-25-09_59,3,1,2,f,f,13.2,12.0,713.0544113886845,762.0273047058653,1,1,36,2657,22,165,0
0,2019-11-25-09_59,3,1,2,f,m,13.2,12.0,713.0544113886845,762.0273047058653,1,1,36,2657,22,165,0
1,2019-11-26-10_00,3,4,3,m,m,15.5,17.5,883.141322780704,918.0584506431281,1,1,472,1322,17,481,0
2,2019-11-27-10_00,3,5,6,f,f,14.4,12.65,728.1663791991439,650.6079943890219,1,1,16,2041,14,311,0
3,2019-11-28-09_58,3,1,3,f,m,13.2,17.5,720.9491781126661,888.9029901347602,2,2,370,30,26,37,0
4,2019-11-29-09_59,3,4,2,m,f,15.5,12.0,927.3677808126133,757.8912786740188,2,2,119,1232,56,161,0
4,2019-11-29-09_59,3,4,2,m,m,15.5,12.0,927.3677808126133,757.8912786740188,2,2,119,1232,56,161,0
5,2019-12-02-10_00,3,3,5,m,f,17.5,14.4,866.5433040990971,719.3596160671729,3,2,2,759,28,165,0
6,2019-12-03-10_01,3,1,6,f,f,13.2,12.65,709.888382193265,645.345316200243,3,2,61,3191,23,230,0
7,2019-12-04-10_00,3,3,2,m,f,17.5,12.0,867.515070390076,732.5567785654214,4,3,2,1005,31,73,0
7,2019-12-04-10_00,3,3,2,m,m,17.5,12.0,867.515070390076,732.5567785654214,4,3,2,1005,31,73,0
8,2019-12-06-10_00,3,4,6,m,f,15.5,12.65,912.2881743174412,652.9837532796978,3,3,34,306,58,188,0
9,2019-12-09-10_00,3,5,2,f,f,14.4,12.0,715.5845509704202,726.7506510306094,4,4,446,2345,10,180,0
9,2019-12-09-10_00,3,5,2,f,m,14.4,12.0,715.5845509704202,726.7506510306094,4,4,446,2345,10,180,0
10,2019-12-10-10_00,3,3,6,m,f,17.5,12.65,853.973867720756,640.9374451096469,5,4,1,205,31,165,0
11,2019-12-11-10_00,3,4,1,m,f,15.5,13.2,909.5564241038855,704.759181051688,4,5,44,260,48,165,0
12,2019-12-12-10_00,3,2,6,f,f,12.0,12.65,708.2029632781753,649.3215729301896,5,5,55,1489,26,152,0
12,2019-12-12-10_00,3,2,6,m,f,12.0,12.65,708.2029632781753,649.3215729301896,5,5,55,1489,26,152,0
13,2019-12-16-10_00,3,4,5,m,f,15.5,14.4,911.4475182245616,734.3463774893517,5,5,52,963,39,123,0
14,2020-03-13-10_00,4,5,4,f,f,12.5,12.266666666666666,726.3470010966499,705.1654694195288,2,2,54,941,70,177,0
15,2020-03-16-10_00,4,3,1,m,f,11.933333333333332,11.299999999999999,852.2318545355058,642.0347177867645,3,3,1304,724,57,154,0

1 recording group win_fish lose_fish sex_win sex_lose size_win size_lose EODf_win EODf_lose exp_win exp_lose chirps_win chirps_lose rises_win rises_lose draw
2 0 2019-11-25-09_59 3 1 2 f f m 13.2 12.0 713.0544113886845 762.0273047058653 1 1 36 2657 22 165 0
3 1 2019-11-26-10_00 3 4 3 m m 15.5 17.5 883.141322780704 918.0584506431281 1 1 472 1322 17 481 0
4 2 2019-11-27-10_00 3 5 6 f f 14.4 12.65 728.1663791991439 650.6079943890219 1 1 16 2041 14 311 0
5 3 2019-11-28-09_58 3 1 3 f m 13.2 17.5 720.9491781126661 888.9029901347602 2 2 370 30 26 37 0
6 4 2019-11-29-09_59 3 4 2 m f m 15.5 12.0 927.3677808126133 757.8912786740188 2 2 119 1232 56 161 0
7 5 2019-12-02-10_00 3 3 5 m f 17.5 14.4 866.5433040990971 719.3596160671729 3 2 2 759 28 165 0
8 6 2019-12-03-10_01 3 1 6 f f 13.2 12.65 709.888382193265 645.345316200243 3 2 61 3191 23 230 0
9 7 2019-12-04-10_00 3 3 2 m f m 17.5 12.0 867.515070390076 732.5567785654214 4 3 2 1005 31 73 0
10 8 2019-12-06-10_00 3 4 6 m f 15.5 12.65 912.2881743174412 652.9837532796978 3 3 34 306 58 188 0
11 9 2019-12-09-10_00 3 5 2 f f m 14.4 12.0 715.5845509704202 726.7506510306094 4 4 446 2345 10 180 0
12 10 2019-12-10-10_00 3 3 6 m f 17.5 12.65 853.973867720756 640.9374451096469 5 4 1 205 31 165 0
13 11 2019-12-11-10_00 3 4 1 m f 15.5 13.2 909.5564241038855 704.759181051688 4 5 44 260 48 165 0
14 12 2019-12-12-10_00 3 2 6 f m f 12.0 12.65 708.2029632781753 649.3215729301896 5 5 55 1489 26 152 0
15 13 2019-12-16-10_00 3 4 5 m f 15.5 14.4 911.4475182245616 734.3463774893517 5 5 52 963 39 123 0
16 14 2020-03-13-10_00 4 5 4 f f 12.5 12.266666666666666 726.3470010966499 705.1654694195288 2 2 54 941 70 177 0
17 15 2020-03-16-10_00 4 3 1 m f 11.933333333333332 11.299999999999999 852.2318545355058 642.0347177867645 3 3 1304 724 57 154 0

View File

@ -34,9 +34,9 @@ def plot_rise_vs_chirp_count(trial_summary):
plt.setp(ax_rises.get_xticklabels(), visible=False)
def plot_chirp_rise_count_per_pairing(trial_summary,
beh_key_win=None, beh_key_lose=None,
ylabel='y'):
def plot_beh_count_per_pairing(trial_summary,
beh_key_win=None, beh_key_lose=None,
ylabel='y'):
mek = ['k', 'None', 'None', 'k']
markersize = 12
@ -48,11 +48,11 @@ def plot_chirp_rise_count_per_pairing(trial_summary,
for win_sex, lose_sex in itertools.product(['m', 'f'], repeat=2):
win_count.append(trial_summary[beh_key_win][(trial_summary["sex_win"] == win_sex) &
(trial_summary["sex_lose"] == lose_sex) &
(trial_summary["draw"] == 0)].to_numpy())
lose_count.append(trial_summary[beh_key_lose][(trial_summary["sex_win"] == win_sex) &
(trial_summary["sex_lose"] == lose_sex) &
(trial_summary["draw"] == 0)].to_numpy())
lose_count.append(trial_summary[beh_key_lose][(trial_summary["sex_win"] == win_sex) &
(trial_summary["sex_lose"] == lose_sex) &
(trial_summary["draw"] == 0)].to_numpy())
fig = plt.figure(figsize=(20/2.54, 12/2.54))
gs = gridspec.GridSpec(1, 1, left=0.1, bottom=0.1, right=0.95, top=0.95)
@ -70,60 +70,6 @@ def plot_chirp_rise_count_per_pairing(trial_summary,
ax.set_ylabel(ylabel, fontsize=12)
plt.tick_params(labelsize=10)
# win_chirps = []
# lose_chirps = []
#
# win_rises = []
# lose_rises = []
#
# for win_sex, lose_sex in itertools.product(['m', 'f'], repeat=2):
# win_chirps.append(trial_summary['chirps_win'][(trial_summary["sex_win"] == win_sex) &
# (trial_summary["sex_lose"] == lose_sex) &
# (trial_summary["draw"] == 0)].to_numpy())
# lose_chirps.append(trial_summary['chirps_lose'][(trial_summary["sex_win"] == win_sex) &
# (trial_summary["sex_lose"] == lose_sex) &
# (trial_summary["draw"] == 0)].to_numpy())
# win_rises.append(trial_summary['rises_win'][(trial_summary["sex_win"] == win_sex) &
# (trial_summary["sex_lose"] == lose_sex) &
# (trial_summary["draw"] == 0)].to_numpy())
# lose_rises.append(trial_summary['rises_lose'][(trial_summary["sex_win"] == win_sex) &
# (trial_summary["sex_lose"] == lose_sex) &
# (trial_summary["draw"] == 0)].to_numpy())
#
#
# fig = plt.figure(figsize=(20/2.54, 12/2.54))
# gs = gridspec.GridSpec(1, 1, left=0.1, bottom=0.1, right=0.95, top=0.95)
# ax = fig.add_subplot(gs[0, 0])
# ax.boxplot(win_chirps, positions=np.arange(len(win_chirps))-0.15, widths= .2, sym='')
# ax.boxplot(lose_chirps, positions=np.arange(len(lose_chirps))+0.15, widths= .2, sym='')
#
# ax.set_xticks(np.arange(len(win_chirps)))
# ax.set_xticklabels([u'\u2642\u2642', u'\u2642\u2640', u'\u2640\u2642', u'\u2640\u2640'])
# # ax.set_xticklabels(['mm', 'mf', 'fm', 'ff'])
# y0, y1 = ax.get_ylim()
# for i in range(len(win_chirps)):
# ax.text(i, y1, f'n={len(win_chirps[i]):.0f}', fontsize=10, ha='center', va='bottom')
# ax.set_ylim(top = y1*1.1)
# ax.set_ylabel('chirps [n]', fontsize=12)
# plt.tick_params(labelsize=10)
#
# fig = plt.figure(figsize=(20/2.54, 12/2.54))
# gs = gridspec.GridSpec(1, 1, left=0.1, bottom=0.1, right=0.95, top=0.95)
# ax = fig.add_subplot(gs[0, 0])
# ax.boxplot(win_rises, positions=np.arange(len(win_rises))-0.15, widths= .2, sym='')
# ax.boxplot(lose_rises, positions=np.arange(len(lose_rises))+0.15, widths= .2, sym='')
#
# ax.set_xticks(np.arange(len(win_rises)))
# ax.set_xticklabels([u'\u2642\u2642', u'\u2642\u2640', u'\u2640\u2642', u'\u2640\u2640'])
# # ax.set_xticklabels(['mm', 'mf', 'fm', 'ff'])
# y0, y1 = ax.get_ylim()
# for i in range(len(win_rises)):
# ax.text(i, y1, f'n={len(win_rises[i]):.0f}', fontsize=10, ha='center', va='bottom')
# ax.set_ylim(top = y1*1.1)
# ax.set_ylabel('rises [n]', fontsize=12)
# plt.tick_params(labelsize=10)
# # plt.show()
def plot_beh_count_vs_meta(trial_summary,
beh_key_win=None, beh_key_lose=None,
@ -183,151 +129,73 @@ def plot_beh_count_vs_meta(trial_summary,
plt.setp(ax[3].get_yticklabels(), visible=False)
plt.tick_params(labelsize=10)
###############################################################################################################
# win_chirps = []
# lose_chirps = []
#
# win_rises = []
# lose_rises = []
#
# d_size = []
# d_EODf = []
#
# for win_sex, lose_sex in itertools.product(['m', 'f'], repeat=2):
# win_chirps.append(trial_summary['chirps_win'][(trial_summary["sex_win"] == win_sex) &
# (trial_summary["sex_lose"] == lose_sex) &
# (trial_summary["draw"] == 0)].to_numpy())
# lose_chirps.append(trial_summary['chirps_lose'][(trial_summary["sex_win"] == win_sex) &
# (trial_summary["sex_lose"] == lose_sex) &
# (trial_summary["draw"] == 0)].to_numpy())
# win_rises.append(trial_summary['rises_win'][(trial_summary["sex_win"] == win_sex) &
# (trial_summary["sex_lose"] == lose_sex) &
# (trial_summary["draw"] == 0)].to_numpy())
# lose_rises.append(trial_summary['rises_lose'][(trial_summary["sex_win"] == win_sex) &
# (trial_summary["sex_lose"] == lose_sex) &
# (trial_summary["draw"] == 0)].to_numpy())
#
# w_size = trial_summary['size_win'][(trial_summary["sex_win"] == win_sex) &
# (trial_summary["sex_lose"] == lose_sex) &
# (trial_summary["draw"] == 0)].to_numpy()
# l_size = trial_summary['size_lose'][(trial_summary["sex_win"] == win_sex) &
# (trial_summary["sex_lose"] == lose_sex) &
# (trial_summary["draw"] == 0)].to_numpy()
#
# w_EODf = trial_summary['EODf_win'][(trial_summary["sex_win"] == win_sex) &
# (trial_summary["sex_lose"] == lose_sex) &
# (trial_summary["draw"] == 0)].to_numpy()
# l_EODf = trial_summary['EODf_lose'][(trial_summary["sex_win"] == win_sex) &
# (trial_summary["sex_lose"] == lose_sex) &
# (trial_summary["draw"] == 0)].to_numpy()
#
# d_size.append(w_size-l_size)
# d_EODf.append(w_EODf-l_EODf)
#
#
# mek = ['k', 'None', 'None', 'k']
# markersize = 12
# win_colors = [male_color, male_color, female_color, female_color]
# lose_colors = [male_color, female_color, male_color, female_color]
#
# ### SIZE
# ##################################################################################################################
# fig = plt.figure(figsize=(20/2.54, 20/2.54))
# gs = gridspec.GridSpec(2, 2, left=0.1, bottom=0.1, right=0.95, top=0.95, hspace=0.1, wspace=0.1)
# ax = []
# ax.append(fig.add_subplot(gs[0, 0]))
# ax.append(fig.add_subplot(gs[1, 0], sharex=ax[0]))
# ax.append(fig.add_subplot(gs[0, 1], sharey=ax[0]))
# ax.append(fig.add_subplot(gs[1, 1], sharex=ax[2], sharey=ax[1]))
#
# for i in range(len(lose_chirps)):
# ax[0].plot(d_size[i], win_rises[i], 'p', color=win_colors[i], markeredgecolor=mek[i], markersize=markersize, markeredgewidth=2)
# ax[1].plot(d_size[i], lose_rises[i], 'p', color=win_colors[i], markeredgecolor=mek[i], markersize=markersize, markeredgewidth=2)
#
# ax[2].plot(d_size[i], win_rises[i], 'o', color=lose_colors[i], markeredgecolor=mek[i], markersize=markersize, markeredgewidth=2)
# ax[3].plot(d_size[i], lose_rises[i], 'o', color=lose_colors[i], markeredgecolor=mek[i], markersize=markersize, markeredgewidth=2 )
#
# ax[0].set_ylabel('win rises [n]', fontsize=12)
# ax[1].set_ylabel('lose rises [n]', fontsize=12)
# ax[1].set_xlabel(u'$\Delta$size [cm]', fontsize=12)
# ax[3].set_xlabel(u'$\Delta$size [cm]', fontsize=12)
#
# plt.setp(ax[0].get_xticklabels(), visible=False)
# plt.setp(ax[2].get_xticklabels(), visible=False)
#
# plt.setp(ax[2].get_yticklabels(), visible=False)
# plt.setp(ax[3].get_yticklabels(), visible=False)
# plt.tick_params(labelsize=10)
#
# ##################################################################################################################
# fig = plt.figure(figsize=(20/2.54, 20/2.54))
# gs = gridspec.GridSpec(2, 2, left=0.1, bottom=0.1, right=0.95, top=0.95, hspace=0.1, wspace=0.1)
# ax = []
# ax.append(fig.add_subplot(gs[0, 0]))
# ax.append(fig.add_subplot(gs[1, 0], sharex=ax[0]))
# ax.append(fig.add_subplot(gs[0, 1], sharey=ax[0]))
# ax.append(fig.add_subplot(gs[1, 1], sharex=ax[2], sharey=ax[1]))
#
# for i in range(len(lose_chirps)):
# ax[0].plot(d_size[i], win_chirps[i], 'p', color=win_colors[i], markeredgecolor=mek[i], markersize=markersize, markeredgewidth=2)
# ax[1].plot(d_size[i], lose_chirps[i], 'p', color=win_colors[i], markeredgecolor=mek[i], markersize=markersize, markeredgewidth=2)
#
# ax[2].plot(d_size[i], win_chirps[i], 'o', color=lose_colors[i], markeredgecolor=mek[i], markersize=markersize, markeredgewidth=2)
# ax[3].plot(d_size[i], lose_chirps[i], 'o', color=lose_colors[i], markeredgecolor=mek[i], markersize=markersize, markeredgewidth=2 )
#
# ax[0].set_ylabel('win chirps [n]', fontsize=12)
# ax[1].set_ylabel('lose chirps [n]', fontsize=12)
# ax[1].set_xlabel(u'$\Delta$size [cm]', fontsize=12)
# ax[3].set_xlabel(u'$\Delta$size [cm]', fontsize=12)
#
# plt.setp(ax[0].get_xticklabels(), visible=False)
# plt.setp(ax[2].get_xticklabels(), visible=False)
#
# plt.setp(ax[2].get_yticklabels(), visible=False)
# plt.setp(ax[3].get_yticklabels(), visible=False)
# plt.tick_params(labelsize=10)
#
# ### EODf
# ##################################################################################################################
#
# fig = plt.figure(figsize=(20/2.54, 12/2.54))
# gs = gridspec.GridSpec(1, 1, left=0.1, bottom=0.15, right=0.95, top=0.95)
# ax = fig.add_subplot(gs[0, 0])
#
# for i in range(len(lose_rises)):
# ax.plot(d_EODf[i], lose_rises[i], 'p', color=win_colors[i], markeredgecolor=mek[i], markersize=markersize)
# # ax.plot(d_EODf[i]*-1, lose_rises[i], 'o', color=lose_colors[i], markeredgecolor=mek[i], markersize=markersize)
#
# ax.set_ylabel('lose rises [n]', fontsize=12)
# ax.set_xlabel(u'$\Delta$EODf [Hz]', fontsize=12)
# plt.tick_params(labelsize=10)
#
# ##################################################################################################################
# fig = plt.figure(figsize=(20/2.54, 12/2.54))
# gs = gridspec.GridSpec(1, 1, left=0.1, bottom=0.15, right=0.95, top=0.95)
# ax = fig.add_subplot(gs[0, 0])
#
# for i in range(len(lose_chirps)):
# ax.plot(d_EODf[i], lose_chirps[i], 'p', color=win_colors[i], markeredgecolor=mek[i], markersize=markersize)
# # ax.plot(d_EODf[i]*-1, lose_chirps[i], 'o', color=lose_colors[i], markeredgecolor=mek[i], markersize=markersize)
#
# ax.set_ylabel('lose chirps [n]', fontsize=12)
# ax.set_xlabel(u'$\Delta$EODf [Hz]', fontsize=12)
# plt.tick_params(labelsize=10)
def plot_beh_conut_vs_experience(trial_summary, beh_key_win='chirps_win', beh_key_lose='chirps_lose', ylabel='chirps [n]'):
mek = ['k', 'None', 'None', 'k']
markersize = 10
win_colors = [male_color, male_color, female_color, female_color]
lose_colors = [male_color, female_color, male_color, female_color]
lose_beh_per_exp = []
win_beh_per_exp = []
for i in np.unique(trial_summary['exp_lose']):
lose_beh_per_exp.append(trial_summary[beh_key_lose][(trial_summary['exp_lose'] == i) &
(trial_summary["draw"] == 0)].to_numpy())
win_beh_per_exp.append(trial_summary[beh_key_win][(trial_summary['exp_lose'] == i) &
(trial_summary["draw"] == 0)].to_numpy())
fig = plt.figure(figsize=(20 / 2.54, 12 / 2.54))
gs = gridspec.GridSpec(1, 1, left=0.1, bottom=0.15, right=0.95, top=0.95, hspace=0.1, wspace=0.1)
ax = fig.add_subplot(gs[0, 0])
ax.boxplot(lose_beh_per_exp, positions = np.unique(trial_summary['exp_lose'])-0.15, widths=0.2)
ax.boxplot(win_beh_per_exp, positions = np.unique(trial_summary['exp_lose'])+0.15, widths=0.2)
for enu, (win_sex, lose_sex) in enumerate(itertools.product(['m', 'f'], repeat=2)):
lose_beh_count = trial_summary[beh_key_lose][(trial_summary["sex_win"] == win_sex) &
(trial_summary["sex_lose"] == lose_sex) &
(trial_summary["draw"] == 0)].to_numpy()
win_beh_count = trial_summary[beh_key_win][(trial_summary["sex_win"] == win_sex) &
(trial_summary["sex_lose"] == lose_sex) &
(trial_summary["draw"] == 0)].to_numpy()
lose_exp = trial_summary['exp_lose'][(trial_summary["sex_win"] == win_sex) &
(trial_summary["sex_lose"] == lose_sex) &
(trial_summary["draw"] == 0)].to_numpy()
win_exp = trial_summary['exp_win'][(trial_summary["sex_win"] == win_sex) &
(trial_summary["sex_lose"] == lose_sex) &
(trial_summary["draw"] == 0)].to_numpy()
ax.plot(lose_exp-0.15, lose_beh_count, 'o', color=lose_colors[enu], markeredgecolor=mek[enu],
markersize=markersize, markeredgewidth=2)
ax.plot(win_exp+0.15, win_beh_count, 'p', color=win_colors[enu], markeredgecolor=mek[enu],
markersize=markersize, markeredgewidth=2)
ax.set_xticks(np.unique(trial_summary['exp_lose']))
ax.set_xticklabels(np.unique(trial_summary['exp_lose']))
ax.set_xlabel('experience [trials]', fontsize=12)
ax.set_ylabel(ylabel, fontsize=12)
ax.tick_params(labelsize=10)
def main():
beh_per_exp = []
trial_summary = pd.read_csv('trial_summary.csv', index_col=0)
chirp_notes = pd.read_csv('chirp_notes.csv', index_col=0)
# trial_summary = trial_summary[chirp_notes['good'] == 1]
trial_summary = trial_summary[chirp_notes['good'] == 1]
plot_rise_vs_chirp_count(trial_summary)
plot_chirp_rise_count_per_pairing(trial_summary,
beh_key_win='chirps_win', beh_key_lose='chirps_lose',
ylabel='chirps [n]')
plot_chirp_rise_count_per_pairing(trial_summary,
beh_key_win='rises_win', beh_key_lose='rises_lose',
ylabel='rises [n]')
plot_beh_count_per_pairing(trial_summary,
beh_key_win='chirps_win', beh_key_lose='chirps_lose',
ylabel='chirps [n]')
plot_beh_count_per_pairing(trial_summary,
beh_key_win='rises_win', beh_key_lose='rises_lose',
ylabel='rises [n]')
plot_beh_count_vs_meta(trial_summary,
@ -347,6 +215,9 @@ def main():
meta_key_win="EODf_win", meta_key_lose='EODf_lose',
xlabel=u'$\Delta$EODf [Hz]')
plot_beh_conut_vs_experience(trial_summary, beh_key_win='chirps_win', beh_key_lose='chirps_lose', ylabel='chirps [n]')
plot_beh_conut_vs_experience(trial_summary, beh_key_win='rises_win', beh_key_lose='rises_lose', ylabel='rises [n]')
plt.show()