celldetective 1.3.9.post4__py3-none-any.whl → 1.4.0__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 (57) hide show
  1. celldetective/__init__.py +0 -3
  2. celldetective/_version.py +1 -1
  3. celldetective/events.py +2 -4
  4. celldetective/extra_properties.py +320 -24
  5. celldetective/gui/InitWindow.py +33 -45
  6. celldetective/gui/__init__.py +1 -0
  7. celldetective/gui/about.py +19 -15
  8. celldetective/gui/analyze_block.py +34 -19
  9. celldetective/gui/base_components.py +23 -0
  10. celldetective/gui/btrack_options.py +26 -34
  11. celldetective/gui/classifier_widget.py +71 -80
  12. celldetective/gui/configure_new_exp.py +113 -17
  13. celldetective/gui/control_panel.py +68 -141
  14. celldetective/gui/generic_signal_plot.py +9 -12
  15. celldetective/gui/gui_utils.py +49 -21
  16. celldetective/gui/json_readers.py +5 -4
  17. celldetective/gui/layouts.py +246 -22
  18. celldetective/gui/measurement_options.py +32 -17
  19. celldetective/gui/neighborhood_options.py +10 -13
  20. celldetective/gui/plot_measurements.py +21 -17
  21. celldetective/gui/plot_signals_ui.py +131 -75
  22. celldetective/gui/process_block.py +180 -123
  23. celldetective/gui/processes/compute_neighborhood.py +594 -0
  24. celldetective/gui/processes/measure_cells.py +5 -0
  25. celldetective/gui/processes/segment_cells.py +27 -6
  26. celldetective/gui/processes/track_cells.py +6 -0
  27. celldetective/gui/retrain_segmentation_model_options.py +12 -20
  28. celldetective/gui/retrain_signal_model_options.py +57 -56
  29. celldetective/gui/seg_model_loader.py +21 -62
  30. celldetective/gui/signal_annotator.py +139 -72
  31. celldetective/gui/signal_annotator2.py +431 -635
  32. celldetective/gui/signal_annotator_options.py +8 -11
  33. celldetective/gui/survival_ui.py +49 -95
  34. celldetective/gui/tableUI.py +28 -25
  35. celldetective/gui/thresholds_gui.py +617 -1221
  36. celldetective/gui/viewers.py +106 -39
  37. celldetective/gui/workers.py +9 -3
  38. celldetective/io.py +73 -27
  39. celldetective/measure.py +63 -27
  40. celldetective/neighborhood.py +342 -268
  41. celldetective/preprocessing.py +25 -17
  42. celldetective/relative_measurements.py +50 -29
  43. celldetective/scripts/analyze_signals.py +4 -1
  44. celldetective/scripts/measure_relative.py +4 -1
  45. celldetective/scripts/segment_cells.py +0 -6
  46. celldetective/scripts/track_cells.py +3 -1
  47. celldetective/scripts/train_segmentation_model.py +7 -4
  48. celldetective/signals.py +29 -14
  49. celldetective/tracking.py +7 -2
  50. celldetective/utils.py +36 -8
  51. {celldetective-1.3.9.post4.dist-info → celldetective-1.4.0.dist-info}/METADATA +24 -16
  52. {celldetective-1.3.9.post4.dist-info → celldetective-1.4.0.dist-info}/RECORD +57 -55
  53. {celldetective-1.3.9.post4.dist-info → celldetective-1.4.0.dist-info}/WHEEL +1 -1
  54. tests/test_qt.py +21 -21
  55. {celldetective-1.3.9.post4.dist-info → celldetective-1.4.0.dist-info}/entry_points.txt +0 -0
  56. {celldetective-1.3.9.post4.dist-info → celldetective-1.4.0.dist-info/licenses}/LICENSE +0 -0
  57. {celldetective-1.3.9.post4.dist-info → celldetective-1.4.0.dist-info}/top_level.txt +0 -0
@@ -1,10 +1,12 @@
1
- from PyQt5.QtWidgets import QMainWindow, QPushButton, QHBoxLayout, QLabel, QWidget, QGridLayout, QFrame, \
2
- QTabWidget, QVBoxLayout, QMessageBox, QScrollArea, QDesktopWidget
1
+ from PyQt5.QtWidgets import QPushButton, QHBoxLayout, QLabel, QGridLayout, QFrame, \
2
+ QTabWidget, QVBoxLayout, QScrollArea, QDesktopWidget
3
+ from celldetective.gui import CelldetectiveMainWindow, CelldetectiveWidget
4
+
3
5
  from PyQt5.QtCore import Qt, QSize
4
- from celldetective.gui.gui_utils import center_window, QHSeperationLine, QCheckableComboBox
5
- from celldetective.utils import _extract_labels_from_config, ConfigSectionMap, extract_experiment_channels, extract_identity_col
6
+ from celldetective.gui.gui_utils import center_window, QHSeperationLine, QCheckableComboBox, generic_message
7
+ from celldetective.utils import _extract_labels_from_config, ConfigSectionMap, extract_identity_col
6
8
  from celldetective.gui import ConfigEditor, ProcessPanel, PreprocessingPanel, AnalysisPanel, NeighPanel
7
- from celldetective.io import get_experiment_wells, get_config, get_spatial_calibration, get_temporal_calibration, get_experiment_concentrations, get_experiment_cell_types, get_experiment_antibodies, get_experiment_pharmaceutical_agents
9
+ from celldetective.io import extract_position_name, get_experiment_wells, get_config, get_spatial_calibration, get_temporal_calibration, get_experiment_concentrations, get_experiment_cell_types, get_experiment_antibodies, get_experiment_pharmaceutical_agents, get_experiment_populations, extract_well_name_and_number
8
10
  from natsort import natsorted
9
11
  from glob import glob
10
12
  import os
@@ -15,11 +17,10 @@ import gc
15
17
  import subprocess
16
18
  from celldetective.gui.viewers import StackVisualizer
17
19
  from celldetective.utils import extract_experiment_channels
18
- from celldetective.gui import Styles
19
20
  import pandas as pd
20
21
 
21
22
 
22
- class ControlPanel(QMainWindow, Styles):
23
+ class ControlPanel(CelldetectiveMainWindow):
23
24
 
24
25
  def __init__(self, parent_window=None, exp_dir=""):
25
26
 
@@ -29,21 +30,20 @@ class ControlPanel(QMainWindow, Styles):
29
30
  if not self.exp_dir.endswith(os.sep):
30
31
  self.exp_dir = self.exp_dir+os.sep
31
32
  self.setWindowTitle("celldetective")
32
- self.setWindowIcon(self.celldetective_icon)
33
33
  self.parent_window = parent_window
34
34
 
35
35
  self.init_wells_and_positions()
36
36
  self.load_configuration()
37
37
 
38
- self.w = QWidget()
38
+ self.w = CelldetectiveWidget()
39
39
  self.grid = QGridLayout(self.w)
40
40
  self.grid.setSpacing(5)
41
- self.grid.setContentsMargins(10,10,10,10) #left top right bottom
41
+ self.grid.setContentsMargins(10, 10, 10, 10) # left top right bottom
42
42
 
43
43
  self.to_disable = []
44
44
  self.generate_header()
45
- self.ProcessEffectors = ProcessPanel(self,'effectors')
46
- self.ProcessTargets = ProcessPanel(self,'targets')
45
+ self.ProcessPopulations = [ProcessPanel(self, pop) for pop in self.populations]
46
+
47
47
  self.NeighPanel = NeighPanel(self)
48
48
  self.PreprocessingPanel = PreprocessingPanel(self)
49
49
 
@@ -57,9 +57,10 @@ class ControlPanel(QMainWindow, Styles):
57
57
  self.SurvivalBlock = AnalysisPanel(self,title='Survival')
58
58
 
59
59
  grid_process.addWidget(self.PreprocessingPanel)
60
- grid_process.addWidget(self.ProcessEffectors)
61
- grid_process.addWidget(self.ProcessTargets)
60
+ for panel in self.ProcessPopulations:
61
+ grid_process.addWidget(panel)
62
62
  grid_process.addWidget(self.NeighPanel)
63
+
63
64
  grid_analyze.addWidget(self.SurvivalBlock)
64
65
 
65
66
  self.scroll=QScrollArea()
@@ -92,7 +93,6 @@ class ControlPanel(QMainWindow, Styles):
92
93
  self.screen_width = desktop.screenGeometry().width()
93
94
  self.scroll.setMinimumWidth(440)
94
95
 
95
- self.setAttribute(Qt.WA_DeleteOnClose)
96
96
  center_window(self)
97
97
 
98
98
 
@@ -108,11 +108,9 @@ class ControlPanel(QMainWindow, Styles):
108
108
  self.wells = get_experiment_wells(self.exp_dir) #natsorted(glob(self.exp_dir + "W*" + os.sep))
109
109
  self.positions = []
110
110
  for w in self.wells:
111
- w = os.path.split(w[:-1])
112
- root = w[0]
113
- w = w[1]
114
- positions_path = natsorted(glob(os.sep.join([root, w, f"{w[1:]}*{os.sep}"])))
115
- self.positions.append([os.path.split(pos[:-1])[1] for pos in positions_path])
111
+ well_name, well_nbr = extract_well_name_and_number(w)
112
+ positions_path = natsorted(glob(os.sep.join([w,f"{well_nbr}*", os.sep])))
113
+ self.positions.append([extract_position_name(pos) for pos in positions_path])
116
114
 
117
115
  def generate_header(self):
118
116
 
@@ -274,15 +272,9 @@ class ControlPanel(QMainWindow, Styles):
274
272
  movies = glob(self.pos + os.sep.join(['movie', f"{self.movie_prefix}*.tif"]))
275
273
 
276
274
  if len(movies) == 0:
277
- msgBox = QMessageBox()
278
- msgBox.setIcon(QMessageBox.Warning)
279
- msgBox.setText("Please select a position containing a movie...")
280
- msgBox.setWindowTitle("Warning")
281
- msgBox.setStandardButtons(QMessageBox.Ok)
282
- returnValue = msgBox.exec()
283
- if returnValue == QMessageBox.Ok:
284
- self.current_stack = None
285
- return None
275
+ generic_message("Please select a position containing a movie...")
276
+ self.current_stack = None
277
+ return None
286
278
  else:
287
279
  self.current_stack = movies[0]
288
280
 
@@ -321,9 +313,11 @@ class ControlPanel(QMainWindow, Styles):
321
313
  print('Reading experiment configuration...')
322
314
  self.exp_config = get_config(self.exp_dir)
323
315
 
316
+ self.populations = get_experiment_populations(self.exp_dir)
324
317
  self.PxToUm = get_spatial_calibration(self.exp_dir)
325
318
  self.FrameToMin = get_temporal_calibration(self.exp_dir)
326
319
 
320
+
327
321
  self.len_movie = int(ConfigSectionMap(self.exp_config,"MovieSettings")["len_movie"])
328
322
  self.shape_x = int(ConfigSectionMap(self.exp_config,"MovieSettings")["shape_x"])
329
323
  self.shape_y = int(ConfigSectionMap(self.exp_config,"MovieSettings")["shape_y"])
@@ -350,7 +344,7 @@ class ControlPanel(QMainWindow, Styles):
350
344
  Close child windows if closed.
351
345
  """
352
346
 
353
- for process_block in [self.ProcessTargets, self.ProcessEffectors]:
347
+ for process_block in self.ProcessPopulations:
354
348
  try:
355
349
  if process_block.SegModelLoader:
356
350
  process_block.SegModelLoader.close()
@@ -436,14 +430,8 @@ class ControlPanel(QMainWindow, Styles):
436
430
  """
437
431
 
438
432
  if self.well_list.isMultipleSelection():
439
- msgBox = QMessageBox()
440
- msgBox.setIcon(QMessageBox.Critical)
441
- msgBox.setText("Please select a single well...")
442
- msgBox.setWindowTitle("Error")
443
- msgBox.setStandardButtons(QMessageBox.Ok)
444
- returnValue = msgBox.exec()
445
- if returnValue == QMessageBox.Ok:
446
- return False
433
+ generic_message("Please select a single well...")
434
+ return False
447
435
  else:
448
436
  self.well_index = self.well_list.getSelectedIndices() #[self.well_list.currentIndex()]
449
437
 
@@ -451,14 +439,8 @@ class ControlPanel(QMainWindow, Styles):
451
439
 
452
440
  pos = self.positions[w_idx]
453
441
  if not self.position_list.isSingleSelection():
454
- msgBox = QMessageBox()
455
- msgBox.setIcon(QMessageBox.Critical)
456
- msgBox.setText("Please select a single position...")
457
- msgBox.setWindowTitle("Error")
458
- msgBox.setStandardButtons(QMessageBox.Ok)
459
- returnValue = msgBox.exec()
460
- if returnValue == QMessageBox.Ok:
461
- return False
442
+ generic_message("Please select a single position...")
443
+ return False
462
444
  else:
463
445
  pos_indices = self.position_list.getSelectedIndices()
464
446
 
@@ -483,127 +465,72 @@ class ControlPanel(QMainWindow, Styles):
483
465
  def update_position_options(self):
484
466
 
485
467
  self.pos = self.position_list.currentText()
486
- panels = [self.ProcessEffectors, self.ProcessTargets]
487
468
 
488
469
  if self.position_list.isMultipleSelection() or not self.position_list.isAnySelected():
489
470
 
490
- for p in panels:
471
+ for p in self.ProcessPopulations:
491
472
  p.check_seg_btn.setEnabled(False)
492
473
  p.check_tracking_result_btn.setEnabled(False)
474
+ p.view_tab_btn.setEnabled(True)
475
+ p.signal_analysis_action.setEnabled(True)
476
+ p.check_seg_btn.setEnabled(False)
477
+ p.check_tracking_result_btn.setEnabled(False)
478
+ p.check_measurements_btn.setEnabled(False)
479
+ p.check_signals_btn.setEnabled(False)
480
+ p.delete_tracks_btn.hide()
493
481
 
494
- self.ProcessTargets.view_tab_btn.setEnabled(True)
495
- self.ProcessEffectors.view_tab_btn.setEnabled(True)
496
- self.NeighPanel.view_tab_btn.setEnabled(True)
497
- self.ProcessEffectors.signal_analysis_action.setEnabled(True)
498
- self.ProcessTargets.signal_analysis_action.setEnabled(True)
499
-
500
- self.ProcessTargets.check_seg_btn.setEnabled(False)
501
- self.ProcessEffectors.check_seg_btn.setEnabled(False)
502
-
503
- self.ProcessTargets.check_tracking_result_btn.setEnabled(False)
504
- self.ProcessEffectors.check_tracking_result_btn.setEnabled(False)
505
-
506
- self.ProcessEffectors.check_measurements_btn.setEnabled(False)
507
- self.ProcessTargets.check_measurements_btn.setEnabled(False)
508
- #self.ProcessTargets.signal_analysis_action.setEnabled(False)
509
- #self.ProcessEffectors.signal_analysis_action.setEnabled(False)
510
482
 
511
- self.ProcessTargets.check_signals_btn.setEnabled(False)
512
- self.ProcessEffectors.check_signals_btn.setEnabled(False)
483
+ self.NeighPanel.view_tab_btn.setEnabled(True)
513
484
  self.NeighPanel.check_signals_btn.setEnabled(False)
514
- self.ProcessTargets.delete_tracks_btn.hide()
515
- self.ProcessEffectors.delete_tracks_btn.hide()
516
-
517
485
  self.view_stack_btn.setEnabled(False)
518
486
 
519
487
  elif self.well_list.isMultipleSelection():
520
488
 
521
- self.ProcessTargets.view_tab_btn.setEnabled(True)
522
- self.ProcessEffectors.view_tab_btn.setEnabled(True)
489
+ for p in self.ProcessPopulations:
490
+ p.view_tab_btn.setEnabled(True)
491
+ p.signal_analysis_action.setEnabled(True)
492
+ p.delete_tracks_btn.hide()
493
+
494
+
523
495
  self.NeighPanel.view_tab_btn.setEnabled(True)
524
496
  self.view_stack_btn.setEnabled(False)
525
- self.ProcessEffectors.signal_analysis_action.setEnabled(True)
526
- self.ProcessTargets.signal_analysis_action.setEnabled(True)
527
497
  if hasattr(self,'delete_tracks_btn'):
528
498
  self.delete_tracks_btn.hide()
529
- self.ProcessTargets.delete_tracks_btn.hide()
530
- self.ProcessEffectors.delete_tracks_btn.hide()
531
499
  else:
532
500
 
533
501
  if self.well_list.isAnySelected() and self.position_list.isAnySelected():
534
502
 
535
503
  self.locate_selected_position()
536
504
  self.view_stack_btn.setEnabled(True)
537
- # if os.path.exists(os.sep.join([self.pos,'labels_effectors', os.sep])):
538
- self.ProcessEffectors.check_seg_btn.setEnabled(True)
539
- # if os.path.exists(os.sep.join([self.pos,'labels_targets', os.sep])):
540
- self.ProcessTargets.check_seg_btn.setEnabled(True)
541
-
542
- # if os.path.exists(os.sep.join([self.pos,'output','tables','napari_target_trajectories.npy'])):
543
- # self.ProcessTargets.check_tracking_result_btn.setEnabled(True)
544
- # else:
545
- # self.ProcessTargets.check_tracking_result_btn.setEnabled(False)
546
- # if os.path.exists(os.sep.join([self.pos,'output','tables','napari_effector_trajectories.npy'])):
547
- # self.ProcessEffectors.check_tracking_result_btn.setEnabled(True)
548
- # else:
549
- # self.ProcessEffectors.check_tracking_result_btn.setEnabled(False)
550
-
551
- if os.path.exists(os.sep.join([self.pos,'output','tables','trajectories_effectors.csv'])):
552
- df = pd.read_csv(os.sep.join([self.pos,'output','tables','trajectories_effectors.csv']), nrows=1)
553
- id_col = extract_identity_col(df)
554
- self.ProcessEffectors.check_measurements_btn.setEnabled(True)
555
- if id_col=='TRACK_ID':
556
- self.ProcessEffectors.check_signals_btn.setEnabled(True)
557
- self.ProcessEffectors.delete_tracks_btn.show()
558
- self.ProcessEffectors.signal_analysis_action.setEnabled(True)
559
- self.ProcessEffectors.check_tracking_result_btn.setEnabled(True)
505
+ for i,p in enumerate(self.ProcessPopulations):
506
+ p.check_seg_btn.setEnabled(True)
507
+ if os.path.exists(os.sep.join([self.pos,'output','tables',f'trajectories_{self.populations[i]}.csv'])):
508
+ df = pd.read_csv(os.sep.join([self.pos,'output','tables',f'trajectories_{self.populations[i]}.csv']), nrows=1)
509
+ id_col = extract_identity_col(df)
510
+ p.check_measurements_btn.setEnabled(True)
511
+
512
+ if id_col=='TRACK_ID':
513
+ p.check_signals_btn.setEnabled(True)
514
+ p.delete_tracks_btn.show()
515
+ p.signal_analysis_action.setEnabled(True)
516
+ p.check_tracking_result_btn.setEnabled(True)
517
+ else:
518
+ p.signal_analysis_action.setEnabled(False)
519
+ p.check_tracking_result_btn.setEnabled(False)
520
+
521
+ p.view_tab_btn.setEnabled(True)
522
+ p.classify_btn.setEnabled(True)
560
523
  else:
561
- self.ProcessEffectors.signal_analysis_action.setEnabled(False)
562
- self.ProcessEffectors.check_tracking_result_btn.setEnabled(False)
563
-
564
- #self.ProcessEffectors.signal_analysis_action.setEnabled(True)
565
- self.ProcessEffectors.view_tab_btn.setEnabled(True)
566
- self.ProcessEffectors.classify_btn.setEnabled(True)
567
- else:
568
- self.ProcessEffectors.check_measurements_btn.setEnabled(False)
569
- self.ProcessEffectors.check_signals_btn.setEnabled(False)
570
- #self.ProcessEffectors.signal_analysis_action.setEnabled(False)
571
- self.ProcessEffectors.view_tab_btn.setEnabled(False)
572
- self.ProcessEffectors.classify_btn.setEnabled(False)
573
- self.ProcessEffectors.delete_tracks_btn.hide()
574
- self.ProcessEffectors.signal_analysis_action.setEnabled(False)
575
-
576
- if os.path.exists(os.sep.join([self.pos,'output','tables','trajectories_targets.csv'])):
577
- df = pd.read_csv(os.sep.join([self.pos,'output','tables','trajectories_targets.csv']), nrows=1)
578
- id_col = extract_identity_col(df)
579
- self.ProcessTargets.check_measurements_btn.setEnabled(True)
580
- if id_col=='TRACK_ID':
581
- self.ProcessTargets.check_signals_btn.setEnabled(True)
582
- self.ProcessTargets.signal_analysis_action.setEnabled(True)
583
- self.ProcessTargets.check_tracking_result_btn.setEnabled(True)
584
- self.ProcessTargets.delete_tracks_btn.show()
585
- else:
586
- self.ProcessTargets.signal_analysis_action.setEnabled(False)
587
- self.ProcessTargets.check_tracking_result_btn.setEnabled(False)
588
-
589
- #self.ProcessTargets.signal_analysis_action.setEnabled(True)
590
- self.ProcessTargets.view_tab_btn.setEnabled(True)
591
- self.ProcessTargets.classify_btn.setEnabled(True)
592
- else:
593
- self.ProcessTargets.check_measurements_btn.setEnabled(False)
594
- self.ProcessTargets.check_signals_btn.setEnabled(False)
595
- #self.ProcessTargets.signal_analysis_action.setEnabled(False)
596
- self.ProcessTargets.view_tab_btn.setEnabled(False)
597
- self.ProcessTargets.classify_btn.setEnabled(False)
598
- self.ProcessTargets.signal_analysis_action.setEnabled(False)
599
- self.ProcessTargets.delete_tracks_btn.hide()
600
- self.ProcessTargets.signal_analysis_action.setEnabled(False)
524
+ p.check_measurements_btn.setEnabled(False)
525
+ p.check_signals_btn.setEnabled(False)
526
+ p.view_tab_btn.setEnabled(False)
527
+ p.classify_btn.setEnabled(False)
528
+ p.delete_tracks_btn.hide()
529
+ p.signal_analysis_action.setEnabled(False)
601
530
 
602
531
  if os.path.exists(os.sep.join([self.pos,'output','tables','trajectories_pairs.csv'])):
603
532
  self.NeighPanel.view_tab_btn.setEnabled(True)
604
533
  self.NeighPanel.check_signals_btn.setEnabled(True)
605
534
  else:
606
535
  self.NeighPanel.view_tab_btn.setEnabled(False)
607
- self.NeighPanel.check_signals_btn.setEnabled(False)
608
-
609
-
536
+ self.NeighPanel.check_signals_btn.setEnabled(False)
@@ -1,5 +1,5 @@
1
1
  from PyQt5.QtWidgets import QMessageBox,QGridLayout, QButtonGroup, \
2
- QCheckBox, QLineEdit, QVBoxLayout, QWidget, QLabel, QHBoxLayout, QPushButton, \
2
+ QCheckBox, QLineEdit, QVBoxLayout, QLabel, QHBoxLayout, QPushButton, \
3
3
  QRadioButton
4
4
  from PyQt5.QtCore import Qt, QSize
5
5
  from PyQt5.QtGui import QDoubleValidator
@@ -18,13 +18,13 @@ import matplotlib.pyplot as plt
18
18
  plt.rcParams['svg.fonttype'] = 'none'
19
19
  from glob import glob
20
20
  from matplotlib.cm import tab10
21
- from celldetective.gui import Styles
21
+ from celldetective.gui import CelldetectiveWidget
22
22
  import matplotlib.cm as mcm
23
23
  import pandas as pd
24
24
 
25
25
  from lifelines.utils import qth_survival_times
26
26
 
27
- class GenericSignalPlotWidget(QWidget, Styles):
27
+ class GenericSignalPlotWidget(CelldetectiveWidget):
28
28
 
29
29
  def __init__(self, df = None, df_pos_info = None, df_well_info = None, feature_selected = None, parent_window=None, title='plot', *args, **kwargs):
30
30
 
@@ -33,7 +33,6 @@ class GenericSignalPlotWidget(QWidget, Styles):
33
33
 
34
34
  self.parent_window = parent_window
35
35
  self.setWindowTitle(title)
36
- self.setWindowIcon(self.celldetective_icon)
37
36
 
38
37
  self.show_ci = False
39
38
  self.legend_visible = True
@@ -60,8 +59,6 @@ class GenericSignalPlotWidget(QWidget, Styles):
60
59
 
61
60
  self.fig.tight_layout()
62
61
  self.setLayout(self.layout)
63
- self.setAttribute(Qt.WA_DeleteOnClose)
64
-
65
62
 
66
63
  def populate_widget(self):
67
64
 
@@ -170,7 +167,7 @@ class GenericSignalPlotWidget(QWidget, Styles):
170
167
  self.ci_btn.clicked.connect(self.switch_ci)
171
168
  self.cell_lines_btn.clicked.connect(self.switch_cell_lines)
172
169
 
173
- self.class_selection_widget = QWidget()
170
+ self.class_selection_widget = CelldetectiveWidget()
174
171
 
175
172
  self.class_selection_lbl = QLabel('class of interest:')
176
173
  class_hbox = QHBoxLayout()
@@ -197,7 +194,7 @@ class GenericSignalPlotWidget(QWidget, Styles):
197
194
  self.layout.addWidget(self.class_selection_widget) #Layout(class_hbox)
198
195
 
199
196
  # Rescale
200
- self.rescale_widget = QWidget()
197
+ self.rescale_widget = CelldetectiveWidget()
201
198
 
202
199
  scale_hbox = QHBoxLayout()
203
200
  self.rescale_widget.setLayout(scale_hbox)
@@ -216,7 +213,7 @@ class GenericSignalPlotWidget(QWidget, Styles):
216
213
 
217
214
 
218
215
  # Rescale
219
- self.cell_lines_alpha_wdg = QWidget()
216
+ self.cell_lines_alpha_wdg = CelldetectiveWidget()
220
217
  alpha_hbox = QHBoxLayout()
221
218
 
222
219
  self.alpha_slider = QLabeledDoubleSlider()
@@ -225,7 +222,7 @@ class GenericSignalPlotWidget(QWidget, Styles):
225
222
  slider_initial_value=self.alpha_setting,
226
223
  slider_range=(0,1),
227
224
  decimal_option=True,
228
- precision=1.0E-05,
225
+ precision=5,
229
226
  )
230
227
  self.alpha_slider.valueChanged.connect(self.submit_alpha)
231
228
  self.cell_lines_alpha_wdg.setLayout(alpha_hbox)
@@ -343,7 +340,7 @@ class GenericSignalPlotWidget(QWidget, Styles):
343
340
  thresh = 20
344
341
  self.well_name_truncated = [w[:thresh - 3]+'...' if len(w)>thresh else w for w in self.usable_well_labels]
345
342
 
346
- self.line_choice_widget = QWidget()
343
+ self.line_choice_widget = CelldetectiveWidget()
347
344
  self.line_check_vbox = QGridLayout()
348
345
  self.line_choice_widget.setLayout(self.line_check_vbox)
349
346
 
@@ -828,7 +825,7 @@ class SurvivalPlotWidget(GenericSignalPlotWidget):
828
825
 
829
826
  def set_table_options(self):
830
827
 
831
- self.config_table_wg = QWidget()
828
+ self.config_table_wg = CelldetectiveWidget()
832
829
  self.config_table_wg.setMinimumWidth(480)
833
830
  self.config_table_wg.setWindowTitle('Survival data')
834
831
 
@@ -1,23 +1,48 @@
1
- import numpy as np
2
- from PyQt5.QtWidgets import QGridLayout, QApplication, QMessageBox, QFrame, QSizePolicy, QWidget, QLineEdit, QListWidget, QVBoxLayout, QComboBox, \
1
+ import os
2
+
3
+ from PyQt5.QtWidgets import QGridLayout, QApplication, QMessageBox, QFrame, QSizePolicy, QLineEdit, QListWidget, QVBoxLayout, QComboBox, \
3
4
  QPushButton, QLabel, QHBoxLayout, QCheckBox, QFileDialog, QToolButton, QMenu, QStylePainter, QStyleOptionComboBox, QStyle
4
5
  from PyQt5.QtCore import Qt, QSize, QAbstractTableModel, QEvent, pyqtSignal
5
6
  from PyQt5.QtGui import QDoubleValidator, QIntValidator, QStandardItemModel, QPalette
6
7
 
7
- from celldetective.gui import Styles
8
+ from celldetective.gui import Styles, CelldetectiveWidget
8
9
  from superqt.fonticon import icon
9
10
  from fonticon_mdi6 import MDI6
10
11
 
11
12
  from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg
12
13
  from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT
13
14
  import matplotlib.pyplot as plt
14
- import celldetective.extra_properties as extra_properties
15
+
16
+ from celldetective.utils import get_software_location
17
+
18
+ try:
19
+ import celldetective.extra_properties as extra_properties
20
+ extra_props = True
21
+ except Exception as e:
22
+ print(f"The module extra_properties seems corrupted: {e}... Skip...")
23
+ extra_props = False
24
+
15
25
  from inspect import getmembers, isfunction
16
26
  from celldetective.filters import *
17
27
  from os import sep
18
28
  import json
19
29
 
20
30
 
31
+ def generic_message(message, msg_type="warning"):
32
+
33
+ print(message)
34
+ message_box = QMessageBox()
35
+ if msg_type=="warning":
36
+ message_box.setIcon(QMessageBox.Warning)
37
+ elif msg_type=="info":
38
+ message_box.setIcon(QMessageBox.Information)
39
+ elif msg_type=="critical":
40
+ message_box.setIcon(QMessageBox.Critical)
41
+ message_box.setText(message)
42
+ message_box.setWindowTitle(msg_type)
43
+ message_box.setStandardButtons(QMessageBox.Ok)
44
+ _ = message_box.exec()
45
+
21
46
  class PreprocessingLayout(QVBoxLayout, Styles):
22
47
 
23
48
  """
@@ -328,7 +353,7 @@ class PandasModel(QAbstractTableModel):
328
353
  self.dataChanged.emit(ix, ix, (Qt.BackgroundRole,))
329
354
 
330
355
 
331
- class GenericOpColWidget(QWidget, Styles):
356
+ class GenericOpColWidget(CelldetectiveWidget):
332
357
 
333
358
  def __init__(self, parent_window, column=None, title=''):
334
359
 
@@ -415,7 +440,7 @@ class QuickSliderLayout(QHBoxLayout):
415
440
  The slider widget that allows the user to select a value.
416
441
  """
417
442
 
418
- def __init__(self, label=None, slider=None, layout_ratio=(0.25,0.75), slider_initial_value=1, slider_range=(0,1), slider_tooltip=None, decimal_option=True, precision=1.0E-03, *args):
443
+ def __init__(self, label=None, slider=None, layout_ratio=(0.25,0.75), slider_initial_value=1, slider_range=(0,1), slider_tooltip=None, decimal_option=True, precision=3, *args):
419
444
  super().__init__(*args)
420
445
 
421
446
  if label is not None and isinstance(label,str):
@@ -423,10 +448,11 @@ class QuickSliderLayout(QHBoxLayout):
423
448
  self.addWidget(self.qlabel, int(100*layout_ratio[0]))
424
449
 
425
450
  self.slider = slider
426
- self.slider.setOrientation(1)
451
+ self.slider.setOrientation(Qt.Horizontal)
427
452
  if decimal_option:
428
- self.slider.setSingleStep(precision)
429
- self.slider.setTickInterval(precision)
453
+ self.slider.setSingleStep(1.0*(10**(-precision)))
454
+ self.slider.setTickInterval(1.0*(10**(-precision)))
455
+ self.slider.setDecimals(precision)
430
456
  else:
431
457
  self.slider.setSingleStep(1)
432
458
  self.slider.setTickInterval(1)
@@ -546,7 +572,7 @@ class QHSeperationLine(QFrame):
546
572
  self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Minimum)
547
573
 
548
574
 
549
- class FeatureChoice(QWidget, Styles):
575
+ class FeatureChoice(CelldetectiveWidget):
550
576
 
551
577
  def __init__(self, parent_window):
552
578
  super().__init__()
@@ -575,10 +601,11 @@ class FeatureChoice(QWidget, Styles):
575
601
  "intensity_min",
576
602
  ]
577
603
 
578
- members = getmembers(extra_properties, isfunction)
579
- for o in members:
580
- if isfunction(o[1]) and o[1].__module__=="celldetective.extra_properties":
581
- standard_measurements.append(o[0])
604
+ if extra_props:
605
+ members = getmembers(extra_properties, isfunction)
606
+ for o in members:
607
+ if isfunction(o[1]) and o[1].__module__=="celldetective.extra_properties":
608
+ standard_measurements.append(o[0])
582
609
 
583
610
  self.combo_box.addItems(standard_measurements)
584
611
 
@@ -599,7 +626,7 @@ class FeatureChoice(QWidget, Styles):
599
626
  self.close()
600
627
 
601
628
 
602
- class FilterChoice(QWidget, Styles):
629
+ class FilterChoice(CelldetectiveWidget):
603
630
 
604
631
  def __init__(self, parent_window):
605
632
 
@@ -707,7 +734,7 @@ class FilterChoice(QWidget, Styles):
707
734
  self.arguments_labels[i].setText('')
708
735
 
709
736
 
710
- class OperationChoice(QWidget):
737
+ class OperationChoice(CelldetectiveWidget):
711
738
  """
712
739
  Mini window to select an operation from numpy to apply on the ROI.
713
740
 
@@ -738,7 +765,7 @@ class OperationChoice(QWidget):
738
765
  self.close()
739
766
 
740
767
 
741
- class GeometryChoice(QWidget):
768
+ class GeometryChoice(CelldetectiveWidget):
742
769
 
743
770
  def __init__(self, parent_window):
744
771
 
@@ -802,7 +829,7 @@ class GeometryChoice(QWidget):
802
829
  self.close()
803
830
 
804
831
 
805
- class DistanceChoice(QWidget):
832
+ class DistanceChoice(CelldetectiveWidget):
806
833
 
807
834
  def __init__(self, parent_window):
808
835
  super().__init__()
@@ -836,7 +863,7 @@ class DistanceChoice(QWidget):
836
863
  self.close()
837
864
 
838
865
 
839
- class ListWidget(QWidget):
866
+ class ListWidget(CelldetectiveWidget):
840
867
 
841
868
  """
842
869
  A customizable widget for displaying and managing a list of items, with the
@@ -963,7 +990,7 @@ class ListWidget(QWidget):
963
990
  del self.items[idx]
964
991
 
965
992
 
966
- class FigureCanvas(QWidget):
993
+ class FigureCanvas(CelldetectiveWidget):
967
994
  """
968
995
  Generic figure canvas.
969
996
  """
@@ -1185,6 +1212,7 @@ def color_from_state(state, recently_modified=False):
1185
1212
  unique_values = np.unique(state)
1186
1213
  color_map={}
1187
1214
  for value in unique_values:
1215
+
1188
1216
  if np.isnan(value):
1189
1217
  value = "nan"
1190
1218
  color_map[value] = 'k'
@@ -1219,7 +1247,7 @@ def color_from_class(cclass, recently_modified=False):
1219
1247
  return 'k'
1220
1248
 
1221
1249
 
1222
- class ChannelChoice(QWidget):
1250
+ class ChannelChoice(CelldetectiveWidget):
1223
1251
 
1224
1252
  def __init__(self, parent_window):
1225
1253
  super().__init__()
@@ -1,10 +1,11 @@
1
1
  import configparser
2
- from PyQt5.QtWidgets import QWidget, QVBoxLayout, QScrollArea, QLabel, QHBoxLayout, QLineEdit, QPushButton
2
+ from PyQt5.QtWidgets import QVBoxLayout, QScrollArea, QLabel, QHBoxLayout, QLineEdit, QPushButton
3
3
  from PyQt5.QtCore import Qt
4
4
  import configparser
5
- from celldetective.gui import Styles
5
+ from celldetective.gui import CelldetectiveWidget
6
6
 
7
- class ConfigEditor(QWidget, Styles):
7
+
8
+ class ConfigEditor(CelldetectiveWidget):
8
9
 
9
10
  def __init__(self, parent_window):
10
11
 
@@ -27,7 +28,7 @@ class ConfigEditor(QWidget, Styles):
27
28
  # Create a scroll area to contain the main layout
28
29
  scroll = QScrollArea()
29
30
  scroll.setWidgetResizable(True)
30
- scroll_content = QWidget()
31
+ scroll_content = CelldetectiveWidget()
31
32
  self.scroll_layout = QVBoxLayout(scroll_content)
32
33
  scroll_content.setLayout(self.scroll_layout)
33
34
  scroll.setWidget(scroll_content)