How to use the deeplabcut.generate_training_dataset.multiple_individual_labeling_toolbox.MainFrame function in deeplabcut

To help you get started, we’ve selected a few deeplabcut examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AlexEMG / DeepLabCut / deeplabcut / generate_training_dataset / multiple_individual_labeling_toolbox.py View on Github external
MainFrame.updateZoomPan(self)
        self.statusbar.SetStatusText('Working on folder: {}'.format(os.path.split(str(self.dir))[-1]))
        
        MainFrame.saveEachImage(self)
        self.buttonCounter = {i : [] for i in self.individual_names}
        self.iter = self.iter - 1

        self.rdb.SetSelection(0)
        self.individualrdb.SetSelection(0)
        self.updatedCoords = []
        self.img = self.index[self.iter]
        img_name = Path(self.index[self.iter]).name
        self.figure,self.axes,self.canvas,self.toolbar,self.image_axis = self.image_panel.drawplot(self.img,img_name,self.iter,self.index,self.multibodyparts,self.colormap,keep_view=self.view_locked)
        self.axes.callbacks.connect('xlim_changed', self.onZoom)
        self.axes.callbacks.connect('ylim_changed', self.onZoom)
        self.buttonCounter  = MainFrame.plot(self,self.img)

        self.cidClick = self.canvas.mpl_connect('button_press_event', self.onClick)
github AlexEMG / DeepLabCut / deeplabcut / generate_training_dataset / multiple_individual_labeling_toolbox.py View on Github external
"""
#        MainFrame.saveDataSet(self, event)
        self.statusbar.SetStatusText("Quitting now!")
        
        nextFilemsg = wx.MessageBox('Do you want to label another data set?', 'Repeat?', wx.YES_NO | wx.ICON_INFORMATION)
        if nextFilemsg == 2:
            self.file = 1
            self.buttonCounter = {i : [] for i in self.individual_names}
            self.updatedCoords = []
            self.dataFrame = None
            self.multibodyparts = []
            self.new_labels = self.new_labels
            self.axes.clear()
            self.figure.delaxes(self.figure.axes[1]) 
            self.choiceBox.Clear(True)
            MainFrame.updateZoomPan(self)
            MainFrame.browseDir(self, event)
        else:
            self.Destroy()
            print("You can now check the labels, using 'check_labels' before proceeding. Then,  you can use the function 'create_training_dataset' to create the training dataset.")
github AlexEMG / DeepLabCut / deeplabcut / generate_training_dataset / multiple_individual_labeling_toolbox.py View on Github external
def show(config):
    app = wx.App()
    frame = MainFrame(None,config).Show()
    app.MainLoop()
github AlexEMG / DeepLabCut / deeplabcut / generate_training_dataset / multiple_individual_labeling_toolbox.py View on Github external
def saveDataSet(self,event):
        """
        Saves the final dataframe
        """
        self.statusbar.SetStatusText("File saved")
        MainFrame.saveEachImage(self)
        MainFrame.updateZoomPan(self)
        # Windows compatible
        self.dataFrame.sort_index(inplace=True)
        self.dataFrame.to_csv(os.path.join(self.dir,"CollectedData_" + self.scorer + ".csv"))
        self.dataFrame.to_hdf(os.path.join(self.dir,"CollectedData_" + self.scorer + '.h5'),'df_with_missing',format='table', mode='w')
github AlexEMG / DeepLabCut / deeplabcut / generate_training_dataset / multiple_individual_labeling_toolbox.py View on Github external
def saveDataSet(self,event):
        """
        Saves the final dataframe
        """
        self.statusbar.SetStatusText("File saved")
        MainFrame.saveEachImage(self)
        MainFrame.updateZoomPan(self)
        # Windows compatible
        self.dataFrame.sort_index(inplace=True)
        self.dataFrame.to_csv(os.path.join(self.dir,"CollectedData_" + self.scorer + ".csv"))
        self.dataFrame.to_hdf(os.path.join(self.dir,"CollectedData_" + self.scorer + '.h5'),'df_with_missing',format='table', mode='w')
github AlexEMG / DeepLabCut / deeplabcut / generate_training_dataset / multiple_individual_labeling_toolbox.py View on Github external
#        MainFrame.saveDataSet(self, event)
        self.statusbar.SetStatusText("Quitting now!")
        
        nextFilemsg = wx.MessageBox('Do you want to label another data set?', 'Repeat?', wx.YES_NO | wx.ICON_INFORMATION)
        if nextFilemsg == 2:
            self.file = 1
            self.buttonCounter = {i : [] for i in self.individual_names}
            self.updatedCoords = []
            self.dataFrame = None
            self.multibodyparts = []
            self.new_labels = self.new_labels
            self.axes.clear()
            self.figure.delaxes(self.figure.axes[1]) 
            self.choiceBox.Clear(True)
            MainFrame.updateZoomPan(self)
            MainFrame.browseDir(self, event)
        else:
            self.Destroy()
            print("You can now check the labels, using 'check_labels' before proceeding. Then,  you can use the function 'create_training_dataset' to create the training dataset.")
github AlexEMG / DeepLabCut / deeplabcut / generate_training_dataset / multiple_individual_labeling_toolbox.py View on Github external
self.num.append(circle)
                    self.axes.add_patch(circle[0])
                    self.dr = auxfun_drag_label_multiple_individuals.DraggablePoint(circle[0],self.individual_names[self.individualrdb.GetSelection()],self.multibodyparts[self.rdb.GetSelection()])
                    self.dr.connect()
                    self.buttonCounter[self.individual_names[self.individualrdb.GetSelection()]].append(self.multibodyparts[self.rdb.GetSelection()])
                    self.dr.coords = [[x1,y1,self.individual_names[self.individualrdb.GetSelection()],self.multibodyparts[self.rdb.GetSelection()]]]
                    self.drs.append(self.dr)
                    self.updatedCoords.append(self.dr.coords)

                    if self.rdb.GetSelection() < len(self.multibodyparts) - 1:
                        self.rdb.SetSelection(self.rdb.GetSelection() + 1)
                    else:
                        self.rdb.SetSelection(0)
                        if self.individualrdb.GetSelection() < len(self.individual_names) -1:
                            self.individualrdb.SetSelection(self.individualrdb.GetSelection() + 1)
                        MainFrame.select_individual(self,event)
        self.canvas.mpl_disconnect(self.onClick)
github AlexEMG / DeepLabCut / deeplabcut / generate_training_dataset / multiple_individual_labeling_toolbox.py View on Github external
else:
                for c, bp in enumerate(self.multibodyparts):
                    image_points = [[self.dataFrame[self.scorer][ind][bp]['x'].values[self.iter],self.dataFrame[self.scorer][ind][bp]['y'].values[self.iter],ind,bp]]
                    self.points = [self.dataFrame[self.scorer][ind][bp]['x'].values[self.iter],self.dataFrame[self.scorer][ind][bp]['y'].values[self.iter]]
                    self.norm,self.colorIndex = self.image_panel.getColorIndices(self.img,self.multibodyparts)
                    color = self.colormap(self.norm(self.colorIndex[c]))
                    circle = patches.Circle((self.points[0], self.points[1]), radius=self.markerSize, fc = color, alpha=self.alpha)
                    self.axes.add_patch(circle)
                    self.dr = auxfun_drag_label_multiple_individuals.DraggablePoint(circle,ind,self.multibodyparts[c])
                    self.dr.connect()
                    self.dr.coords = image_points
                    self.drs.append(self.dr)
                    self.updatedCoords.append(self.dr.coords)
                    if np.isnan(self.points)[0] == False:
                        self.buttonCounter[ind].append(self.multibodyparts[c])
            MainFrame.saveEachImage(self)
        self.figure.canvas.draw()
        return(self.buttonCounter)
github AlexEMG / DeepLabCut / deeplabcut / generate_training_dataset / multiple_individual_labeling_toolbox.py View on Github external
# Reading the existing dataset,if already present
        try:
            self.dataFrame = pd.read_hdf(os.path.join(self.dir,'CollectedData_'+self.scorer+'.h5'),'df_with_missing')
            self.dataFrame.sort_index(inplace=True)
            self.prev.Enable(True)
# Finds the first empty row in the dataframe and sets the iteration to that index
            for idx,j in enumerate(self.dataFrame.index):
                values = self.dataFrame.loc[j,:].values
                if np.prod(np.isnan(values)) == 1:
                    self.iter = idx
                    break
                else:
                    self.iter = idx
        except:
            #Create an empty data frame
            self.dataFrame = MainFrame.create_dataframe(self,self.dataFrame,self.relativeimagenames,self.individual_names,self.uniquebodyparts,self.multibodyparts)
            self.iter = 0

        # Reading the image name
        self.img = self.index[self.iter]
        img_name = Path(self.index[self.iter]).name

        # Checking for new frames and adding them to the existing dataframe
        old_imgs = np.sort(list(self.dataFrame.index))
        self.newimages = list(set(self.relativeimagenames) - set(old_imgs))
        if self.newimages == []:
            pass
        else:
            print("Found new frames..")
            # Create an empty dataframe with all the new images and then merge this to the existing dataframe.
            self.df = MainFrame.create_dataframe(self,None,self.newimages,self.individual_names,self.uniquebodyparts,self.multibodyparts)
            self.dataFrame = pd.concat([self.dataFrame, self.df],axis=0)