MCPcopy Create free account
hub / github.com/DeepLabCut/DeepLabCut / on_pick

Method on_pick

deeplabcut/gui/tracklet_toolbox.py:686–730  ·  view source on GitHub ↗
(self, event)

Source from the content-addressed store, hash-verified

684 self.slider.set_val(self.curr_frame)
685
686 def on_pick(self, event):
687 artist = event.artist
688 if artist.axes == self.ax1:
689 self.picked = list(event.ind)
690 elif artist.axes == self.ax2:
691 if isinstance(artist, plt.Line2D):
692 self.picked = [self.lines_x.index(artist)]
693 elif artist.axes == self.ax3:
694 if isinstance(artist, plt.Line2D):
695 self.picked = [self.lines_y.index(artist)]
696 else: # Click on the legend lines
697 if self.picked:
698 num_individual = self.leg.get_lines().index(artist)
699 nrow = self.manager.tracklet2id.index(num_individual)
700 inds = [nrow + self.manager.to_num_bodypart(pick) for pick in self.picked]
701 xy = self.manager.xy[self.picked]
702 p = self.manager.prob[self.picked]
703 mask = np.zeros(xy.shape[1], dtype=bool)
704 if len(self.cuts) > 1:
705 mask[self.cuts[-2] : self.cuts[-1] + 1] = True
706 self.cuts = []
707 for line in self.ax_slider.lines:
708 line.remove()
709 self.clean_collections()
710 else:
711 return
712 sl_inds = np.ix_(inds, mask)
713 sl_picks = np.ix_(self.picked, mask)
714 old_xy = self.manager.xy[sl_inds].copy()
715 old_prob = self.manager.prob[sl_inds].copy()
716 self.manager.xy[sl_inds] = xy[:, mask]
717 self.manager.prob[sl_inds] = p[:, mask]
718 self.manager.xy[sl_picks] = old_xy
719 self.manager.prob[sl_picks] = old_prob
720 self.picked_pair = []
721 if len(self.picked) == 1:
722 for pair in self.manager.swapping_pairs:
723 if self.picked[0] in pair:
724 self.picked_pair = pair
725 break
726 self.clean_collections()
727 self.display_traces()
728 if self.picked_pair:
729 self.fill_shaded_areas()
730 self.slider.set_val(self.curr_frame)
731
732 def on_click(self, event):
733 if (

Callers

nothing calls this directly

Calls 5

clean_collectionsMethod · 0.95
display_tracesMethod · 0.95
fill_shaded_areasMethod · 0.95
to_num_bodypartMethod · 0.80
removeMethod · 0.80

Tested by

no test coverage detected