From 8f22b7d16d3399192331779637dc736d93e9cab7 Mon Sep 17 00:00:00 2001 From: ferrari <maxence.ferrari@gmail.com> Date: Mon, 15 Mar 2021 18:05:36 +0100 Subject: [PATCH] Make annotated clicks black --- README.md | 1 + ipi_extract.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ae44fd5..76f229a 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ Clicking on the sound signal will select the click that will be analysed. The cl The click will then be displayed in one of the 3 groups of plots selected by the radio button bellow them. While hovering above the signal, the cursor will have the color of the selected group. Clicking on a new click will change the click to be analysed. An already analysed click can be clicked again. +Unselected clicks will be black if any fields have been annotated, and purple otherwise. *Note that a click can be assigned to two groups of plots. This currently cause desyncs in the display of the annotation. In future an update, this might either be fixed, or the possibilities of selecting the same click for multiple groups will be removed* diff --git a/ipi_extract.py b/ipi_extract.py index 079a050..02babc2 100644 --- a/ipi_extract.py +++ b/ipi_extract.py @@ -287,7 +287,10 @@ class Callback(object): pos = int(FSSR*event.xdata) mpos = np.argmax(self.song_resample[max(pos-int(FSSR*FSPK),0):pos+int(FSSR*FSPK)]) + max(pos-int(FSSR*FSPK),0) if self.curr_ind[self.curr] is not None: - self.scat._facecolors[self.curr_ind[self.curr]] = [0.7, 0.2, 0.5, 1] + if np.all(np.isnan(list(self.df[self.offset[self.curr_ind[self.curr], 0]].values()))): + self.scat._facecolors[self.curr_ind[self.curr]] = [0.7, 0.2, 0.5, 1] + else: + self.scat._facecolors[self.curr_ind[self.curr]] = [0, 0, 0, 1] if mpos/FSSR not in self.offset[:,0]: self.offset = np.concatenate([self.offset, [[mpos/FSSR, self.song_resample[mpos]]]], axis=0) self.scat.set_offsets(self.offset) @@ -722,7 +725,11 @@ def main(args): ref_dict['callback'].offset = np.tile(np.array(list(ref_dict['callback'].df.keys()))[:, np.newaxis], (1,2)) ref_dict['callback'].offset[:, 1] = ref_dict['callback'].song_resample[(ref_dict['callback'].offset[:, 1] * FSSR).astype(int)] ref_dict['callback'].scat.set_offsets(ref_dict['callback'].offset) - ref_dict['callback'].scat.set_color(np.array(len(ref_dict['callback'].offset)*[[0.7, 0.2, 0.5, 1]])) + colors = np.array(len(ref_dict['callback'].offset)*[[0.7, 0.2, 0.5, 1]]) + for i, p in enumerate(ref_dict['callback'].offset[:, 0]): + if not np.all(np.isnan(list(ref_dict['callback'].df[p].values()))): + colors[i] = [0, 0, 0, 1] + ref_dict['callback'].scat.set_color(colors) plt.draw() plt.pause(0.2) ref_dict['fig'].set_constrained_layout(False) -- GitLab