Skip to content

Commit

Permalink
Merge pull request #87 from MattNolanLab/correlation_analysis
Browse files Browse the repository at this point in the history
Correlation analysis
  • Loading branch information
klaragerlei authored Nov 17, 2018
2 parents 14eb821 + 4c5f70f commit 2cbbb35
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
15 changes: 13 additions & 2 deletions OverallAnalysis/analyze_hd_from_whole_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def add_combined_id_to_df(df_all_mice):
def main():
print('-------------------------------------------------------------')
print('-------------------------------------------------------------')
local_path = '/Users/s1466507/Documents/Ephys/test_overall_analysis/test_df.pkl'
local_path = '/Users/s1466507/Documents/Ephys/test_overall_analysis/all_mice_df.pkl'
path_to_data = 'C:/Users/s1466507/Documents/Ephys/test_overall_analysis/'
save_output_path = 'C:/Users/s1466507/Documents/Ephys/overall_figures/'
false_positives_path = path_to_data + 'false_positives_all.txt'
Expand All @@ -44,9 +44,20 @@ def main():
print('mean pearson r of correlation between first and second half')
print(df_all_mice.hd_correlation_first_vs_second_half[significant_corr & good_cluster].mean())

watson_result_exists = df_all_mice.watson_test_hd.notnull()
print('Number of cells included in two sample watson test for head-direction from the whole session: ' + str(watson_result_exists.sum()))
print('excitatory: ' + str(len(df_all_mice[excitatory_neurons & watson_result_exists])))
print('inhibitory: ' + str(len(df_all_mice[inhibitory_neurons & watson_result_exists])))
watson_significant = df_all_mice.watson_test_hd > 0.385 # p < 0.001
print('Number of cells with significantly differen HD distributions: ' + str(watson_significant.sum()))
print('Number of excitatory neurons with significantly different HD: ' + str(len(df_all_mice[watson_significant & excitatory_neurons])))
print('Number of inhibitory neurons with significantly different HD: ' + str(len(df_all_mice[watson_significant & inhibitory_neurons])))

# find those where the hd polar plot significantly differs in the first vs second half
# run load_df again and add the result of the 2 sample watson test to the big df and then filter for that here
OverallAnalysis.analyze_field_correlations.plot_correlation_coef_hist(df_all_mice.hd_correlation_first_vs_second_half[significant_corr & good_cluster], save_output_path + 'correlation_hd_session.png')
OverallAnalysis.analyze_field_correlations.plot_correlation_coef_hist(df_all_mice.hd_correlation_first_vs_second_half[significant_corr & good_cluster & watson_significant], save_output_path + 'correlation_hd_session.png')
OverallAnalysis.analyze_field_correlations.plot_correlation_coef_hist(df_all_mice.hd_correlation_first_vs_second_half[significant_corr & good_cluster & watson_significant & excitatory_neurons], save_output_path + 'correlation_hd_session_excitatory.png')
OverallAnalysis.analyze_field_correlations.plot_correlation_coef_hist(df_all_mice.hd_correlation_first_vs_second_half[significant_corr & good_cluster & watson_significant & inhibitory_neurons], save_output_path + 'correlation_hd_session_inhibitory.png')



Expand Down
6 changes: 3 additions & 3 deletions OverallAnalysis/load_data_frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

server_test_file = '//cmvm.datastore.ed.ac.uk/cmvm/sbms/groups/mnolan_NolanLab/ActiveProjects/Klara/test_analysis/M5_2018-03-05_13-30-30_of/parameters.txt'
server_path = '//cmvm.datastore.ed.ac.uk/cmvm/sbms/groups/mnolan_NolanLab/ActiveProjects/Klara/Open_field_opto_tagging_p038/'
local_output_path = '/Users/s1466507/Documents/Ephys/test_overall_analysis/test_df.pkl'
local_output_path = '/Users/s1466507/Documents/Ephys/test_overall_analysis/all_mice_df.pkl'


test_image_path = '/Users/s1466507/Desktop/mouse.jpg'
Expand Down Expand Up @@ -38,8 +38,8 @@
'hd_hist_second_half'
'''
if 'hd_hist_first_half' in spatial_firing:
spatial_firing = spatial_firing[['session_id', 'cluster_id', 'tetrode', 'number_of_spikes', 'mean_firing_rate', 'isolation', 'noise_overlap', 'peak_snr', 'hd_correlation_first_vs_second_half', 'hd_correlation_first_vs_second_half_p', 'hd_hist_first_half', 'firing_fields_hd_session', 'hd_hist_second_half']].copy()
if ('hd_hist_first_half' in spatial_firing) and ('watson_test_hd' in spatial_firing):
spatial_firing = spatial_firing[['session_id', 'cluster_id', 'tetrode', 'number_of_spikes', 'mean_firing_rate', 'isolation', 'noise_overlap', 'peak_snr', 'hd_correlation_first_vs_second_half', 'hd_correlation_first_vs_second_half_p', 'hd_hist_first_half', 'firing_fields_hd_session', 'hd_hist_second_half', 'watson_test_hd']].copy()

# print(spatial_firing.head())
spatial_firing_data = spatial_firing_data.append(spatial_firing)
Expand Down
3 changes: 2 additions & 1 deletion PostSorting/open_field_make_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def plot_firing_rate_maps(spatial_firing, prm):
os.makedirs(save_path)
for cluster in range(len(spatial_firing)):
cluster = spatial_firing.cluster_id.values[cluster] - 1
firing_rate_map = spatial_firing.firing_maps[cluster]
firing_rate_map_original = spatial_firing.firing_maps[cluster]
firing_rate_map = np.rot90(firing_rate_map_original)
firing_rate_map_fig = plt.figure()
firing_rate_map_fig.set_size_inches(5, 5, forward=True)
ax = firing_rate_map_fig.add_subplot(1, 1, 1) # specify (nrows, ncols, axnum)
Expand Down

0 comments on commit 2cbbb35

Please sign in to comment.