celldetective 1.4.2__py3-none-any.whl → 1.5.0b1__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 +25 -0
- celldetective/__main__.py +62 -43
- celldetective/_version.py +1 -1
- celldetective/extra_properties.py +477 -399
- celldetective/filters.py +192 -97
- celldetective/gui/InitWindow.py +541 -411
- celldetective/gui/__init__.py +0 -15
- celldetective/gui/about.py +44 -39
- celldetective/gui/analyze_block.py +120 -84
- celldetective/gui/base/__init__.py +0 -0
- celldetective/gui/base/channel_norm_generator.py +335 -0
- celldetective/gui/base/components.py +249 -0
- celldetective/gui/base/feature_choice.py +92 -0
- celldetective/gui/base/figure_canvas.py +52 -0
- celldetective/gui/base/list_widget.py +133 -0
- celldetective/gui/{styles.py → base/styles.py} +92 -36
- celldetective/gui/base/utils.py +33 -0
- celldetective/gui/base_annotator.py +900 -767
- celldetective/gui/classifier_widget.py +6 -22
- celldetective/gui/configure_new_exp.py +777 -671
- celldetective/gui/control_panel.py +635 -524
- celldetective/gui/dynamic_progress.py +449 -0
- celldetective/gui/event_annotator.py +2023 -1662
- celldetective/gui/generic_signal_plot.py +1292 -944
- celldetective/gui/gui_utils.py +899 -1289
- celldetective/gui/interactions_block.py +658 -0
- celldetective/gui/interactive_timeseries_viewer.py +447 -0
- celldetective/gui/json_readers.py +48 -15
- celldetective/gui/layouts/__init__.py +5 -0
- celldetective/gui/layouts/background_model_free_layout.py +537 -0
- celldetective/gui/layouts/channel_offset_layout.py +134 -0
- celldetective/gui/layouts/local_correction_layout.py +91 -0
- celldetective/gui/layouts/model_fit_layout.py +372 -0
- celldetective/gui/layouts/operation_layout.py +68 -0
- celldetective/gui/layouts/protocol_designer_layout.py +96 -0
- celldetective/gui/pair_event_annotator.py +3130 -2435
- celldetective/gui/plot_measurements.py +586 -267
- celldetective/gui/plot_signals_ui.py +724 -506
- celldetective/gui/preprocessing_block.py +395 -0
- celldetective/gui/process_block.py +1678 -1831
- celldetective/gui/seg_model_loader.py +580 -473
- celldetective/gui/settings/__init__.py +0 -7
- celldetective/gui/settings/_cellpose_model_params.py +181 -0
- celldetective/gui/settings/_event_detection_model_params.py +95 -0
- celldetective/gui/settings/_segmentation_model_params.py +159 -0
- celldetective/gui/settings/_settings_base.py +77 -65
- celldetective/gui/settings/_settings_event_model_training.py +752 -526
- celldetective/gui/settings/_settings_measurements.py +1133 -964
- celldetective/gui/settings/_settings_neighborhood.py +574 -488
- celldetective/gui/settings/_settings_segmentation_model_training.py +779 -564
- celldetective/gui/settings/_settings_signal_annotator.py +329 -305
- celldetective/gui/settings/_settings_tracking.py +1304 -1094
- celldetective/gui/settings/_stardist_model_params.py +98 -0
- celldetective/gui/survival_ui.py +422 -312
- celldetective/gui/tableUI.py +1665 -1701
- celldetective/gui/table_ops/_maths.py +295 -0
- celldetective/gui/table_ops/_merge_groups.py +140 -0
- celldetective/gui/table_ops/_merge_one_hot.py +95 -0
- celldetective/gui/table_ops/_query_table.py +43 -0
- celldetective/gui/table_ops/_rename_col.py +44 -0
- celldetective/gui/thresholds_gui.py +382 -179
- celldetective/gui/viewers/__init__.py +0 -0
- celldetective/gui/viewers/base_viewer.py +700 -0
- celldetective/gui/viewers/channel_offset_viewer.py +331 -0
- celldetective/gui/viewers/contour_viewer.py +394 -0
- celldetective/gui/viewers/size_viewer.py +153 -0
- celldetective/gui/viewers/spot_detection_viewer.py +341 -0
- celldetective/gui/viewers/threshold_viewer.py +309 -0
- celldetective/gui/workers.py +403 -126
- celldetective/log_manager.py +92 -0
- celldetective/measure.py +1895 -1478
- celldetective/napari/__init__.py +0 -0
- celldetective/napari/utils.py +1025 -0
- celldetective/neighborhood.py +1914 -1448
- celldetective/preprocessing.py +1620 -1220
- celldetective/processes/__init__.py +0 -0
- celldetective/processes/background_correction.py +271 -0
- celldetective/processes/compute_neighborhood.py +894 -0
- celldetective/processes/detect_events.py +246 -0
- celldetective/processes/downloader.py +137 -0
- celldetective/processes/measure_cells.py +565 -0
- celldetective/processes/segment_cells.py +760 -0
- celldetective/processes/track_cells.py +435 -0
- celldetective/processes/train_segmentation_model.py +694 -0
- celldetective/processes/train_signal_model.py +265 -0
- celldetective/processes/unified_process.py +292 -0
- celldetective/regionprops/_regionprops.py +358 -317
- celldetective/relative_measurements.py +987 -710
- celldetective/scripts/measure_cells.py +313 -212
- celldetective/scripts/measure_relative.py +90 -46
- celldetective/scripts/segment_cells.py +165 -104
- celldetective/scripts/segment_cells_thresholds.py +96 -68
- celldetective/scripts/track_cells.py +198 -149
- celldetective/scripts/train_segmentation_model.py +324 -201
- celldetective/scripts/train_signal_model.py +87 -45
- celldetective/segmentation.py +844 -749
- celldetective/signals.py +3514 -2861
- celldetective/tracking.py +30 -15
- celldetective/utils/__init__.py +0 -0
- celldetective/utils/cellpose_utils/__init__.py +133 -0
- celldetective/utils/color_mappings.py +42 -0
- celldetective/utils/data_cleaning.py +630 -0
- celldetective/utils/data_loaders.py +450 -0
- celldetective/utils/dataset_helpers.py +207 -0
- celldetective/utils/downloaders.py +235 -0
- celldetective/utils/event_detection/__init__.py +8 -0
- celldetective/utils/experiment.py +1782 -0
- celldetective/utils/image_augmenters.py +308 -0
- celldetective/utils/image_cleaning.py +74 -0
- celldetective/utils/image_loaders.py +926 -0
- celldetective/utils/image_transforms.py +335 -0
- celldetective/utils/io.py +62 -0
- celldetective/utils/mask_cleaning.py +348 -0
- celldetective/utils/mask_transforms.py +5 -0
- celldetective/utils/masks.py +184 -0
- celldetective/utils/maths.py +351 -0
- celldetective/utils/model_getters.py +325 -0
- celldetective/utils/model_loaders.py +296 -0
- celldetective/utils/normalization.py +380 -0
- celldetective/utils/parsing.py +465 -0
- celldetective/utils/plots/__init__.py +0 -0
- celldetective/utils/plots/regression.py +53 -0
- celldetective/utils/resources.py +34 -0
- celldetective/utils/stardist_utils/__init__.py +104 -0
- celldetective/utils/stats.py +90 -0
- celldetective/utils/types.py +21 -0
- {celldetective-1.4.2.dist-info → celldetective-1.5.0b1.dist-info}/METADATA +1 -1
- celldetective-1.5.0b1.dist-info/RECORD +187 -0
- {celldetective-1.4.2.dist-info → celldetective-1.5.0b1.dist-info}/WHEEL +1 -1
- tests/gui/test_new_project.py +129 -117
- tests/gui/test_project.py +127 -79
- tests/test_filters.py +39 -15
- tests/test_notebooks.py +8 -0
- tests/test_tracking.py +232 -13
- tests/test_utils.py +123 -77
- celldetective/gui/base_components.py +0 -23
- celldetective/gui/layouts.py +0 -1602
- celldetective/gui/processes/compute_neighborhood.py +0 -594
- celldetective/gui/processes/downloader.py +0 -111
- celldetective/gui/processes/measure_cells.py +0 -360
- celldetective/gui/processes/segment_cells.py +0 -499
- celldetective/gui/processes/track_cells.py +0 -303
- celldetective/gui/processes/train_segmentation_model.py +0 -270
- celldetective/gui/processes/train_signal_model.py +0 -108
- celldetective/gui/table_ops/merge_groups.py +0 -118
- celldetective/gui/viewers.py +0 -1354
- celldetective/io.py +0 -3663
- celldetective/utils.py +0 -3108
- celldetective-1.4.2.dist-info/RECORD +0 -123
- {celldetective-1.4.2.dist-info → celldetective-1.5.0b1.dist-info}/entry_points.txt +0 -0
- {celldetective-1.4.2.dist-info → celldetective-1.5.0b1.dist-info}/licenses/LICENSE +0 -0
- {celldetective-1.4.2.dist-info → celldetective-1.5.0b1.dist-info}/top_level.txt +0 -0
|
@@ -1,12 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import time
|
|
2
|
+
|
|
3
|
+
from PyQt5.QtWidgets import (
|
|
4
|
+
QPushButton,
|
|
5
|
+
QHBoxLayout,
|
|
6
|
+
QLabel,
|
|
7
|
+
QGridLayout,
|
|
8
|
+
QFrame,
|
|
9
|
+
QTabWidget,
|
|
10
|
+
QVBoxLayout,
|
|
11
|
+
QScrollArea,
|
|
12
|
+
QDesktopWidget,
|
|
13
|
+
)
|
|
14
|
+
from celldetective.gui.base.components import (
|
|
15
|
+
CelldetectiveMainWindow,
|
|
16
|
+
CelldetectiveWidget,
|
|
17
|
+
QCheckableComboBox,
|
|
18
|
+
QHSeperationLine,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
from PyQt5.QtCore import Qt, QSize, QThread
|
|
22
|
+
from celldetective.gui.base.components import generic_message
|
|
23
|
+
from celldetective.utils.parsing import (
|
|
24
|
+
config_section_to_dict,
|
|
25
|
+
_extract_labels_from_config,
|
|
26
|
+
)
|
|
27
|
+
from celldetective.gui.process_block import ProcessPanel
|
|
28
|
+
from celldetective.gui.preprocessing_block import PreprocessingPanel
|
|
29
|
+
from celldetective.gui.interactions_block import NeighPanel
|
|
30
|
+
from celldetective.gui.analyze_block import AnalysisPanel
|
|
31
|
+
|
|
32
|
+
from celldetective.utils.experiment import (
|
|
33
|
+
get_experiment_wells,
|
|
34
|
+
extract_well_name_and_number,
|
|
35
|
+
extract_position_name,
|
|
36
|
+
extract_experiment_channels,
|
|
37
|
+
get_spatial_calibration,
|
|
38
|
+
get_temporal_calibration,
|
|
39
|
+
get_experiment_concentrations,
|
|
40
|
+
get_experiment_cell_types,
|
|
41
|
+
get_experiment_antibodies,
|
|
42
|
+
get_experiment_pharmaceutical_agents,
|
|
43
|
+
get_experiment_populations,
|
|
44
|
+
get_config,
|
|
45
|
+
)
|
|
10
46
|
from natsort import natsorted
|
|
11
47
|
from glob import glob
|
|
12
48
|
import os
|
|
@@ -15,525 +51,600 @@ from superqt.fonticon import icon
|
|
|
15
51
|
from fonticon_mdi6 import MDI6
|
|
16
52
|
import gc
|
|
17
53
|
import subprocess
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
54
|
+
|
|
55
|
+
import logging
|
|
56
|
+
|
|
57
|
+
logger = logging.getLogger(__name__)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class BackgroundLoader(QThread):
|
|
61
|
+
def run(self):
|
|
62
|
+
logger.info("Loading background packages...")
|
|
63
|
+
try:
|
|
64
|
+
from celldetective.gui.viewers.base_viewer import StackVisualizer
|
|
65
|
+
self.StackVisualizer = StackVisualizer
|
|
66
|
+
except Exception:
|
|
67
|
+
logger.error("Background packages not loaded...")
|
|
68
|
+
logger.info("Background packages loaded...")
|
|
21
69
|
|
|
22
70
|
|
|
23
71
|
class ControlPanel(CelldetectiveMainWindow):
|
|
24
72
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
73
|
+
def __init__(self, parent_window=None, exp_dir=""):
|
|
74
|
+
|
|
75
|
+
super().__init__()
|
|
76
|
+
|
|
77
|
+
self.exp_dir = exp_dir
|
|
78
|
+
if not self.exp_dir.endswith(os.sep):
|
|
79
|
+
self.exp_dir = self.exp_dir + os.sep
|
|
80
|
+
self.setWindowTitle("celldetective")
|
|
81
|
+
self.parent_window = parent_window
|
|
82
|
+
|
|
83
|
+
self.init_wells_and_positions()
|
|
84
|
+
self.load_configuration()
|
|
85
|
+
|
|
86
|
+
self.w = CelldetectiveWidget()
|
|
87
|
+
self.grid = QGridLayout(self.w)
|
|
88
|
+
self.grid.setSpacing(5)
|
|
89
|
+
self.grid.setContentsMargins(10, 10, 10, 10) # left top right bottom
|
|
90
|
+
|
|
91
|
+
self.to_disable = []
|
|
92
|
+
self.generate_header()
|
|
93
|
+
self.ProcessPopulations = [ProcessPanel(self, pop) for pop in self.populations]
|
|
94
|
+
|
|
95
|
+
self.NeighPanel = NeighPanel(self)
|
|
96
|
+
self.PreprocessingPanel = PreprocessingPanel(self)
|
|
97
|
+
|
|
98
|
+
ProcessFrame = QFrame()
|
|
99
|
+
grid_process = QVBoxLayout(ProcessFrame)
|
|
100
|
+
grid_process.setContentsMargins(15, 30, 15, 15)
|
|
101
|
+
|
|
102
|
+
AnalyzeFrame = QFrame()
|
|
103
|
+
grid_analyze = QVBoxLayout(AnalyzeFrame)
|
|
104
|
+
grid_analyze.setContentsMargins(15, 30, 15, 15)
|
|
105
|
+
self.SurvivalBlock = AnalysisPanel(self, title="Survival")
|
|
106
|
+
|
|
107
|
+
grid_process.addWidget(self.PreprocessingPanel)
|
|
108
|
+
for panel in self.ProcessPopulations:
|
|
109
|
+
grid_process.addWidget(panel)
|
|
110
|
+
grid_process.addWidget(self.NeighPanel)
|
|
111
|
+
|
|
112
|
+
grid_analyze.addWidget(self.SurvivalBlock)
|
|
113
|
+
|
|
114
|
+
self.scroll = QScrollArea()
|
|
115
|
+
self.scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
|
116
|
+
self.scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
|
117
|
+
self.scroll.setWidgetResizable(True)
|
|
118
|
+
desktop = QDesktopWidget()
|
|
119
|
+
self.scroll.setMinimumHeight(550)
|
|
120
|
+
# self.scroll.setMinimumHeight(int(0.4*screen_height))
|
|
121
|
+
|
|
122
|
+
tabWidget = QTabWidget()
|
|
123
|
+
tab_index_process = tabWidget.addTab(ProcessFrame, "Process")
|
|
124
|
+
tabWidget.setTabIcon(tab_index_process, icon(MDI6.cog_outline, color="black"))
|
|
125
|
+
|
|
126
|
+
tab_index_analyze = tabWidget.addTab(AnalyzeFrame, "Analyze")
|
|
127
|
+
tabWidget.setTabIcon(tab_index_analyze, icon(MDI6.poll, color="black"))
|
|
128
|
+
tabWidget.setStyleSheet(self.qtab_style)
|
|
129
|
+
|
|
130
|
+
self.grid.addWidget(tabWidget, 7, 0, 1, 3, alignment=Qt.AlignTop)
|
|
131
|
+
self.grid.setSpacing(5)
|
|
132
|
+
self.scroll.setWidget(self.w)
|
|
133
|
+
self.setCentralWidget(self.scroll)
|
|
134
|
+
self.create_config_dir()
|
|
135
|
+
self.update_position_options()
|
|
136
|
+
# self.setMinimumHeight(int(self.sizeHint().height()))
|
|
137
|
+
|
|
138
|
+
self.initial_height = self.size().height()
|
|
139
|
+
self.initial_width = self.size().width()
|
|
140
|
+
self.screen_height = desktop.screenGeometry().height()
|
|
141
|
+
self.screen_width = desktop.screenGeometry().width()
|
|
142
|
+
self.scroll.setMinimumWidth(440)
|
|
143
|
+
|
|
144
|
+
self.well_list.setCurrentIndex(0)
|
|
145
|
+
# self.position_list.setCurrentIndex(0)
|
|
146
|
+
|
|
147
|
+
t_loaded = time.time()
|
|
148
|
+
logger.info(f"Launch time: {t_loaded - self.parent_window.t_ref} s...")
|
|
149
|
+
|
|
150
|
+
self.bg_loader = BackgroundLoader()
|
|
151
|
+
self.bg_loader.start()
|
|
152
|
+
|
|
153
|
+
def init_wells_and_positions(self):
|
|
154
|
+
"""
|
|
155
|
+
Detect the wells in the experiment folder and the associated positions.
|
|
156
|
+
"""
|
|
157
|
+
|
|
158
|
+
self.wells = get_experiment_wells(
|
|
159
|
+
self.exp_dir
|
|
160
|
+
) # natsorted(glob(self.exp_dir + "W*" + os.sep))
|
|
161
|
+
self.positions = []
|
|
162
|
+
self.position_paths = []
|
|
163
|
+
for w in self.wells:
|
|
164
|
+
well_name, well_nbr = extract_well_name_and_number(w)
|
|
165
|
+
positions_path = natsorted(glob(os.sep.join([w, f"{well_nbr}*", os.sep])))
|
|
166
|
+
self.position_paths.append(positions_path)
|
|
167
|
+
self.positions.append(
|
|
168
|
+
[extract_position_name(pos) for pos in positions_path]
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
def generate_header(self):
|
|
172
|
+
"""
|
|
173
|
+
Show the experiment name, create two QComboBox for respectively the
|
|
174
|
+
biological condition (well) and position of interest, access the experiment config.
|
|
175
|
+
"""
|
|
176
|
+
|
|
177
|
+
condition_label = QLabel("condition: ")
|
|
178
|
+
position_label = QLabel("position: ")
|
|
179
|
+
|
|
180
|
+
name = self.exp_dir.split(os.sep)[-2]
|
|
181
|
+
experiment_label = QLabel(f"Experiment:")
|
|
182
|
+
experiment_label.setStyleSheet("""
|
|
128
183
|
font-weight: bold;
|
|
129
184
|
""")
|
|
130
185
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
186
|
+
self.folder_exp_btn = QPushButton()
|
|
187
|
+
self.folder_exp_btn.setIcon(icon(MDI6.folder, color="black"))
|
|
188
|
+
self.folder_exp_btn.setIconSize(QSize(20, 20))
|
|
189
|
+
self.folder_exp_btn.setToolTip("Experiment folder")
|
|
190
|
+
self.folder_exp_btn.clicked.connect(self.open_experiment_folder)
|
|
191
|
+
self.folder_exp_btn.setStyleSheet(self.button_select_all)
|
|
192
|
+
|
|
193
|
+
self.edit_config_button = QPushButton()
|
|
194
|
+
self.edit_config_button.setIcon(icon(MDI6.cog_outline, color="black"))
|
|
195
|
+
self.edit_config_button.setIconSize(QSize(20, 20))
|
|
196
|
+
self.edit_config_button.setToolTip("Configuration file")
|
|
197
|
+
self.edit_config_button.clicked.connect(self.open_config_editor)
|
|
198
|
+
self.edit_config_button.setStyleSheet(self.button_select_all)
|
|
199
|
+
|
|
200
|
+
self.well_list = QCheckableComboBox(obj="well", parent_window=self)
|
|
201
|
+
thresh = 32
|
|
202
|
+
self.well_truncated = [
|
|
203
|
+
w[: thresh - 3] + "..." if len(w) > thresh else w for w in self.well_labels
|
|
204
|
+
]
|
|
205
|
+
for i in range(len(self.well_truncated)):
|
|
206
|
+
self.well_list.addItem(self.well_truncated[i], tooltip=self.well_labels[i])
|
|
207
|
+
|
|
208
|
+
self.position_list = QCheckableComboBox(obj="position", parent_window=self)
|
|
209
|
+
self.position_list.addItems(self.positions[0])
|
|
210
|
+
self.to_disable.append(self.position_list)
|
|
211
|
+
# self.locate_selected_position()
|
|
212
|
+
|
|
213
|
+
self.well_list.activated.connect(self.display_positions)
|
|
214
|
+
|
|
215
|
+
self.position_list.activated.connect(self.update_position_options)
|
|
216
|
+
|
|
217
|
+
self.view_stack_btn = QPushButton()
|
|
218
|
+
self.view_stack_btn.setStyleSheet(self.button_select_all)
|
|
219
|
+
self.view_stack_btn.setIcon(icon(MDI6.image_check, color="black"))
|
|
220
|
+
self.view_stack_btn.setToolTip("View stack.")
|
|
221
|
+
self.view_stack_btn.setIconSize(QSize(20, 20))
|
|
222
|
+
self.view_stack_btn.clicked.connect(self.view_current_stack)
|
|
223
|
+
self.view_stack_btn.setEnabled(False)
|
|
224
|
+
|
|
225
|
+
self.select_all_wells_btn = QPushButton()
|
|
226
|
+
self.select_all_wells_btn.setIcon(icon(MDI6.select_all, color="black"))
|
|
227
|
+
self.select_all_wells_btn.setIconSize(QSize(20, 20))
|
|
228
|
+
self.select_all_wells_btn.setToolTip("Select all wells.")
|
|
229
|
+
self.select_all_wells_btn.clicked.connect(self.select_all_wells)
|
|
230
|
+
self.select_all_wells_btn.setStyleSheet(self.button_select_all)
|
|
231
|
+
self.select_all_wells_option = False
|
|
232
|
+
|
|
233
|
+
self.select_all_pos_btn = QPushButton()
|
|
234
|
+
self.select_all_pos_btn.setIcon(icon(MDI6.select_all, color="black"))
|
|
235
|
+
self.select_all_pos_btn.setIconSize(QSize(20, 20))
|
|
236
|
+
self.select_all_pos_btn.setToolTip("Select all positions.")
|
|
237
|
+
self.select_all_pos_btn.clicked.connect(self.select_all_positions)
|
|
238
|
+
self.select_all_pos_btn.setStyleSheet(self.button_select_all)
|
|
239
|
+
self.select_all_pos_option = False
|
|
240
|
+
|
|
241
|
+
well_lbl = QLabel("Well: ")
|
|
242
|
+
well_lbl.setAlignment(Qt.AlignRight)
|
|
243
|
+
|
|
244
|
+
pos_lbl = QLabel("Position: ")
|
|
245
|
+
pos_lbl.setAlignment(Qt.AlignRight)
|
|
246
|
+
|
|
247
|
+
hsep = QHSeperationLine()
|
|
248
|
+
|
|
249
|
+
## LAYOUT
|
|
250
|
+
|
|
251
|
+
# Header layout
|
|
252
|
+
vbox = QVBoxLayout()
|
|
253
|
+
self.grid.addLayout(vbox, 0, 0, 1, 3)
|
|
254
|
+
|
|
255
|
+
# Experiment row
|
|
256
|
+
exp_hbox = QHBoxLayout()
|
|
257
|
+
exp_hbox.addWidget(experiment_label, 25, alignment=Qt.AlignRight)
|
|
258
|
+
exp_subhbox = QHBoxLayout()
|
|
259
|
+
if len(name) > thresh:
|
|
260
|
+
name_cut = name[: thresh - 3] + "..."
|
|
261
|
+
else:
|
|
262
|
+
name_cut = name
|
|
263
|
+
exp_name_lbl = QLabel(name_cut)
|
|
264
|
+
exp_name_lbl.setToolTip(name)
|
|
265
|
+
exp_subhbox.addWidget(exp_name_lbl, 90, alignment=Qt.AlignLeft)
|
|
266
|
+
exp_subhbox.addWidget(self.folder_exp_btn, 5, alignment=Qt.AlignRight)
|
|
267
|
+
exp_subhbox.addWidget(self.edit_config_button, 5, alignment=Qt.AlignRight)
|
|
268
|
+
exp_hbox.addLayout(exp_subhbox, 75)
|
|
269
|
+
vbox.addLayout(exp_hbox)
|
|
270
|
+
|
|
271
|
+
# Well row
|
|
272
|
+
well_hbox = QHBoxLayout()
|
|
273
|
+
well_hbox.addWidget(well_lbl, 25, alignment=Qt.AlignVCenter)
|
|
274
|
+
well_subhbox = QHBoxLayout()
|
|
275
|
+
well_subhbox.addWidget(self.well_list, 95)
|
|
276
|
+
well_subhbox.addWidget(self.select_all_wells_btn, 5)
|
|
277
|
+
well_hbox.addLayout(well_subhbox, 75)
|
|
278
|
+
vbox.addLayout(well_hbox)
|
|
279
|
+
|
|
280
|
+
# Position row
|
|
281
|
+
position_hbox = QHBoxLayout()
|
|
282
|
+
position_hbox.addWidget(pos_lbl, 25, alignment=Qt.AlignVCenter)
|
|
283
|
+
pos_subhbox = QHBoxLayout()
|
|
284
|
+
pos_subhbox.addWidget(self.position_list, 90)
|
|
285
|
+
pos_subhbox.addWidget(self.select_all_pos_btn, 5)
|
|
286
|
+
pos_subhbox.addWidget(self.view_stack_btn, 5)
|
|
287
|
+
position_hbox.addLayout(pos_subhbox, 75)
|
|
288
|
+
vbox.addLayout(position_hbox)
|
|
289
|
+
|
|
290
|
+
vbox.addWidget(hsep)
|
|
291
|
+
|
|
292
|
+
def select_all_wells(self):
|
|
293
|
+
|
|
294
|
+
if not self.select_all_wells_option:
|
|
295
|
+
self.well_list.selectAll()
|
|
296
|
+
self.select_all_wells_option = True
|
|
297
|
+
self.select_all_wells_btn.setIcon(
|
|
298
|
+
icon(MDI6.select_all, color=self.celldetective_blue)
|
|
299
|
+
)
|
|
300
|
+
self.select_all_wells_btn.setIconSize(QSize(20, 20))
|
|
301
|
+
self.display_positions()
|
|
302
|
+
else:
|
|
303
|
+
self.well_list.unselectAll()
|
|
304
|
+
self.select_all_wells_option = False
|
|
305
|
+
self.select_all_wells_btn.setIcon(icon(MDI6.select_all, color="black"))
|
|
306
|
+
self.select_all_wells_btn.setIconSize(QSize(20, 20))
|
|
307
|
+
self.display_positions()
|
|
308
|
+
|
|
309
|
+
def select_all_positions(self):
|
|
310
|
+
|
|
311
|
+
if not self.select_all_pos_option:
|
|
312
|
+
self.position_list.selectAll()
|
|
313
|
+
self.select_all_pos_option = True
|
|
314
|
+
self.select_all_pos_btn.setIcon(
|
|
315
|
+
icon(MDI6.select_all, color=self.celldetective_blue)
|
|
316
|
+
)
|
|
317
|
+
self.select_all_pos_btn.setIconSize(QSize(20, 20))
|
|
318
|
+
else:
|
|
319
|
+
self.position_list.unselectAll()
|
|
320
|
+
self.select_all_pos_option = False
|
|
321
|
+
self.select_all_pos_btn.setIcon(icon(MDI6.select_all, color="black"))
|
|
322
|
+
self.select_all_pos_btn.setIconSize(QSize(20, 20))
|
|
323
|
+
|
|
324
|
+
def locate_image(self):
|
|
325
|
+
"""
|
|
326
|
+
Load the first frame of the first movie found in the experiment folder as a sample.
|
|
327
|
+
"""
|
|
328
|
+
|
|
329
|
+
movies = glob(self.pos + os.sep.join(["movie", f"{self.movie_prefix}*.tif"]))
|
|
330
|
+
|
|
331
|
+
if len(movies) == 0:
|
|
332
|
+
generic_message("Please select a position containing a movie...")
|
|
333
|
+
self.current_stack = None
|
|
334
|
+
return None
|
|
335
|
+
else:
|
|
336
|
+
self.current_stack = movies[0]
|
|
337
|
+
|
|
338
|
+
def view_current_stack(self):
|
|
339
|
+
|
|
340
|
+
if self.bg_loader.isFinished() and hasattr(self.bg_loader, "StackVisualizer"):
|
|
341
|
+
StackVisualizer = self.bg_loader.StackVisualizer
|
|
342
|
+
else:
|
|
343
|
+
from celldetective.gui.viewers.base_viewer import StackVisualizer
|
|
344
|
+
|
|
345
|
+
self.locate_image()
|
|
346
|
+
if self.current_stack is not None:
|
|
347
|
+
self.viewer = StackVisualizer(
|
|
348
|
+
stack_path=self.current_stack,
|
|
349
|
+
window_title=f"Position {self.position_list.currentText()}",
|
|
350
|
+
frame_slider=True,
|
|
351
|
+
contrast_slider=True,
|
|
352
|
+
channel_cb=True,
|
|
353
|
+
channel_names=self.exp_channels,
|
|
354
|
+
n_channels=self.nbr_channels,
|
|
355
|
+
PxToUm=self.PxToUm,
|
|
356
|
+
)
|
|
357
|
+
|
|
358
|
+
# Not working for some reason
|
|
359
|
+
# def post_widget(widget):
|
|
360
|
+
# try:
|
|
361
|
+
# widget.resize(widget.width() + 1, widget.height() + 1)
|
|
362
|
+
# center_window(widget)
|
|
363
|
+
# except Exception as e:
|
|
364
|
+
# traceback.print_exc()
|
|
365
|
+
|
|
366
|
+
self.viewer.show()
|
|
367
|
+
|
|
368
|
+
def open_experiment_folder(self):
|
|
369
|
+
|
|
370
|
+
try:
|
|
371
|
+
subprocess.Popen(f"explorer {os.path.realpath(self.exp_dir)}")
|
|
372
|
+
except:
|
|
373
|
+
try:
|
|
374
|
+
os.system('xdg-open "%s"' % self.exp_dir)
|
|
375
|
+
except:
|
|
376
|
+
return None
|
|
377
|
+
|
|
378
|
+
def load_configuration(self):
|
|
379
|
+
"""
|
|
380
|
+
This methods load the configuration read in the config.ini file of the experiment.
|
|
381
|
+
"""
|
|
382
|
+
|
|
383
|
+
logger.info("Reading experiment configuration...")
|
|
384
|
+
self.exp_config = get_config(self.exp_dir)
|
|
385
|
+
|
|
386
|
+
self.populations = get_experiment_populations(self.exp_dir)
|
|
387
|
+
self.PxToUm = get_spatial_calibration(self.exp_dir)
|
|
388
|
+
self.FrameToMin = get_temporal_calibration(self.exp_dir)
|
|
389
|
+
|
|
390
|
+
self.len_movie = int(
|
|
391
|
+
config_section_to_dict(self.exp_config, "MovieSettings")["len_movie"]
|
|
392
|
+
)
|
|
393
|
+
self.shape_x = int(
|
|
394
|
+
config_section_to_dict(self.exp_config, "MovieSettings")["shape_x"]
|
|
395
|
+
)
|
|
396
|
+
self.shape_y = int(
|
|
397
|
+
config_section_to_dict(self.exp_config, "MovieSettings")["shape_y"]
|
|
398
|
+
)
|
|
399
|
+
self.movie_prefix = config_section_to_dict(self.exp_config, "MovieSettings")[
|
|
400
|
+
"movie_prefix"
|
|
401
|
+
]
|
|
402
|
+
|
|
403
|
+
# Read channels
|
|
404
|
+
self.exp_channels, channel_indices = extract_experiment_channels(self.exp_dir)
|
|
405
|
+
self.nbr_channels = len(self.exp_channels)
|
|
406
|
+
|
|
407
|
+
number_of_wells = len(self.wells)
|
|
408
|
+
self.well_labels = _extract_labels_from_config(self.exp_config, number_of_wells)
|
|
409
|
+
|
|
410
|
+
self.concentrations = get_experiment_concentrations(self.exp_dir)
|
|
411
|
+
self.cell_types = get_experiment_cell_types(self.exp_dir)
|
|
412
|
+
self.antibodies = get_experiment_antibodies(self.exp_dir)
|
|
413
|
+
self.pharmaceutical_agents = get_experiment_pharmaceutical_agents(self.exp_dir)
|
|
414
|
+
|
|
415
|
+
self.metadata = config_section_to_dict(self.exp_config, "Metadata")
|
|
416
|
+
logger.info("Experiment configuration successfully read...")
|
|
417
|
+
|
|
418
|
+
def closeEvent(self, event):
|
|
419
|
+
"""
|
|
420
|
+
Close child windows if closed.
|
|
421
|
+
"""
|
|
422
|
+
|
|
423
|
+
for process_block in self.ProcessPopulations:
|
|
424
|
+
try:
|
|
425
|
+
if process_block.SegModelLoader:
|
|
426
|
+
process_block.SegModelLoader.close()
|
|
427
|
+
except:
|
|
428
|
+
pass
|
|
429
|
+
try:
|
|
430
|
+
if process_block.ConfigTracking:
|
|
431
|
+
process_block.ConfigTracking.close()
|
|
432
|
+
except:
|
|
433
|
+
pass
|
|
434
|
+
try:
|
|
435
|
+
if process_block.ConfigSignalTrain:
|
|
436
|
+
process_block.ConfigSignalTrain.close()
|
|
437
|
+
except:
|
|
438
|
+
pass
|
|
439
|
+
try:
|
|
440
|
+
if process_block.ConfigMeasurements:
|
|
441
|
+
process_block.ConfigMeasurements.close()
|
|
442
|
+
except:
|
|
443
|
+
pass
|
|
444
|
+
try:
|
|
445
|
+
if process_block.ConfigSignalAnnotator:
|
|
446
|
+
process_block.ConfigSignalAnnotator.close()
|
|
447
|
+
except:
|
|
448
|
+
pass
|
|
449
|
+
try:
|
|
450
|
+
if process_block.tab_ui:
|
|
451
|
+
process_block.tab_ui.close()
|
|
452
|
+
except:
|
|
453
|
+
pass
|
|
454
|
+
|
|
455
|
+
try:
|
|
456
|
+
if self.cfg_editor:
|
|
457
|
+
self.cfg_editor.close()
|
|
458
|
+
except:
|
|
459
|
+
pass
|
|
460
|
+
|
|
461
|
+
gc.collect()
|
|
462
|
+
|
|
463
|
+
def display_positions(self):
|
|
464
|
+
"""
|
|
465
|
+
Show the positions as the well is changed.
|
|
466
|
+
"""
|
|
467
|
+
|
|
468
|
+
if self.well_list.isMultipleSelection():
|
|
469
|
+
|
|
470
|
+
self.position_list.clear()
|
|
471
|
+
position_linspace = np.linspace(
|
|
472
|
+
0, len(self.positions[0]) - 1, len(self.positions[0]), dtype=int
|
|
473
|
+
)
|
|
474
|
+
position_linspace = [str(s) for s in position_linspace]
|
|
475
|
+
self.position_list.addItems(position_linspace)
|
|
476
|
+
if self.select_all_pos_option:
|
|
477
|
+
self.select_all_pos_btn.click()
|
|
478
|
+
self.select_all_pos_btn.click()
|
|
479
|
+
|
|
480
|
+
elif not self.well_list.isAnySelected():
|
|
481
|
+
|
|
482
|
+
self.position_list.unselectAll()
|
|
483
|
+
if self.select_all_pos_option:
|
|
484
|
+
self.select_all_pos_btn.click()
|
|
485
|
+
|
|
486
|
+
else:
|
|
487
|
+
pos_index = self.well_list.getSelectedIndices()[0]
|
|
488
|
+
self.position_list.clear()
|
|
489
|
+
self.position_list.addItems(self.positions[pos_index])
|
|
490
|
+
if self.select_all_pos_option:
|
|
491
|
+
self.select_all_pos_btn.click()
|
|
492
|
+
self.position_list.setCurrentIndex(0)
|
|
493
|
+
|
|
494
|
+
self.update_position_options()
|
|
495
|
+
|
|
496
|
+
def open_config_editor(self):
|
|
497
|
+
from celldetective.gui.json_readers import ConfigEditor
|
|
498
|
+
|
|
499
|
+
self.cfg_editor = ConfigEditor(self)
|
|
500
|
+
self.cfg_editor.show()
|
|
501
|
+
|
|
502
|
+
def locate_selected_position(self):
|
|
503
|
+
"""
|
|
504
|
+
Set the current position if the option one well, one positon is selected
|
|
505
|
+
Display error messages otherwise.
|
|
506
|
+
|
|
507
|
+
"""
|
|
508
|
+
|
|
509
|
+
if self.well_list.isMultipleSelection():
|
|
510
|
+
generic_message("Please select a single well...")
|
|
511
|
+
return False
|
|
512
|
+
else:
|
|
513
|
+
self.well_index = (
|
|
514
|
+
self.well_list.getSelectedIndices()
|
|
515
|
+
) # [self.well_list.currentIndex()]
|
|
516
|
+
|
|
517
|
+
for w_idx in self.well_index:
|
|
518
|
+
|
|
519
|
+
pos = self.positions[w_idx]
|
|
520
|
+
if not self.position_list.isSingleSelection():
|
|
521
|
+
generic_message("Please select a single position...")
|
|
522
|
+
return False
|
|
523
|
+
else:
|
|
524
|
+
pos_indices = self.position_list.getSelectedIndices()
|
|
525
|
+
|
|
526
|
+
well = self.wells[w_idx]
|
|
527
|
+
|
|
528
|
+
for pos_idx in pos_indices:
|
|
529
|
+
|
|
530
|
+
self.pos = self.position_paths[w_idx][pos_idx]
|
|
531
|
+
if not os.path.exists(self.pos + "output"):
|
|
532
|
+
os.mkdir(self.pos + "output")
|
|
533
|
+
if not os.path.exists(self.pos + os.sep.join(["output", "tables"])):
|
|
534
|
+
os.mkdir(self.pos + os.sep.join(["output", "tables"]))
|
|
535
|
+
|
|
536
|
+
return True
|
|
537
|
+
|
|
538
|
+
def create_config_dir(self):
|
|
539
|
+
|
|
540
|
+
self.config_folder = self.exp_dir + "configs" + os.sep
|
|
541
|
+
if not os.path.exists(self.config_folder):
|
|
542
|
+
os.mkdir(self.config_folder)
|
|
543
|
+
|
|
544
|
+
def update_position_options(self):
|
|
545
|
+
|
|
546
|
+
self.pos = self.position_list.currentText()
|
|
547
|
+
|
|
548
|
+
if (
|
|
549
|
+
self.position_list.isMultipleSelection()
|
|
550
|
+
or not self.position_list.isAnySelected()
|
|
551
|
+
):
|
|
552
|
+
|
|
553
|
+
for p in self.ProcessPopulations:
|
|
554
|
+
p.check_seg_btn.setEnabled(False)
|
|
555
|
+
p.check_tracking_result_btn.setEnabled(False)
|
|
556
|
+
p.view_tab_btn.setEnabled(True)
|
|
557
|
+
p.signal_analysis_action.setEnabled(True)
|
|
558
|
+
p.check_seg_btn.setEnabled(False)
|
|
559
|
+
p.check_tracking_result_btn.setEnabled(False)
|
|
560
|
+
p.check_measurements_btn.setEnabled(False)
|
|
561
|
+
p.check_signals_btn.setEnabled(False)
|
|
562
|
+
p.delete_tracks_btn.hide()
|
|
563
|
+
|
|
564
|
+
self.NeighPanel.view_tab_btn.setEnabled(True)
|
|
565
|
+
self.NeighPanel.check_signals_btn.setEnabled(False)
|
|
566
|
+
self.view_stack_btn.setEnabled(False)
|
|
567
|
+
|
|
568
|
+
elif self.well_list.isMultipleSelection():
|
|
569
|
+
|
|
570
|
+
for p in self.ProcessPopulations:
|
|
571
|
+
p.view_tab_btn.setEnabled(True)
|
|
572
|
+
p.signal_analysis_action.setEnabled(True)
|
|
573
|
+
p.delete_tracks_btn.hide()
|
|
574
|
+
|
|
575
|
+
self.NeighPanel.view_tab_btn.setEnabled(True)
|
|
576
|
+
self.view_stack_btn.setEnabled(False)
|
|
577
|
+
if hasattr(self, "delete_tracks_btn"):
|
|
578
|
+
self.delete_tracks_btn.hide()
|
|
579
|
+
else:
|
|
580
|
+
|
|
581
|
+
if self.well_list.isAnySelected() and self.position_list.isAnySelected():
|
|
582
|
+
|
|
583
|
+
self.locate_selected_position()
|
|
584
|
+
self.view_stack_btn.setEnabled(True)
|
|
585
|
+
for i, p in enumerate(self.ProcessPopulations):
|
|
586
|
+
p.check_seg_btn.setEnabled(True)
|
|
587
|
+
if os.path.exists(
|
|
588
|
+
os.sep.join(
|
|
589
|
+
[
|
|
590
|
+
self.pos,
|
|
591
|
+
"output",
|
|
592
|
+
"tables",
|
|
593
|
+
f"trajectories_{self.populations[i]}.csv",
|
|
594
|
+
]
|
|
595
|
+
)
|
|
596
|
+
):
|
|
597
|
+
try:
|
|
598
|
+
import pandas as pd
|
|
599
|
+
|
|
600
|
+
cols = pd.read_csv(
|
|
601
|
+
os.sep.join(
|
|
602
|
+
[
|
|
603
|
+
self.pos,
|
|
604
|
+
"output",
|
|
605
|
+
"tables",
|
|
606
|
+
f"trajectories_{self.populations[i]}.csv",
|
|
607
|
+
]
|
|
608
|
+
),
|
|
609
|
+
nrows=0,
|
|
610
|
+
).columns
|
|
611
|
+
except Exception as e:
|
|
612
|
+
continue
|
|
613
|
+
|
|
614
|
+
if "TRACK_ID" in cols:
|
|
615
|
+
id_col = "TRACK_ID"
|
|
616
|
+
elif "ID" in cols:
|
|
617
|
+
id_col = "ID"
|
|
618
|
+
else:
|
|
619
|
+
id_col = None
|
|
620
|
+
p.check_measurements_btn.setEnabled(True)
|
|
621
|
+
|
|
622
|
+
if id_col == "TRACK_ID":
|
|
623
|
+
p.check_signals_btn.setEnabled(True)
|
|
624
|
+
p.delete_tracks_btn.show()
|
|
625
|
+
p.signal_analysis_action.setEnabled(True)
|
|
626
|
+
p.check_tracking_result_btn.setEnabled(True)
|
|
627
|
+
else:
|
|
628
|
+
p.signal_analysis_action.setEnabled(False)
|
|
629
|
+
p.check_tracking_result_btn.setEnabled(False)
|
|
630
|
+
|
|
631
|
+
p.view_tab_btn.setEnabled(True)
|
|
632
|
+
p.classify_btn.setEnabled(True)
|
|
633
|
+
else:
|
|
634
|
+
p.check_measurements_btn.setEnabled(False)
|
|
635
|
+
p.check_signals_btn.setEnabled(False)
|
|
636
|
+
p.view_tab_btn.setEnabled(False)
|
|
637
|
+
p.classify_btn.setEnabled(False)
|
|
638
|
+
p.delete_tracks_btn.hide()
|
|
639
|
+
p.signal_analysis_action.setEnabled(False)
|
|
640
|
+
|
|
641
|
+
if os.path.exists(
|
|
642
|
+
os.sep.join(
|
|
643
|
+
[self.pos, "output", "tables", "trajectories_pairs.csv"]
|
|
644
|
+
)
|
|
645
|
+
):
|
|
646
|
+
self.NeighPanel.view_tab_btn.setEnabled(True)
|
|
647
|
+
self.NeighPanel.check_signals_btn.setEnabled(True)
|
|
648
|
+
else:
|
|
649
|
+
self.NeighPanel.view_tab_btn.setEnabled(False)
|
|
650
|
+
self.NeighPanel.check_signals_btn.setEnabled(False)
|