Skip to content

Commit

Permalink
fix: auto fill holes, closes #349
Browse files Browse the repository at this point in the history
  • Loading branch information
ElpadoCan committed Jun 13, 2023
1 parent 51be845 commit 4d579ce
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions cellacdc/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class FilterBaseDialog(QDialog):
sigClose = Signal(object)
sigApplyFilter = Signal(str)
sigPreviewToggled = Signal(bool, str)
sigPreviewToggled = Signal(bool, object, str)

def __init__(
self, layersChannelNames, winTitle, parent=None,
Expand Down Expand Up @@ -50,7 +50,7 @@ def addChannelName(self, newChannelName):

def preview_cb(self, checked):
channelName = self.channelsComboBox.currentText()
self.sigPreviewToggled.emit(checked, channelName)
self.sigPreviewToggled.emit(checked, self, channelName)

def apply(self):
channelName = self.channelsComboBox.currentText()
Expand Down
13 changes: 9 additions & 4 deletions cellacdc/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -5346,7 +5346,10 @@ def fillHolesID(self, ID, sender='brush'):
obj = posData.rp[obj_idx]
objMask = self.getObjImage(obj.image, obj.bbox)
localFill = scipy.ndimage.binary_fill_holes(objMask)
posData.lab[self.getObjSlice(obj.slice)][localFill] = ID
objSlice = self.getObjSlice(obj.slice)
lab2D = self.get_2Dlab(posData.lab)
lab2D[objSlice][localFill] = ID
self.set_2Dlab(lab2D)
self.update_rp()

def highlightIDcheckBoxToggled(self, checked):
Expand Down Expand Up @@ -15266,8 +15269,8 @@ def applyBrushMask(self, mask, ID, toLocalSlice=None):
else:
if toLocalSlice is not None:
for z in range(len(posData.lab)):
toLocalSlice = (z, *toLocalSlice)
posData.lab[toLocalSlice][mask] = ID
_slice = (z, *toLocalSlice)
posData.lab[_slice][mask] = ID
else:
posData.lab[:, mask] = ID
else:
Expand Down Expand Up @@ -19269,6 +19272,7 @@ def loadingDataAborted(self):
self.titleLabel.setText('Loading data aborted.')

def cleanUpOnError(self):
self.onEscape()
txt = 'WARNING: Cell-ACDC is in error state. Please, restart.'
_hl = '===================================='
self.titleLabel.setText(txt, color='r')
Expand Down Expand Up @@ -21213,7 +21217,8 @@ def clearMemory(self):
def onEscape(self):
self.setUncheckedAllButtons()
self.setUncheckedAllCustomAnnotButtons()
self.tempLayerImg1.setImage(self.emptyLab)
if hasattr(self, 'tempLayerImg1'):
self.tempLayerImg1.setImage(self.emptyLab)
self.isMouseDragImg1 = False
self.typingEditID = False
if self.highlightedID != 0:
Expand Down
2 changes: 1 addition & 1 deletion cellacdc/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1386,7 +1386,7 @@ class VerticalResizeHline(QFrame):

def __init__(self):
super().__init__()
self.setCursor(Qt.SizeVerCursor)
self.setCursor(Qt.SplitVCursor)
self.setFrameShape(QFrame.Shape.HLine)
self.setFrameShadow(QFrame.Shadow.Sunken)
self.installEventFilter(self)
Expand Down

0 comments on commit 4d579ce

Please sign in to comment.