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.
- celldetective/__init__.py +0 -3
- celldetective/_version.py +1 -1
- celldetective/events.py +2 -4
- celldetective/extra_properties.py +320 -24
- celldetective/gui/InitWindow.py +33 -45
- celldetective/gui/__init__.py +1 -0
- celldetective/gui/about.py +19 -15
- celldetective/gui/analyze_block.py +34 -19
- celldetective/gui/base_components.py +23 -0
- celldetective/gui/btrack_options.py +26 -34
- celldetective/gui/classifier_widget.py +71 -80
- celldetective/gui/configure_new_exp.py +113 -17
- celldetective/gui/control_panel.py +68 -141
- celldetective/gui/generic_signal_plot.py +9 -12
- celldetective/gui/gui_utils.py +49 -21
- celldetective/gui/json_readers.py +5 -4
- celldetective/gui/layouts.py +246 -22
- celldetective/gui/measurement_options.py +32 -17
- celldetective/gui/neighborhood_options.py +10 -13
- celldetective/gui/plot_measurements.py +21 -17
- celldetective/gui/plot_signals_ui.py +131 -75
- celldetective/gui/process_block.py +180 -123
- celldetective/gui/processes/compute_neighborhood.py +594 -0
- celldetective/gui/processes/measure_cells.py +5 -0
- celldetective/gui/processes/segment_cells.py +27 -6
- celldetective/gui/processes/track_cells.py +6 -0
- celldetective/gui/retrain_segmentation_model_options.py +12 -20
- celldetective/gui/retrain_signal_model_options.py +57 -56
- celldetective/gui/seg_model_loader.py +21 -62
- celldetective/gui/signal_annotator.py +139 -72
- celldetective/gui/signal_annotator2.py +431 -635
- celldetective/gui/signal_annotator_options.py +8 -11
- celldetective/gui/survival_ui.py +49 -95
- celldetective/gui/tableUI.py +28 -25
- celldetective/gui/thresholds_gui.py +617 -1221
- celldetective/gui/viewers.py +106 -39
- celldetective/gui/workers.py +9 -3
- celldetective/io.py +73 -27
- celldetective/measure.py +63 -27
- celldetective/neighborhood.py +342 -268
- celldetective/preprocessing.py +25 -17
- celldetective/relative_measurements.py +50 -29
- celldetective/scripts/analyze_signals.py +4 -1
- celldetective/scripts/measure_relative.py +4 -1
- celldetective/scripts/segment_cells.py +0 -6
- celldetective/scripts/track_cells.py +3 -1
- celldetective/scripts/train_segmentation_model.py +7 -4
- celldetective/signals.py +29 -14
- celldetective/tracking.py +7 -2
- celldetective/utils.py +36 -8
- {celldetective-1.3.9.post4.dist-info → celldetective-1.4.0.dist-info}/METADATA +24 -16
- {celldetective-1.3.9.post4.dist-info → celldetective-1.4.0.dist-info}/RECORD +57 -55
- {celldetective-1.3.9.post4.dist-info → celldetective-1.4.0.dist-info}/WHEEL +1 -1
- tests/test_qt.py +21 -21
- {celldetective-1.3.9.post4.dist-info → celldetective-1.4.0.dist-info}/entry_points.txt +0 -0
- {celldetective-1.3.9.post4.dist-info → celldetective-1.4.0.dist-info/licenses}/LICENSE +0 -0
- {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
|
|
2
|
-
QTabWidget, QVBoxLayout,
|
|
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,
|
|
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(
|
|
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 =
|
|
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)
|
|
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.
|
|
46
|
-
|
|
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
|
-
|
|
61
|
-
|
|
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
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
-
|
|
278
|
-
|
|
279
|
-
|
|
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
|
|
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
|
-
|
|
440
|
-
|
|
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
|
-
|
|
455
|
-
|
|
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
|
|
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.
|
|
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.
|
|
522
|
-
|
|
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
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
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
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
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,
|
|
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
|
|
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(
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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=
|
|
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 =
|
|
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 =
|
|
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
|
|
celldetective/gui/gui_utils.py
CHANGED
|
@@ -1,23 +1,48 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
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
|
-
|
|
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(
|
|
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=
|
|
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(
|
|
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(
|
|
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
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
|
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
|
|
5
|
+
from celldetective.gui import CelldetectiveWidget
|
|
6
6
|
|
|
7
|
-
|
|
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 =
|
|
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)
|