Merge branch 'master' of https://whale.am28.uni-tuebingen.de/git/jgrewe/chirp_probing
This commit is contained in:
commit
bdbab448ed
@ -43,11 +43,12 @@ Won't do, this is trivial?!
|
|||||||
|
|
||||||
* Work out the difference between baseline activity and a foreign chirp response: --> done
|
* Work out the difference between baseline activity and a foreign chirp response: --> done
|
||||||
* calculate the discriminability between the baseline (no-other fish present) and the another fish is present for each contrast
|
* calculate the discriminability between the baseline (no-other fish present) and the another fish is present for each contrast
|
||||||
* Work out the difference between the soliloquy and the response to self generated chirp in a communication context
|
* Work out the difference between the soliloquy and the response to self generated chirp in a communication context -> done
|
||||||
* Compare to the beat alone parts of the responses.
|
* Compare to the beat alone parts of the responses. -> done
|
||||||
* What kernels to use?
|
* What kernels to use?
|
||||||
* Duration of the chrip window?
|
* Duration of the chrip window?
|
||||||
* sorting according to phase?
|
* sorting according to phase?
|
||||||
|
* we could filter the P-unit responses to model the ELL filering
|
||||||
|
|
||||||
## Random thoughts
|
## Random thoughts
|
||||||
|
|
||||||
@ -55,4 +56,3 @@ Won't do, this is trivial?!
|
|||||||
* Raab et al show this is also the case with rises.
|
* Raab et al show this is also the case with rises.
|
||||||
* Check role of AFRs and rises in Tallarovic et al, Hupe et al.
|
* Check role of AFRs and rises in Tallarovic et al, Hupe et al.
|
||||||
* we actually do not observe chirps without stimulation
|
* we actually do not observe chirps without stimulation
|
||||||
*
|
|
||||||
|
@ -273,7 +273,7 @@ def foreign_fish_detection_beat(block_map, df, all_contrasts, all_conditions, ke
|
|||||||
baseline_dist = within_group_distance(no_other_snippets)
|
baseline_dist = within_group_distance(no_other_snippets)
|
||||||
comp_dist = across_group_distance(no_other_snippets, self_snippets)
|
comp_dist = across_group_distance(no_other_snippets, self_snippets)
|
||||||
|
|
||||||
# sort and perfom roc
|
# sort and perfom ROC analysis
|
||||||
triangle_indices = np.tril_indices_from(baseline_dist, -1)
|
triangle_indices = np.tril_indices_from(baseline_dist, -1)
|
||||||
valid_distances_baseline = baseline_dist[triangle_indices]
|
valid_distances_baseline = baseline_dist[triangle_indices]
|
||||||
temp1 = np.zeros_like(valid_distances_baseline)
|
temp1 = np.zeros_like(valid_distances_baseline)
|
||||||
@ -344,7 +344,7 @@ def foreign_fish_detection_chirp(block_map, df, all_contrasts, all_conditions, k
|
|||||||
self_vs_alone_dist = across_group_distance(alone_chirping_snippets, self_snippets)
|
self_vs_alone_dist = across_group_distance(alone_chirping_snippets, self_snippets)
|
||||||
other_vs_baseline_dist = across_group_distance(baseline_snippets, other_snippets)
|
other_vs_baseline_dist = across_group_distance(baseline_snippets, other_snippets)
|
||||||
|
|
||||||
# sort and perfom roc for two comparisons
|
# sort and perfom ROC analysis for two comparisons
|
||||||
# 1. soliloquy vs. self chirping in company
|
# 1. soliloquy vs. self chirping in company
|
||||||
# 2. other chirping vs. nobody is chirping
|
# 2. other chirping vs. nobody is chirping
|
||||||
triangle_indices = np.tril_indices_from(alone_chirping_dist, -1)
|
triangle_indices = np.tril_indices_from(alone_chirping_dist, -1)
|
||||||
@ -381,7 +381,7 @@ def foreign_fish_detection_chirp(block_map, df, all_contrasts, all_conditions, k
|
|||||||
return detection_performances
|
return detection_performances
|
||||||
|
|
||||||
|
|
||||||
def plot_detection_results(data_frame, df, kernel_width, cell):
|
def plot_detection_results(data_frame, df, kernel_width, cell, figure_name=None):
|
||||||
cell_results = data_frame[(data_frame.cell == cell) & (data_frame.df == df)]
|
cell_results = data_frame[(data_frame.cell == cell) & (data_frame.df == df)]
|
||||||
conditions = sorted(cell_results.detection_task.unique())
|
conditions = sorted(cell_results.detection_task.unique())
|
||||||
kernels = sorted(cell_results.kernel_width.unique())
|
kernels = sorted(cell_results.kernel_width.unique())
|
||||||
@ -390,26 +390,27 @@ def plot_detection_results(data_frame, df, kernel_width, cell):
|
|||||||
fig_grid = (8, 7)
|
fig_grid = (8, 7)
|
||||||
for i, c in enumerate(conditions):
|
for i, c in enumerate(conditions):
|
||||||
condition_results = cell_results[cell_results.detection_task == c]
|
condition_results = cell_results[cell_results.detection_task == c]
|
||||||
|
roc_data = condition_results[condition_results.kernel_width == kernel_width]
|
||||||
|
contrasts = roc_data.contrast.unique()
|
||||||
|
|
||||||
roc_ax = plt.subplot2grid(fig_grid, (i * 2 + i, 0), colspan=3, rowspan=2)
|
roc_ax = plt.subplot2grid(fig_grid, (i * 2 + i, 0), colspan=3, rowspan=2)
|
||||||
|
roc_ax.set_title(c, fontsize=9, ha="left")
|
||||||
auc_ax = plt.subplot2grid(fig_grid, (i * 2 + i, 4), colspan=3, rowspan=2)
|
auc_ax = plt.subplot2grid(fig_grid, (i * 2 + i, 4), colspan=3, rowspan=2)
|
||||||
|
|
||||||
roc_data = condition_results[condition_results.kernel_width == kernel_width]
|
|
||||||
|
|
||||||
contrasts = roc_data.contrast.unique()
|
|
||||||
for c in contrasts:
|
for c in contrasts:
|
||||||
tpr = roc_data.true_positives[roc_data.contrast == c].values[0]
|
tpr = roc_data.true_positives[roc_data.contrast == c].values[0]
|
||||||
fpr = roc_data.false_positives[roc_data.contrast == c].values[0]
|
fpr = roc_data.false_positives[roc_data.contrast == c].values[0]
|
||||||
roc_ax.plot(fpr, tpr, label="%.3f" % c, zorder=2)
|
roc_ax.plot(fpr, tpr, label="%.3f" % c, zorder=2)
|
||||||
roc_ax.legend(loc="best", fontsize=6, ncol=2, frameon=False)
|
roc_ax.legend(loc="best", fontsize=6, ncol=2, frameon=False)
|
||||||
roc_ax.plot([0., 1.],[0., 1.], color="k", lw=0.5, ls="--", zorder=0)
|
roc_ax.plot([0., 1.],[0., 1.], color="k", lw=0.5, ls="--", zorder=0)
|
||||||
roc_ax.set_xlabel("false positive rate", fontsize=9)
|
|
||||||
roc_ax.set_ylabel("true positive rate", fontsize=9)
|
|
||||||
roc_ax.set_xticks(np.arange(0.0, 1.01, 0.5))
|
roc_ax.set_xticks(np.arange(0.0, 1.01, 0.5))
|
||||||
roc_ax.set_xticks(np.arange(0.0, 1.01, 0.25), minor=True)
|
roc_ax.set_xticks(np.arange(0.0, 1.01, 0.25), minor=True)
|
||||||
roc_ax.set_xticklabels(np.arange(0.0, 1.01, 0.5), fontsize=8)
|
|
||||||
roc_ax.set_yticks(np.arange(0.0, 1.01, 0.5))
|
roc_ax.set_yticks(np.arange(0.0, 1.01, 0.5))
|
||||||
roc_ax.set_yticks(np.arange(0.0, 1.01, 0.25), minor=True)
|
roc_ax.set_yticks(np.arange(0.0, 1.01, 0.25), minor=True)
|
||||||
|
if i == len(conditions) - 1:
|
||||||
|
roc_ax.set_xticklabels(np.arange(0.0, 1.01, 0.5), fontsize=8)
|
||||||
|
roc_ax.set_xlabel("false positive rate", fontsize=9)
|
||||||
|
roc_ax.set_ylabel("true positive rate", fontsize=9)
|
||||||
roc_ax.set_yticklabels(np.arange(0.0, 1.01, 0.5), fontsize=8)
|
roc_ax.set_yticklabels(np.arange(0.0, 1.01, 0.5), fontsize=8)
|
||||||
|
|
||||||
for k in kernels:
|
for k in kernels:
|
||||||
@ -417,19 +418,25 @@ def plot_detection_results(data_frame, df, kernel_width, cell):
|
|||||||
aucs = np.asarray(condition_results.auc[condition_results.kernel_width == k])
|
aucs = np.asarray(condition_results.auc[condition_results.kernel_width == k])
|
||||||
aucs_sorted = aucs[np.argsort(contrasts)]
|
aucs_sorted = aucs[np.argsort(contrasts)]
|
||||||
contrasts_sorted = np.sort(contrasts)
|
contrasts_sorted = np.sort(contrasts)
|
||||||
auc_ax.plot(contrasts_sorted, aucs_sorted, marker=".", label=r"$\sigma$: %.4f" % k)
|
auc_ax.plot(contrasts_sorted, aucs_sorted, marker=".", label=r"$\sigma$: %.4f" % k, zorder=1)
|
||||||
|
if i == len(conditions) - 1:
|
||||||
auc_ax.set_xlabel("contrast [%]")
|
auc_ax.set_xlabel("contrast [%]", fontsize=9)
|
||||||
|
else:
|
||||||
|
auc_ax.set_xticklabels("")
|
||||||
auc_ax.set_ylim([0.25, 1.0])
|
auc_ax.set_ylim([0.25, 1.0])
|
||||||
auc_ax.set_ylabel("discriminability")
|
auc_ax.set_yticks(np.arange(0.25, 1.01, 0.25))
|
||||||
|
auc_ax.set_yticklabels(np.arange(0.25, 1.01, 0.25), fontsize=8)
|
||||||
|
auc_ax.set_ylabel("discriminability", fontsize=9)
|
||||||
auc_ax.legend(ncol=2, fontsize=6, handletextpad=0.4, columnspacing=1.0, labelspacing=0.25)
|
auc_ax.legend(ncol=2, fontsize=6, handletextpad=0.4, columnspacing=1.0, labelspacing=0.25)
|
||||||
auc_ax.plot([min(contrasts), max(contrasts)], [0.5, 0.5], lw=0.5, ls"--",)
|
auc_ax.plot([min(contrasts), max(contrasts)], [0.5, 0.5], lw=0.5, ls="--", zorder=0)
|
||||||
fig.savefig("discrimination.pdf")
|
name = figure_name if figure_name is not None else "foreign_fish_detection.pdf"
|
||||||
|
name = (name + ".pdf") if ".pdf" not in name else name
|
||||||
|
plt.savefig(os.path.join(figure_folder, name))
|
||||||
|
|
||||||
|
|
||||||
def foreign_fish_detection(block_map, all_dfs, all_contrasts, all_conditions, current_df=None, cell_name=""):
|
def foreign_fish_detection(block_map, all_dfs, all_contrasts, all_conditions, current_df=None, cell_name=""):
|
||||||
dfs = [current_df] if current_df is not None else all_dfs
|
dfs = [current_df] if current_df is not None else all_dfs
|
||||||
kernels = [0.00025, 0.0005, 0.001, 0.0025, 0.005]
|
kernels = [0.00025, 0.0005, 0.001, 0.0025]
|
||||||
result_dicts = []
|
result_dicts = []
|
||||||
for df in dfs:
|
for df in dfs:
|
||||||
for kw in kernels:
|
for kw in kernels:
|
||||||
@ -447,6 +454,11 @@ def foreign_fish_detection(block_map, all_dfs, all_contrasts, all_conditions, cu
|
|||||||
return result_dicts
|
return result_dicts
|
||||||
|
|
||||||
|
|
||||||
|
def estimate_chirp_phase(am, chirp_times):
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def process_cell(filename, dfs=[], contrasts=[], conditions=[]):
|
def process_cell(filename, dfs=[], contrasts=[], conditions=[]):
|
||||||
nf = nix.File.open(filename, nix.FileMode.ReadOnly)
|
nf = nix.File.open(filename, nix.FileMode.ReadOnly)
|
||||||
block_map, all_contrasts, all_dfs, all_conditions = sort_blocks(nf)
|
block_map, all_contrasts, all_dfs, all_conditions = sort_blocks(nf)
|
||||||
|
Loading…
Reference in New Issue
Block a user