celldetective 1.3.2__py3-none-any.whl → 1.3.4__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.
Files changed (41) hide show
  1. celldetective/__main__.py +30 -4
  2. celldetective/_version.py +1 -1
  3. celldetective/extra_properties.py +21 -0
  4. celldetective/filters.py +15 -2
  5. celldetective/gui/InitWindow.py +28 -34
  6. celldetective/gui/analyze_block.py +3 -498
  7. celldetective/gui/classifier_widget.py +1 -1
  8. celldetective/gui/control_panel.py +100 -29
  9. celldetective/gui/generic_signal_plot.py +35 -18
  10. celldetective/gui/gui_utils.py +143 -2
  11. celldetective/gui/layouts.py +7 -6
  12. celldetective/gui/measurement_options.py +38 -43
  13. celldetective/gui/plot_measurements.py +5 -13
  14. celldetective/gui/plot_signals_ui.py +30 -30
  15. celldetective/gui/process_block.py +66 -197
  16. celldetective/gui/retrain_segmentation_model_options.py +3 -1
  17. celldetective/gui/signal_annotator.py +50 -32
  18. celldetective/gui/signal_annotator2.py +7 -4
  19. celldetective/gui/styles.py +13 -0
  20. celldetective/gui/survival_ui.py +8 -21
  21. celldetective/gui/tableUI.py +1 -2
  22. celldetective/gui/thresholds_gui.py +195 -205
  23. celldetective/gui/viewers.py +262 -12
  24. celldetective/io.py +85 -11
  25. celldetective/measure.py +128 -88
  26. celldetective/models/segmentation_effectors/ricm_bf_all_last/config_input.json +79 -0
  27. celldetective/models/segmentation_effectors/ricm_bf_all_last/ricm_bf_all_last +0 -0
  28. celldetective/models/segmentation_effectors/ricm_bf_all_last/training_instructions.json +37 -0
  29. celldetective/models/segmentation_effectors/test-transfer/config_input.json +39 -0
  30. celldetective/models/segmentation_effectors/test-transfer/test-transfer +0 -0
  31. celldetective/neighborhood.py +0 -2
  32. celldetective/scripts/measure_cells.py +21 -9
  33. celldetective/signals.py +77 -66
  34. celldetective/tracking.py +19 -13
  35. {celldetective-1.3.2.dist-info → celldetective-1.3.4.dist-info}/METADATA +12 -10
  36. {celldetective-1.3.2.dist-info → celldetective-1.3.4.dist-info}/RECORD +41 -36
  37. {celldetective-1.3.2.dist-info → celldetective-1.3.4.dist-info}/WHEEL +1 -1
  38. tests/test_qt.py +5 -3
  39. {celldetective-1.3.2.dist-info → celldetective-1.3.4.dist-info}/LICENSE +0 -0
  40. {celldetective-1.3.2.dist-info → celldetective-1.3.4.dist-info}/entry_points.txt +0 -0
  41. {celldetective-1.3.2.dist-info → celldetective-1.3.4.dist-info}/top_level.txt +0 -0
@@ -2213,10 +2213,13 @@ class SignalAnnotator2(QMainWindow,Styles):
2213
2213
  self.index = ind[0]
2214
2214
  elif len(ind)>1:
2215
2215
  # More than one point in vicinity
2216
- datax,datay = [positions[self.framedata][i,0] for i in ind],[positions[self.framedata][i,1] for i in ind]
2217
- msx, msy = event.mouseevent.xdata, event.mouseevent.ydata
2218
- dist = np.sqrt((np.array(datax)-msx)**2+(np.array(datay)-msy)**2)
2219
- self.index = ind[np.argmin(dist)]
2216
+ try:
2217
+ datax,datay = [positions[self.framedata][i,0] for i in ind],[positions[self.framedata][i,1] for i in ind]
2218
+ msx, msy = event.mouseevent.xdata, event.mouseevent.ydata
2219
+ dist = np.sqrt((np.array(datax)-msx)**2+(np.array(datay)-msy)**2)
2220
+ self.index = ind[np.argmin(dist)]
2221
+ except Exception as e:
2222
+ print(f"{e=}")
2220
2223
  else:
2221
2224
  self.index = None
2222
2225
 
@@ -23,6 +23,7 @@ class Styles(object):
23
23
 
24
24
  def init_button_styles(self):
25
25
 
26
+
26
27
  self.button_style_sheet = '''
27
28
  QPushButton {
28
29
  background-color: #1565c0;
@@ -147,6 +148,18 @@ class Styles(object):
147
148
  }
148
149
  '''
149
150
 
151
+ self.menu_check_style = '''
152
+ QCheckBox {
153
+ font-size: 10px;
154
+ padding-left: 10px;
155
+ padding-top: 5px;
156
+ }
157
+ QCheckBox::indicator:unchecked:hover {
158
+ background-color : rgba(189, 189, 189, 1);
159
+ opacity : 0.3;
160
+ }
161
+ '''
162
+
150
163
  self.button_add = '''
151
164
  QPushButton {
152
165
  background-color: transparent;
@@ -39,8 +39,8 @@ class ConfigSurvival(QWidget, Styles):
39
39
  self.float_validator = QDoubleValidator()
40
40
  self.auto_close = False
41
41
 
42
- self.well_option = self.parent_window.parent_window.well_list.currentIndex()
43
- self.position_option = self.parent_window.parent_window.position_list.currentIndex()
42
+ self.well_option = self.parent_window.parent_window.well_list.getSelectedIndices()
43
+ self.position_option = self.parent_window.parent_window.position_list.getSelectedIndices()
44
44
  self.interpret_pos_location()
45
45
  #self.config_path = self.exp_dir + self.config_name
46
46
 
@@ -62,15 +62,10 @@ class ConfigSurvival(QWidget, Styles):
62
62
 
63
63
  """
64
64
 
65
- if self.well_option==len(self.wells):
66
- self.well_indices = np.arange(len(self.wells))
67
- else:
68
- self.well_indices = np.array([self.well_option],dtype=int)
69
-
70
- if self.position_option==0:
65
+ self.well_indices = self.parent_window.parent_window.well_list.getSelectedIndices()
66
+ self.position_indices = self.parent_window.parent_window.position_list.getSelectedIndices()
67
+ if self.position_indices==[]:
71
68
  self.position_indices = None
72
- else:
73
- self.position_indices = np.array([self.position_option],dtype=int)
74
69
 
75
70
 
76
71
  def populate_widget(self):
@@ -243,18 +238,10 @@ class ConfigSurvival(QWidget, Styles):
243
238
 
244
239
  """
245
240
 
246
- self.well_option = self.parent_window.parent_window.well_list.currentIndex()
247
- if self.well_option==len(self.wells):
248
- wo = '*'
249
- else:
250
- wo = self.well_option
251
- self.position_option = self.parent_window.parent_window.position_list.currentIndex()
252
- if self.position_option==0:
253
- po = '*'
254
- else:
255
- po = self.position_option - 1
241
+ self.well_option = self.parent_window.parent_window.well_list.getSelectedIndices()
242
+ self.position_option = self.parent_window.parent_window.position_list.getSelectedIndices()
256
243
 
257
- self.df, self.df_pos_info = load_experiment_tables(self.exp_dir, well_option=wo, position_option=po, population=self.cbs[0].currentText(), return_pos_info=True)
244
+ self.df, self.df_pos_info = load_experiment_tables(self.exp_dir, well_option=self.well_option, position_option=self.position_option, population=self.cbs[0].currentText(), return_pos_info=True)
258
245
  if self.df is None:
259
246
  msgBox = QMessageBox()
260
247
  msgBox.setIcon(QMessageBox.Warning)
@@ -1,5 +1,5 @@
1
1
  from PyQt5.QtWidgets import QRadioButton, QButtonGroup, QMainWindow, QTableView, QAction, QMenu,QFileDialog, QLineEdit, QHBoxLayout, QWidget, QPushButton, QVBoxLayout, QComboBox, QLabel, QCheckBox, QMessageBox
2
- from PyQt5.QtCore import Qt, QAbstractTableModel
2
+ from PyQt5.QtCore import Qt
3
3
  from PyQt5.QtGui import QBrush, QColor, QDoubleValidator
4
4
  import pandas as pd
5
5
  import matplotlib.pyplot as plt
@@ -17,7 +17,6 @@ from superqt import QColormapComboBox, QLabeledSlider, QSearchableComboBox
17
17
  from superqt.fonticon import icon
18
18
  from fonticon_mdi6 import MDI6
19
19
  from math import floor
20
- import re
21
20
 
22
21
  from matplotlib import colormaps
23
22
 
@@ -1,12 +1,6 @@
1
- import math
2
-
3
- import skimage
4
1
  from PyQt5.QtWidgets import QAction, QMenu, QMainWindow, QMessageBox, QLabel, QWidget, QFileDialog, QHBoxLayout, \
5
2
  QGridLayout, QLineEdit, QScrollArea, QVBoxLayout, QComboBox, QPushButton, QApplication, QPushButton, QRadioButton, QButtonGroup
6
3
  from PyQt5.QtGui import QDoubleValidator, QIntValidator
7
- from matplotlib.patches import Circle
8
- from scipy import ndimage
9
- from skimage.morphology import disk
10
4
 
11
5
  from celldetective.filters import std_filter, gauss_filter
12
6
  from celldetective.gui.gui_utils import center_window, FigureCanvas, ListWidget, FilterChoice, color_from_class, help_generic
@@ -1169,202 +1163,198 @@ class ThresholdNormalisation(ThresholdConfigWizard):
1169
1163
  self.close()
1170
1164
 
1171
1165
 
1172
- class ThresholdSpot(ThresholdConfigWizard):
1173
- def __init__(self, current_channel, img, mask, parent_window=None):
1174
- QMainWindow.__init__(self)
1175
- self.parent_window = parent_window
1176
- self.screen_height = self.parent_window.parent_window.parent_window.parent_window.screen_height
1177
- self.screen_width = self.parent_window.parent_window.parent_window.parent_window.screen_width
1178
- self.setMinimumHeight(int(0.8 * self.screen_height))
1179
- self.setWindowTitle("Spot threshold preview")
1180
- center_window(self)
1181
- self.img = img
1182
- self.current_channel = current_channel
1183
- self.mode = self.parent_window.mode
1184
- self.pos = self.parent_window.parent_window.parent_window.pos
1185
- self.exp_dir = self.parent_window.parent_window.exp_dir
1186
- self.onlyFloat = QDoubleValidator()
1187
- self.onlyInt = QIntValidator()
1188
- self.soft_path = get_software_location()
1189
- self.auto_close = False
1190
-
1191
- if self.img is not None:
1192
- print(self.img.shape)
1193
- #self.test_frame = self.img
1194
- self.frame = self.img
1195
- self.test_mask = mask
1196
- self.populate_all()
1197
- self.setAttribute(Qt.WA_DeleteOnClose)
1198
- if self.auto_close:
1199
- self.close()
1200
-
1201
- def populate_left_panel(self):
1202
-
1203
- self.left_layout = QVBoxLayout()
1204
- diameter_layout=QHBoxLayout()
1205
- self.diameter_lbl = QLabel('Spot diameter: ')
1206
- self.diameter_value = QLineEdit()
1207
- self.diameter_value.setText(self.parent_window.diameter_value.text())
1208
- self.diameter_value.setValidator(self.onlyFloat)
1209
- diameter_layout.addWidget(self.diameter_lbl, alignment=Qt.AlignCenter)
1210
- diameter_layout.addWidget(self.diameter_value, alignment=Qt.AlignCenter)
1211
- self.left_layout.addLayout(diameter_layout)
1212
- threshold_layout=QHBoxLayout()
1213
- self.threshold_lbl = QLabel('Spot threshold: ')
1214
- self.threshold_value = QLineEdit()
1215
- self.threshold_value.setValidator(self.onlyFloat)
1216
- self.threshold_value.setText(self.parent_window.threshold_value.text())
1217
- threshold_layout.addWidget(self.threshold_lbl, alignment=Qt.AlignCenter)
1218
- threshold_layout.addWidget(self.threshold_value, alignment=Qt.AlignCenter)
1219
- self.left_layout.addLayout(threshold_layout)
1220
- self.left_panel.addLayout(self.left_layout)
1221
-
1222
- def enable_preview(self):
1223
-
1224
- diam = self.diameter_value.text().replace(',','').replace('.','')
1225
- thresh = self.threshold_value.text().replace(',','').replace('.','')
1226
- if diam.isnumeric() and thresh.isnumeric():
1227
- self.preview_button.setEnabled(True)
1228
- else:
1229
- self.preview_button.setEnabled(False)
1230
-
1231
- def draw_spot_preview(self):
1232
-
1233
- try:
1234
- diameter_value = float(self.parent_window.diameter_value.text().replace(',','.'))
1235
- except:
1236
- print('Diameter could not be converted to float... Abort.')
1237
- self.auto_close = True
1238
- return None
1239
-
1240
- try:
1241
- threshold_value = float(self.parent_window.threshold_value.text().replace(',','.'))
1242
- except:
1243
- print('Threshold could not be converted to float... Abort.')
1244
- self.auto_close = True
1245
- return None
1246
-
1247
- lbl = self.test_mask
1248
- blobs = self.blob_preview(image=self.img[:, :, self.current_channel], label=lbl, threshold=threshold_value,
1249
- diameter=diameter_value)
1250
- mask = np.array([lbl[int(y), int(x)] != 0 for y, x, r in blobs])
1251
- if np.any(mask):
1252
- blobs_filtered = blobs[mask]
1253
- else:
1254
- blobs_filtered=[]
1255
-
1256
- self.fig_contour, self.ax_contour = plt.subplots(figsize=(4, 6))
1257
- self.fcanvas = FigureCanvas(self.fig_contour, title="Blob measurement", interactive=True)
1258
- self.ax_contour.clear()
1259
- self.im = self.ax_contour.imshow(self.img[:, :, self.current_channel], cmap='gray')
1260
- self.circles = [Circle((x, y), r, color='red', fill=False, alpha=0.3) for y, x, r in blobs_filtered]
1261
- for circle in self.circles:
1262
- self.ax_contour.add_artist(circle)
1263
- self.ax_contour.set_xticks([])
1264
- self.ax_contour.set_yticks([])
1265
- self.fig_contour.set_facecolor('none') # or 'None'
1266
- self.fig_contour.canvas.setStyleSheet("background-color: transparent;")
1267
- self.fcanvas.canvas.draw()
1268
-
1269
- def populate_all(self):
1270
- self.button_widget = QWidget()
1271
- main_layout = QVBoxLayout()
1272
- self.button_widget.setLayout(main_layout)
1273
- self.right_panel = QVBoxLayout()
1274
- self.left_panel = QVBoxLayout()
1275
- self.left_panel.setContentsMargins(30, 30, 30, 30)
1276
- self.populate_left_panel()
1277
- self.draw_spot_preview()
1278
- self.setCentralWidget(self.button_widget)
1279
- contrast_slider_layout = QHBoxLayout()
1280
- self.contrast_slider = QLabeledDoubleRangeSlider()
1281
- self.contrast_slider.setSingleStep(0.00001)
1282
- self.contrast_slider.setTickInterval(0.00001)
1283
- self.contrast_slider.setOrientation(1)
1284
- selection = self.frame[:, :, self.current_channel]
1285
- self.contrast_slider.setRange(np.amin(selection[selection==selection]), np.amax(selection[selection==selection]))
1286
- self.contrast_slider.setValue(
1287
- [np.percentile(self.frame[:, :, self.current_channel].flatten(), 1), np.percentile(self.frame[:, :, self.current_channel].flatten(), 99.99)])
1288
- self.contrast_slider.valueChanged.connect(self.contrast_slider_action)
1289
- contrast_label = QLabel("Contrast: ")
1290
- contrast_slider_layout.addWidget(contrast_label)
1291
- contrast_slider_layout.addWidget(self.contrast_slider)
1292
- self.preview_button=QPushButton("Preview")
1293
- self.preview_button.clicked.connect(self.update_spots)
1294
- self.preview_button.setStyleSheet(self.button_style_sheet_2)
1295
- self.apply_changes=QPushButton("Apply")
1296
- self.apply_changes.setStyleSheet(self.button_style_sheet)
1297
- self.apply_changes.clicked.connect(self.apply)
1298
-
1299
- self.diameter_value.textChanged.connect(self.enable_preview)
1300
- self.threshold_value.textChanged.connect(self.enable_preview)
1301
-
1302
- self.right_panel.addWidget(self.fcanvas.canvas)
1303
- self.right_panel.addWidget(self.fcanvas.toolbar)
1304
-
1305
- main_layout.addLayout(self.right_panel)
1306
- main_layout.addLayout(self.left_panel)
1307
- main_layout.addLayout(contrast_slider_layout)
1308
- main_layout.addWidget(self.preview_button)
1309
- main_layout.addWidget(self.apply_changes)
1310
- self.show()
1311
-
1312
- def blob_preview(self, image, label, threshold, diameter):
1313
- removed_background = image.copy()
1314
- dilated_image = ndimage.grey_dilation(label, footprint=disk(10))
1315
- removed_background[np.where(dilated_image == 0)] = 0
1316
- min_sigma = (1 / (1 + math.sqrt(2))) * diameter
1317
- max_sigma = math.sqrt(2) * min_sigma
1318
- blobs = skimage.feature.blob_dog(removed_background, threshold=threshold, min_sigma=min_sigma,
1319
- max_sigma=max_sigma, overlap=0.75)
1320
- return blobs
1321
-
1322
- def update_spots(self):
1323
-
1324
- try:
1325
- diameter_value = float(self.diameter_value.text().replace(',','.'))
1326
- except:
1327
- print('Diameter could not be converted to float... Abort.')
1328
- return None
1329
-
1330
- try:
1331
- threshold_value = float(self.threshold_value.text().replace(',','.'))
1332
- except:
1333
- print('Threshold could not be converted to float... Abort.')
1334
- return None
1335
- xlim = self.ax_contour.get_xlim()
1336
- ylim = self.ax_contour.get_ylim()
1337
- contrast_levels = self.contrast_slider.value()
1338
- blobs = self.blob_preview(image=self.frame[:, :, self.current_channel], label=self.test_mask,
1339
- threshold=threshold_value,
1340
- diameter=diameter_value)
1341
- mask = np.array([self.test_mask[int(y), int(x)] != 0 for y, x, r in blobs])
1342
- if np.any(mask):
1343
- blobs_filtered = blobs[mask]
1344
- else:
1345
- blobs_filtered = []
1346
- self.ax_contour.clear()
1347
- self.im = self.ax_contour.imshow(self.frame[:, :, self.current_channel], cmap='gray')
1348
- self.ax_contour.set_xticks([])
1349
- self.ax_contour.set_yticks([])
1350
- self.circles = [Circle((x, y), r, color='red', fill=False, alpha=0.3) for y, x, r in blobs_filtered]
1351
- for circle in self.circles:
1352
- self.ax_contour.add_artist(circle)
1353
- self.ax_contour.set_xlim(xlim)
1354
- self.ax_contour.set_ylim(ylim)
1355
-
1356
- self.im.set_data(self.frame[:, :, self.current_channel])
1357
- self.fig_contour.canvas.draw()
1358
- self.contrast_slider.setValue(contrast_levels)
1359
-
1360
-
1361
-
1362
-
1363
- def apply(self):
1364
- self.parent_window.threshold_value.setText(self.threshold_value.text())
1365
- self.parent_window.diameter_value.setText(self.diameter_value.text())
1366
- self.close()
1367
-
1368
-
1369
-
1370
-
1166
+ # class ThresholdSpot(ThresholdConfigWizard):
1167
+ # def __init__(self, current_channel, img, mask, parent_window=None):
1168
+ # QMainWindow.__init__(self)
1169
+ # self.parent_window = parent_window
1170
+ # self.screen_height = self.parent_window.parent_window.parent_window.parent_window.screen_height
1171
+ # self.screen_width = self.parent_window.parent_window.parent_window.parent_window.screen_width
1172
+ # self.setMinimumHeight(int(0.8 * self.screen_height))
1173
+ # self.setWindowTitle("Spot threshold preview")
1174
+ # center_window(self)
1175
+ # self.img = img
1176
+ # self.current_channel = current_channel
1177
+ # self.mode = self.parent_window.mode
1178
+ # self.pos = self.parent_window.parent_window.parent_window.pos
1179
+ # self.exp_dir = self.parent_window.parent_window.exp_dir
1180
+ # self.onlyFloat = QDoubleValidator()
1181
+ # self.onlyInt = QIntValidator()
1182
+ # self.soft_path = get_software_location()
1183
+ # self.auto_close = False
1184
+
1185
+ # if self.img is not None:
1186
+ # print(self.img.shape)
1187
+ # #self.test_frame = self.img
1188
+ # self.frame = self.img
1189
+ # self.test_mask = mask
1190
+ # self.populate_all()
1191
+ # self.setAttribute(Qt.WA_DeleteOnClose)
1192
+ # if self.auto_close:
1193
+ # self.close()
1194
+
1195
+ # def populate_left_panel(self):
1196
+
1197
+ # self.left_layout = QVBoxLayout()
1198
+ # diameter_layout=QHBoxLayout()
1199
+ # self.diameter_lbl = QLabel('Spot diameter: ')
1200
+ # self.diameter_value = QLineEdit()
1201
+ # self.diameter_value.setText(self.parent_window.diameter_value.text())
1202
+ # self.diameter_value.setValidator(self.onlyFloat)
1203
+ # diameter_layout.addWidget(self.diameter_lbl, alignment=Qt.AlignCenter)
1204
+ # diameter_layout.addWidget(self.diameter_value, alignment=Qt.AlignCenter)
1205
+ # self.left_layout.addLayout(diameter_layout)
1206
+ # threshold_layout=QHBoxLayout()
1207
+ # self.threshold_lbl = QLabel('Spot threshold: ')
1208
+ # self.threshold_value = QLineEdit()
1209
+ # self.threshold_value.setValidator(self.onlyFloat)
1210
+ # self.threshold_value.setText(self.parent_window.threshold_value.text())
1211
+ # threshold_layout.addWidget(self.threshold_lbl, alignment=Qt.AlignCenter)
1212
+ # threshold_layout.addWidget(self.threshold_value, alignment=Qt.AlignCenter)
1213
+ # self.left_layout.addLayout(threshold_layout)
1214
+ # self.left_panel.addLayout(self.left_layout)
1215
+
1216
+ # def enable_preview(self):
1217
+
1218
+ # diam = self.diameter_value.text().replace(',','').replace('.','')
1219
+ # thresh = self.threshold_value.text().replace(',','').replace('.','')
1220
+ # if diam.isnumeric() and thresh.isnumeric():
1221
+ # self.preview_button.setEnabled(True)
1222
+ # else:
1223
+ # self.preview_button.setEnabled(False)
1224
+
1225
+ # def draw_spot_preview(self):
1226
+
1227
+ # try:
1228
+ # diameter_value = float(self.parent_window.diameter_value.text().replace(',','.'))
1229
+ # except:
1230
+ # print('Diameter could not be converted to float... Abort.')
1231
+ # self.auto_close = True
1232
+ # return None
1233
+
1234
+ # try:
1235
+ # threshold_value = float(self.parent_window.threshold_value.text().replace(',','.'))
1236
+ # except:
1237
+ # print('Threshold could not be converted to float... Abort.')
1238
+ # self.auto_close = True
1239
+ # return None
1240
+
1241
+ # lbl = self.test_mask
1242
+ # blobs = self.blob_preview(image=self.img[:, :, self.current_channel], label=lbl, threshold=threshold_value,
1243
+ # diameter=diameter_value)
1244
+ # mask = np.array([lbl[int(y), int(x)] != 0 for y, x, r in blobs])
1245
+ # if np.any(mask):
1246
+ # blobs_filtered = blobs[mask]
1247
+ # else:
1248
+ # blobs_filtered=[]
1249
+
1250
+ # self.fig_contour, self.ax_contour = plt.subplots(figsize=(4, 6))
1251
+ # self.fcanvas = FigureCanvas(self.fig_contour, title="Blob measurement", interactive=True)
1252
+ # self.ax_contour.clear()
1253
+ # self.im = self.ax_contour.imshow(self.img[:, :, self.current_channel], cmap='gray')
1254
+ # self.circles = [Circle((x, y), r, color='red', fill=False, alpha=0.3) for y, x, r in blobs_filtered]
1255
+ # for circle in self.circles:
1256
+ # self.ax_contour.add_artist(circle)
1257
+ # self.ax_contour.set_xticks([])
1258
+ # self.ax_contour.set_yticks([])
1259
+ # self.fig_contour.set_facecolor('none') # or 'None'
1260
+ # self.fig_contour.canvas.setStyleSheet("background-color: transparent;")
1261
+ # self.fcanvas.canvas.draw()
1262
+
1263
+ # def populate_all(self):
1264
+ # self.button_widget = QWidget()
1265
+ # main_layout = QVBoxLayout()
1266
+ # self.button_widget.setLayout(main_layout)
1267
+ # self.right_panel = QVBoxLayout()
1268
+ # self.left_panel = QVBoxLayout()
1269
+ # self.left_panel.setContentsMargins(30, 30, 30, 30)
1270
+ # self.populate_left_panel()
1271
+ # self.draw_spot_preview()
1272
+ # self.setCentralWidget(self.button_widget)
1273
+ # contrast_slider_layout = QHBoxLayout()
1274
+ # self.contrast_slider = QLabeledDoubleRangeSlider()
1275
+ # self.contrast_slider.setSingleStep(0.00001)
1276
+ # self.contrast_slider.setTickInterval(0.00001)
1277
+ # self.contrast_slider.setOrientation(1)
1278
+ # selection = self.frame[:, :, self.current_channel]
1279
+ # self.contrast_slider.setRange(np.amin(selection[selection==selection]), np.amax(selection[selection==selection]))
1280
+ # self.contrast_slider.setValue(
1281
+ # [np.percentile(self.frame[:, :, self.current_channel].flatten(), 1), np.percentile(self.frame[:, :, self.current_channel].flatten(), 99.99)])
1282
+ # self.contrast_slider.valueChanged.connect(self.contrast_slider_action)
1283
+ # contrast_label = QLabel("Contrast: ")
1284
+ # contrast_slider_layout.addWidget(contrast_label)
1285
+ # contrast_slider_layout.addWidget(self.contrast_slider)
1286
+ # self.preview_button=QPushButton("Preview")
1287
+ # self.preview_button.clicked.connect(self.update_spots)
1288
+ # self.preview_button.setStyleSheet(self.button_style_sheet_2)
1289
+ # self.apply_changes=QPushButton("Apply")
1290
+ # self.apply_changes.setStyleSheet(self.button_style_sheet)
1291
+ # self.apply_changes.clicked.connect(self.apply)
1292
+
1293
+ # self.diameter_value.textChanged.connect(self.enable_preview)
1294
+ # self.threshold_value.textChanged.connect(self.enable_preview)
1295
+
1296
+ # self.right_panel.addWidget(self.fcanvas.canvas)
1297
+ # self.right_panel.addWidget(self.fcanvas.toolbar)
1298
+
1299
+ # main_layout.addLayout(self.right_panel)
1300
+ # main_layout.addLayout(self.left_panel)
1301
+ # main_layout.addLayout(contrast_slider_layout)
1302
+ # main_layout.addWidget(self.preview_button)
1303
+ # main_layout.addWidget(self.apply_changes)
1304
+ # self.show()
1305
+
1306
+ # def blob_preview(self, image, label, threshold, diameter):
1307
+ # removed_background = image.copy()
1308
+ # dilated_image = ndimage.grey_dilation(label, footprint=disk(10))
1309
+ # removed_background[np.where(dilated_image == 0)] = 0
1310
+ # min_sigma = (1 / (1 + math.sqrt(2))) * diameter
1311
+ # max_sigma = math.sqrt(2) * min_sigma
1312
+ # blobs = skimage.feature.blob_dog(removed_background, threshold=threshold, min_sigma=min_sigma,
1313
+ # max_sigma=max_sigma, overlap=0.75)
1314
+ # return blobs
1315
+
1316
+ # def update_spots(self):
1317
+
1318
+ # try:
1319
+ # diameter_value = float(self.diameter_value.text().replace(',','.'))
1320
+ # except:
1321
+ # print('Diameter could not be converted to float... Abort.')
1322
+ # return None
1323
+
1324
+ # try:
1325
+ # threshold_value = float(self.threshold_value.text().replace(',','.'))
1326
+ # except:
1327
+ # print('Threshold could not be converted to float... Abort.')
1328
+ # return None
1329
+ # xlim = self.ax_contour.get_xlim()
1330
+ # ylim = self.ax_contour.get_ylim()
1331
+ # contrast_levels = self.contrast_slider.value()
1332
+ # blobs = self.blob_preview(image=self.frame[:, :, self.current_channel], label=self.test_mask,
1333
+ # threshold=threshold_value,
1334
+ # diameter=diameter_value)
1335
+ # mask = np.array([self.test_mask[int(y), int(x)] != 0 for y, x, r in blobs])
1336
+ # if np.any(mask):
1337
+ # blobs_filtered = blobs[mask]
1338
+ # else:
1339
+ # blobs_filtered = []
1340
+ # self.ax_contour.clear()
1341
+ # self.im = self.ax_contour.imshow(self.frame[:, :, self.current_channel], cmap='gray')
1342
+ # self.ax_contour.set_xticks([])
1343
+ # self.ax_contour.set_yticks([])
1344
+ # self.circles = [Circle((x, y), r, color='red', fill=False, alpha=0.3) for y, x, r in blobs_filtered]
1345
+ # for circle in self.circles:
1346
+ # self.ax_contour.add_artist(circle)
1347
+ # self.ax_contour.set_xlim(xlim)
1348
+ # self.ax_contour.set_ylim(ylim)
1349
+
1350
+ # self.im.set_data(self.frame[:, :, self.current_channel])
1351
+ # self.fig_contour.canvas.draw()
1352
+ # self.contrast_slider.setValue(contrast_levels)
1353
+
1354
+
1355
+
1356
+
1357
+ # def apply(self):
1358
+ # self.parent_window.threshold_value.setText(self.threshold_value.text())
1359
+ # self.parent_window.diameter_value.setText(self.diameter_value.text())
1360
+ # self.close()