<jupyter_start><jupyter_text>Import Results of Syllable Preference Analysis  z020<jupyter_code>z020_bird_id = 'z020'

z020_day1 = load_pandas_from_pickle(data_name="syllable_phase_preference", bird_id=z020_bird_id,
                                    source=syllable_phase_preference_path, session=z020_days[0], verbose=True)

z020_day2 = load_pandas_from_pickle(data_name="syllable_phase_preference", bird_id=z020_bird_id,
                                    source=syllable_phase_preference_path, session=z020_days[1], verbose=True)
z020_day1['Session'] = "Day 1"
z020_day2['Session'] = "Day 2"

full_results_z020 = pd.concat([z020_day1, z020_day2], axis=0)

z020_when_instruct = all_when_label_instructions[z020_bird_id]<jupyter_output><empty_output><jupyter_text>z007<jupyter_code>z007_bird_id = 'z007'

z007_day1 = load_pandas_from_pickle(data_name="syllable_phase_preference", bird_id=z007_bird_id,
                                    source=syllable_phase_preference_path, session=z007_days[0], verbose=True)

z007_day2 = load_pandas_from_pickle(data_name="syllable_phase_preference", bird_id=z007_bird_id,
                                    source=syllable_phase_preference_path, session=z007_days[1], verbose=True)
z007_day1['Session'] = "Day 1"
z007_day2['Session'] = "Day 2"

full_results_z007 = pd.concat([z007_day1, z007_day2], axis=0)
full_results_z007.head()
z007_when_instruct = all_when_label_instructions[z007_bird_id]<jupyter_output><empty_output><jupyter_text>z017<jupyter_code>z017_bird_id = 'z017'

z017_day1 = load_pandas_from_pickle(data_name="syllable_phase_preference", bird_id=z017_bird_id,
                                    source=syllable_phase_preference_path, session=z017_days[0], verbose=True)

z017_day2 = load_pandas_from_pickle(data_name="syllable_phase_preference", bird_id=z017_bird_id,
                                    source=syllable_phase_preference_path, session=z017_days[1], verbose=True)
z017_day1['Session'] = "Day 1"
z017_day2['Session'] = "Day 2"

full_results_z017 = pd.concat([z017_day1, z017_day2], axis=0)
z017_when_instruct = all_when_label_instructions[z017_bird_id]<jupyter_output><empty_output><jupyter_text>Run Statistics on the Results<jupyter_code>z020_day1.head()
z020_day1[z020_day1['Syllable']=='2']['Difference']
z020_when_instruct
statistics, p_value = stats.wilcoxon(flat_diff_z_results[5], alternative='greater')<jupyter_output><empty_output><jupyter_text>z020<jupyter_code>the_p_values = []
for syll in z020_when_instruct:
    statistics, p_value = stats.wilcoxon(z020_day1[z020_day1['Syllable']==str(syll)]['Difference'],
                                         alternative='greater')
    the_p_values.append(p_value)
    print(p_value)
freq_p_values = np.asarray(the_p_values)  # Copy a ndarray of the p_values
p_values_ordered = np.sort(the_p_values)
p_value_order = np.argsort(freq_p_values)

significance = np.zeros(np.shape(freq_p_values))

for index, p_value in enumerate(p_values_ordered):
    threshold = ((index+1)/len(freq_p_values))*.05
    if p_value > threshold:
        significance[p_value_order[index]] = 1
significance
# b_h_fdr_result = []
# for all_freq_p_values in all_ranked_p_values:
#     freq_p_values = np.asarray(all_freq_p_values)  # Copy a ndarray of the p_values
#     p_values_ordered = np.sort(all_freq_p_values)
#     p_value_order = np.argsort(freq_p_values)
    
#     significance = np.zeros(np.shape(freq_p_values))
    
#     for index, p_value in enumerate(p_values_ordered):
#         threshold = ((index+1)/len(freq_p_values))*.05
#         if p_value > threshold:
#             significance[p_value_order[index]] = 1
#     b_h_fdr_result.append(significance)            

# b_h_fdr_result
the_p_values = []

for syll in z020_when_instruct:
    statistics, p_value = stats.wilcoxon(z020_day2[z020_day2['Syllable']==str(syll)]['Difference'],
                                         alternative='greater')
    the_p_values.append(p_value)
    print(p_value)
freq_p_values = np.asarray(the_p_values)  # Copy a ndarray of the p_values
p_values_ordered = np.sort(the_p_values)
p_value_order = np.argsort(freq_p_values)

significance = np.zeros(np.shape(freq_p_values))

for index, p_value in enumerate(p_values_ordered):
    threshold = ((index+1)/len(freq_p_values))*.05
    if p_value > threshold:
        significance[p_value_order[index]] = 1
significance<jupyter_output><empty_output><jupyter_text>z007<jupyter_code>the_p_values = []

for syll in z007_when_instruct:
    statistics, p_value = stats.wilcoxon(z007_day1[z007_day1['Syllable']==str(syll)]['Difference'],
                                         alternative='greater')
    the_p_values.append(p_value)
    print(p_value)
freq_p_values = np.asarray(the_p_values)  # Copy a ndarray of the p_values
p_values_ordered = np.sort(the_p_values)
p_value_order = np.argsort(freq_p_values)

significance = np.zeros(np.shape(freq_p_values))

for index, p_value in enumerate(p_values_ordered):
    threshold = ((index+1)/len(freq_p_values))*.05
    if p_value > threshold:
        significance[p_value_order[index]] = 1
significance
the_p_values = []

for syll in z007_when_instruct:
    statistics, p_value = stats.wilcoxon(z007_day2[z007_day2['Syllable']==str(syll)]['Difference'],
                                         alternative='greater')
    the_p_values.append(p_value)
    print(p_value)
freq_p_values = np.asarray(the_p_values)  # Copy a ndarray of the p_values
p_values_ordered = np.sort(the_p_values)
p_value_order = np.argsort(freq_p_values)

significance = np.zeros(np.shape(freq_p_values))

for index, p_value in enumerate(p_values_ordered):
    threshold = ((index+1)/len(freq_p_values))*.05
    if p_value > threshold:
        significance[p_value_order[index]] = 1
significance<jupyter_output><empty_output><jupyter_text>z017<jupyter_code>the_p_values = []

for syll in z017_when_instruct:
    statistics, p_value = stats.wilcoxon(z017_day1[z017_day1['Syllable']==str(syll)]['Difference'],
                                         alternative='greater')
    the_p_values.append(p_value)
    print(p_value)
freq_p_values = np.asarray(the_p_values)  # Copy a ndarray of the p_values
p_values_ordered = np.sort(the_p_values)
p_value_order = np.argsort(freq_p_values)

significance = np.zeros(np.shape(freq_p_values))

for index, p_value in enumerate(p_values_ordered):
    threshold = ((index+1)/len(freq_p_values))*.05
    if p_value > threshold:
        significance[p_value_order[index]] = 1
significance
the_p_values = []

for syll in z017_when_instruct:
    statistics, p_value = stats.wilcoxon(z017_day2[z017_day2['Syllable']==str(syll)]['Difference'],
                                         alternative='greater')
    the_p_values.append(p_value)
    print(p_value)
freq_p_values = np.asarray(the_p_values)  # Copy a ndarray of the p_values
p_values_ordered = np.sort(the_p_values)
p_value_order = np.argsort(freq_p_values)

significance = np.zeros(np.shape(freq_p_values))

for index, p_value in enumerate(p_values_ordered):
    threshold = ((index+1)/len(freq_p_values))*.05
    if p_value > threshold:
        significance[p_value_order[index]] = 1
significance<jupyter_output><empty_output><jupyter_text>Make Summary Figure<jupyter_code># [left, bottom, width, height]
0.117647 *2
fig = plt.figure(figsize=(8.5, 7), dpi = 300)

syll_colors= ['#B66DFF', '#db6e00', '#009292', '#924900', '#006DDB', '#FFFF6D', 'white', '#B6DBFF' , '#490092']

line_width = .5
subsize = 8
bigsize = 12
ticksize = 8


z007_ax = fig.add_axes([0.05882, 0.392839, 0.235294, 0.2857]) 

z020_ax = fig.add_axes([0.367634, 0.392839, 0.235294, 0.2857]) # z017

z017_ax = fig.add_axes([0.676448, 0.392839, 0.235294, 0.2857])

# z007
# Day 1
## Box Plot
sns.boxplot(x='Session', y= 'Difference', hue="Syllable", 
            hue_order= ['2', '3', '4', '5'],
            data= full_results_z007,
            order=['Day 1','Day 2'],
            palette = syll_colors,
            fliersize=line_width, 
            linewidth=line_width,
            ax=z007_ax)

z007_ax.set_ylim(-60, 140)


z007_ax.set_ylabel('Time Relative to True Onset (ms)')
z007_ax.tick_params(axis='both', which='major', labelsize=ticksize)
# ax1.set_xticklabels([])
# syll_2_1.set_yticklabels([])
z007_ax.xaxis.label.set_visible(False)
z007_ax.yaxis.label.set_visible(False)

# overall_legend = syll_2_1.get_legend()
z007_ax.legend('',frameon=False)

# z007
# Day 1
## Box Plot
sns.boxplot(x='Session', y= 'Difference', hue="Syllable", 
            hue_order= ['2', '3', '4'],
            data= full_results_z020,
            order=['Day 1','Day 2'],
            palette = syll_colors,
            fliersize=line_width, 
            linewidth=line_width,
            ax=z020_ax)

z020_ax.set_ylim(-60, 140)


z020_ax.set_ylabel('Time Relative to True Onset (ms)')
z020_ax.tick_params(axis='both', which='major', labelsize=ticksize)
# ax1.set_xticklabels([])
# syll_2_1.set_yticklabels([])
z020_ax.xaxis.label.set_visible(False)
z020_ax.yaxis.label.set_visible(False)
# z020_ax.set_yticklabels([])


# overall_legend = syll_2_1.get_legend()
z020_ax.legend('',frameon=False)

# z017
# Day 1
## Box Plot
sns.boxplot(x='Session', y= 'Difference', hue="Syllable", 
            hue_order= ['2', '3', '4', '5', '6', '7'],
            data= full_results_z017,
            order=['Day 1','Day 2'],
            palette = syll_colors,
            fliersize=line_width, 
            linewidth=line_width,
            ax=z017_ax)

z017_ax.set_ylim(-60, 140)


z017_ax.set_ylabel('Time Relative to True Onset (ms)')
z017_ax.tick_params(axis='both', which='major', labelsize=ticksize)
# ax1.set_xticklabels([])
# syll_2_1.set_yticklabels([])
z017_ax.xaxis.label.set_visible(False)
z017_ax.yaxis.label.set_visible(False)
# z017_ax.set_yticklabels([])


# overall_legend = syll_2_1.get_legend()
z017_ax.legend('',frameon=False)

# Save the Figure
figure_name = 'Syllable_Phase_Preference' + '_Supplement_cb.svg'
figure_type_folder = FIGURES_DIR / 'Syllable_Phase_Preference'

# Check if Folder Path Exists
if not figure_type_folder.exists():
    figure_type_folder.mkdir(parents=True, exist_ok=True)

figure_location = figure_type_folder / figure_name

# fig.savefig(figure_location, format='png')
fig.savefig(figure_location, dpi=300, papertype=None, format='svg')





plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12369337979094076, 'fraction_numerical': 0.0559427022841657, 'mean_word_length': 4.470089994706194, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '612590', 'license': 'MIT', 'n_tokens_mistral': 4312, 'n_tokens_neox': 3885, 'n_words': 556, 'path': 'notebooks/Main_Body_Figures/Fig_08-Phase_preference_to_syllable_onset_is_reflective_of_constitutive_syllables_rather_than_of_the_larger_motif_structure.ipynb', 'repo_name': 'Darilbii/Songbird_LFP_Paper', 'size': '10332'}