celldetective 1.5.0b1__py3-none-any.whl → 1.5.0b2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
celldetective/_version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "1.5.0b1"
1
+ __version__ = "1.5.0b2"
@@ -21,6 +21,7 @@ from PyQt5.QtWidgets import (
21
21
  QPushButton,
22
22
  QMessageBox,
23
23
  QVBoxLayout,
24
+ QProgressDialog,
24
25
  )
25
26
  from fonticon_mdi6 import MDI6
26
27
  from psutil import cpu_count
@@ -57,6 +58,8 @@ class BackgroundLoader(QThread):
57
58
  import scipy.ndimage
58
59
  import tifffile
59
60
  import numpy
61
+ import napari
62
+ from celldetective.napari.utils import launch_napari_viewer
60
63
  except Exception:
61
64
  logger.error("Background packages not loaded...")
62
65
  logger.info("Background packages loaded...")
@@ -337,14 +340,33 @@ class AppInitWindow(CelldetectiveMainWindow):
337
340
  )
338
341
 
339
342
  def correct_seg_annotation(self):
343
+
340
344
  from celldetective.napari.utils import correct_annotation
341
345
 
342
346
  self.filename, _ = QFileDialog.getOpenFileName(
343
347
  self, "Open Image", "/home/", "TIF Files (*.tif)"
344
348
  )
349
+
345
350
  if self.filename != "":
351
+ # 2. Show progress bar for opening the image in Napari
352
+ progress_open = QProgressDialog(
353
+ f"Opening {os.path.basename(self.filename)} in napari...",
354
+ None,
355
+ 0,
356
+ 0,
357
+ self,
358
+ )
359
+ progress_open.setWindowTitle("Please wait")
360
+ progress_open.setWindowModality(Qt.WindowModal)
361
+ progress_open.setMinimumDuration(0)
362
+ progress_open.show()
363
+ QApplication.processEvents()
364
+
346
365
  logger.info(f"Opening {self.filename} in napari...")
347
- correct_annotation(self.filename)
366
+ try:
367
+ correct_annotation(self.filename)
368
+ finally:
369
+ progress_open.close()
348
370
  else:
349
371
  return None
350
372
 
@@ -11,11 +11,13 @@ from PyQt5.QtWidgets import (
11
11
  QStylePainter,
12
12
  QStyleOptionComboBox,
13
13
  QStyle,
14
- QFrame,
15
14
  QSizePolicy,
16
15
  QProgressDialog,
16
+ QPushButton,
17
+ QFrame,
17
18
  )
18
19
  from PyQt5.QtCore import Qt, pyqtSignal, QEvent
20
+ from superqt.fonticon import icon
19
21
  from celldetective.gui.base.styles import Styles
20
22
 
21
23
 
@@ -247,3 +249,20 @@ class QHSeperationLine(QFrame):
247
249
  self.setFrameShape(QFrame.HLine)
248
250
  self.setFrameShadow(QFrame.Sunken)
249
251
  self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Minimum)
252
+
253
+
254
+ class HoverButton(QPushButton):
255
+ def __init__(self, text, icon_enum, default_color="black", hover_color="white"):
256
+ super().__init__(text)
257
+ self.icon_enum = icon_enum
258
+ self.default_color = default_color
259
+ self.hover_color = hover_color
260
+ self.setIcon(icon(self.icon_enum, color=self.default_color))
261
+
262
+ def enterEvent(self, event):
263
+ self.setIcon(icon(self.icon_enum, color=self.hover_color))
264
+ super().enterEvent(event)
265
+
266
+ def leaveEvent(self, event):
267
+ self.setIcon(icon(self.icon_enum, color=self.default_color))
268
+ super().leaveEvent(event)
@@ -47,6 +47,9 @@ from celldetective.gui.gui_utils import (
47
47
  from celldetective.gui.base.figure_canvas import FigureCanvas
48
48
  from celldetective.gui.base.utils import center_window
49
49
  import gc
50
+ from celldetective import get_logger
51
+
52
+ logger = get_logger(__name__)
50
53
 
51
54
 
52
55
  class BaseAnnotator(CelldetectiveMainWindow, Styles):
@@ -364,7 +367,7 @@ class BaseAnnotator(CelldetectiveMainWindow, Styles):
364
367
  self.correct_btn.disconnect()
365
368
  self.correct_btn.clicked.connect(self.show_annotation_buttons)
366
369
 
367
- print(f"{self.selection=}")
370
+ logger.info(f"{self.selection=}")
368
371
 
369
372
  ind = event.ind
370
373
 
@@ -711,7 +714,7 @@ class BaseAnnotator(CelldetectiveMainWindow, Styles):
711
714
  try:
712
715
  self.df_tracks = self.df_tracks.drop([c], axis=1)
713
716
  except Exception as e:
714
- print(e)
717
+ logger.error(e)
715
718
  item_idx = self.class_choice_cb.findText(class_to_delete)
716
719
  self.class_choice_cb.removeItem(item_idx)
717
720
 
@@ -755,7 +758,7 @@ class BaseAnnotator(CelldetectiveMainWindow, Styles):
755
758
  self.log_btn.setIcon(icon(MDI6.math_log, color="black"))
756
759
  self.log_scale = False
757
760
  except Exception as e:
758
- print(e)
761
+ logger.error(e)
759
762
 
760
763
  # self.cell_ax.autoscale()
761
764
  self.cell_fcanvas.canvas.draw_idle()
@@ -839,9 +842,9 @@ class BaseAnnotator(CelldetectiveMainWindow, Styles):
839
842
  pathsave += ".npy"
840
843
  try:
841
844
  np.save(pathsave, training_set)
842
- print(f"File successfully written in {pathsave}.")
845
+ logger.info(f"File successfully written in {pathsave}.")
843
846
  except Exception as e:
844
- print(f"Error {e}...")
847
+ logger.error(f"Error {e}...")
845
848
 
846
849
  def create_new_event_class(self):
847
850
 
@@ -897,10 +900,11 @@ class BaseAnnotator(CelldetectiveMainWindow, Styles):
897
900
 
898
901
  def save_trajectories(self):
899
902
  # specific to signal/static annotator
900
- print("Save trajectory function not implemented for BaseAnnotator class...")
903
+ logger.info(
904
+ "Save trajectory function not implemented for BaseAnnotator class..."
905
+ )
901
906
 
902
907
  def cancel_selection(self):
903
- print("we are in cancel selection...")
904
908
  self.hide_annotation_buttons()
905
909
  self.correct_btn.setEnabled(False)
906
910
  self.correct_btn.setText("correct")