Skip to content

Commit

Permalink
Updated gui, various bugfixes dlc 2.0.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexEMG committed Feb 1, 2019
1 parent ec322a9 commit 0197cf5
Show file tree
Hide file tree
Showing 9 changed files with 1,043 additions and 389 deletions.
44 changes: 22 additions & 22 deletions deeplabcut/generate_training_dataset/labeling_toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,12 @@ def __init__(self, parent,config):
widgetsizer.Add(self.save , 1, wx.ALL, 15)
self.save.Bind(wx.EVT_BUTTON, self.saveDataSet)
self.save.Enable(False)
widgetsizer.AddStretchSpacer(15)

widgetsizer.AddStretchSpacer(15)
self.quit = wx.Button(self.widget_panel, id=wx.ID_ANY, label="Quit")
widgetsizer.Add(self.quit , 1, wx.ALL|wx.ALIGN_RIGHT, 15)
self.quit.Bind(wx.EVT_BUTTON, self.quitButton)

self.widget_panel.SetSizer(widgetsizer)
self.widget_panel.SetSizerAndFit(widgetsizer)
self.widget_panel.Layout()
Expand Down Expand Up @@ -253,7 +253,7 @@ def OnSliderScroll(self, event):
"""
MainFrame.saveEachImage(self)
MainFrame.updateZoomPan(self)

self.markerSize = self.slider.GetValue()
img_name = Path(self.index[self.iter]).name
self.axes.clear()
Expand Down Expand Up @@ -285,9 +285,9 @@ def helpButton(self,event):

def homeButton(self,event):
self.toolbar.home()
# if self.pan.GetValue() == True:
# self.toolbar.pan()
# if self.zoom.GetValue() == True:
# if self.pan.GetValue() == True:
# self.toolbar.pan()
# if self.zoom.GetValue() == True:
# self.toolbar.zoom()
MainFrame.updateZoomPan(self)
self.zoom.SetValue(False)
Expand All @@ -299,7 +299,7 @@ def panButton(self,event):
if self.pan.GetValue() == True:
self.toolbar.pan()
self.statusbar.SetStatusText("Pan On")
self.zoom.SetValue(False)
self.zoom.SetValue(False)
else:
self.toolbar.pan()
self.statusbar.SetStatusText("Pan Off")
Expand Down Expand Up @@ -341,7 +341,7 @@ def onClick(self,event):
self.updatedCoords.append(self.dr.coords)
if self.rdb.GetSelection() < len(self.bodyparts) -1:
self.rdb.SetSelection(self.rdb.GetSelection() + 1)

self.canvas.mpl_disconnect(self.onClick)


Expand Down Expand Up @@ -376,7 +376,7 @@ def browseDir(self, event):
self.alpha = self.cfg['alphavalue']
self.colormap = plt.get_cmap(self.cfg['colormap'])
self.project_path=self.cfg['project_path']
self.index =np.sort([fn for fn in glob.glob(os.path.join(self.dir,'*.png')) if ('labeled.png' not in fn)])
self.index =np.sort([fn for fn in glob.glob(os.path.join(self.dir,'*.png')) if ('labeled.png' not in fn)])
#np.sort(glob.glob(os.path.join(self.dir,'*.png')))
#self.labeled_imgs = np.sort(glob.glob(os.path.join(self.dir,'*_labeled.png')))
#self.index = np.sort(list(set(self.index) - set(self.labeled_imgs)))
Expand All @@ -393,7 +393,7 @@ def browseDir(self, event):
self.norm,self.colorIndex = self.image_panel.getColorIndices(self.img,self.bodyparts)

self.flag = 0

# 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')
Expand Down Expand Up @@ -425,7 +425,7 @@ def browseDir(self, event):
# Sort it by the index values
self.dataFrame.sort_index(inplace=True)


# checks for unique bodyparts
if len(self.bodyparts)!=len(set(self.bodyparts)):
print("Error - bodyparts must have unique labels! Please choose unique bodyparts in config.yaml file and try again. Quitting for now!")
Expand All @@ -438,7 +438,7 @@ def browseDir(self, event):
self.new_bodyparts = list(set(self.bodyparts) - set(oldbodyparts2plot))

# Checking if user added a new label
if self.new_bodyparts==[]: # i.e. no new label
if self.new_bodyparts==[]: # i.e. no new label
self.figure,self.axes,self.canvas,self.toolbar = self.image_panel.drawplot(self.img,img_name,self.iter,self.index,self.bodyparts,self.colormap)
self.choiceBox,self.rdb,self.slider,self.checkBox = self.choice_panel.addRadioButtons(self.bodyparts,self.file,self.markerSize)
self.buttonCounter = MainFrame.plot(self,self.img)
Expand All @@ -456,7 +456,7 @@ def browseDir(self, event):
frame = pd.DataFrame(a, columns = index, index = self.relativeimagenames)
self.dataFrame = pd.concat([self.dataFrame, frame],axis=1)


self.figure,self.axes,self.canvas,self.toolbar = self.image_panel.drawplot(self.img,img_name,self.iter,self.index,self.bodyparts,self.colormap)
self.choiceBox,self.rdb,self.slider,self.checkBox = self.choice_panel.addRadioButtons(self.bodyparts,self.file,self.markerSize)
self.cidClick = self.canvas.mpl_connect('button_press_event', self.onClick)
Expand All @@ -474,7 +474,7 @@ def nextImage(self,event):
self.next.Enable(False)
return
self.prev.Enable(True)

# Checks if zoom/pan button is ON
MainFrame.updateZoomPan(self)

Expand All @@ -485,9 +485,9 @@ def nextImage(self,event):
self.axes.clear()
self.buttonCounter = []
MainFrame.saveEachImage(self)

self.iter = self.iter + 1

if len(self.index) >= self.iter:
# self.dr.coords = self.updatedCoords
self.updatedCoords = MainFrame.getLabels(self,self.iter)
Expand Down Expand Up @@ -518,7 +518,7 @@ def prevImage(self, event):
self.buttonCounter = []
self.iter = self.iter - 1


self.rdb.SetSelection(0)
self.img = self.index[self.iter]
img_name = Path(self.index[self.iter]).name
Expand Down Expand Up @@ -606,13 +606,13 @@ def onChecked(self, event):
self.cidClick = self.canvas.mpl_connect('button_press_event', self.onClick)
else:
self.slider.Enable(False)

def updateZoomPan(self):
# Checks if zoom/pan button is ON
if self.pan.GetValue() == True:
self.toolbar.pan()
if self.pan.GetValue() == True:
self.toolbar.pan()
self.pan.SetValue(False)
if self.zoom.GetValue() == True:
if self.zoom.GetValue() == True:
self.toolbar.zoom()
self.zoom.SetValue(False)

Expand Down
Loading

0 comments on commit 0197cf5

Please sign in to comment.