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,22 +1,35 @@
|
|
|
1
|
-
from PyQt5.QtWidgets import
|
|
2
|
-
|
|
1
|
+
from PyQt5.QtWidgets import (
|
|
2
|
+
QComboBox,
|
|
3
|
+
QCheckBox,
|
|
4
|
+
QLineEdit,
|
|
5
|
+
QVBoxLayout,
|
|
6
|
+
QLabel,
|
|
7
|
+
QHBoxLayout,
|
|
8
|
+
QPushButton,
|
|
9
|
+
)
|
|
3
10
|
from PyQt5.QtCore import Qt
|
|
4
11
|
from PyQt5.QtGui import QDoubleValidator
|
|
5
12
|
|
|
6
|
-
from celldetective.gui.
|
|
13
|
+
from celldetective.gui.base.components import generic_message
|
|
14
|
+
from celldetective.gui.base.utils import center_window
|
|
7
15
|
from celldetective.gui.generic_signal_plot import GenericSignalPlotWidget
|
|
8
16
|
from superqt import QLabeledSlider, QColormapComboBox, QSearchableComboBox
|
|
9
|
-
from celldetective
|
|
10
|
-
|
|
17
|
+
from celldetective import (
|
|
18
|
+
get_software_location,
|
|
19
|
+
)
|
|
20
|
+
from celldetective.utils.data_cleaning import extract_cols_from_table_list
|
|
21
|
+
from celldetective.utils.parsing import _extract_labels_from_config
|
|
22
|
+
from celldetective.utils.data_loaders import load_experiment_tables
|
|
11
23
|
from celldetective.signals import mean_signal
|
|
12
24
|
import numpy as np
|
|
13
25
|
import os
|
|
14
26
|
import matplotlib.pyplot as plt
|
|
15
|
-
|
|
27
|
+
|
|
28
|
+
plt.rcParams["svg.fonttype"] = "none"
|
|
16
29
|
from glob import glob
|
|
17
30
|
from natsort import natsorted
|
|
18
31
|
import math
|
|
19
|
-
from celldetective.gui import CelldetectiveWidget
|
|
32
|
+
from celldetective.gui.base.components import CelldetectiveWidget
|
|
20
33
|
from matplotlib import colormaps
|
|
21
34
|
import matplotlib.cm
|
|
22
35
|
from celldetective.relative_measurements import expand_pair_table
|
|
@@ -24,504 +37,709 @@ from celldetective.neighborhood import extract_neighborhood_in_pair_table
|
|
|
24
37
|
|
|
25
38
|
|
|
26
39
|
class ConfigSignalPlot(CelldetectiveWidget):
|
|
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
|
-
|
|
40
|
+
"""
|
|
41
|
+
UI to set survival instructions.
|
|
42
|
+
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
def __init__(self, parent_window=None):
|
|
46
|
+
|
|
47
|
+
super().__init__()
|
|
48
|
+
self.parent_window = parent_window
|
|
49
|
+
self.setWindowTitle("Configure signal plot")
|
|
50
|
+
self.exp_dir = self.parent_window.exp_dir
|
|
51
|
+
self.soft_path = get_software_location()
|
|
52
|
+
self.exp_config = self.exp_dir + "config.ini"
|
|
53
|
+
self.wells = np.array(self.parent_window.parent_window.wells, dtype=str)
|
|
54
|
+
self.well_labels = _extract_labels_from_config(self.exp_config, len(self.wells))
|
|
55
|
+
self.FrameToMin = self.parent_window.parent_window.FrameToMin
|
|
56
|
+
self.float_validator = QDoubleValidator()
|
|
57
|
+
self.target_class = [0, 1]
|
|
58
|
+
self.show_ci = True
|
|
59
|
+
self.show_cell_lines = False
|
|
60
|
+
self.ax2 = None
|
|
61
|
+
self.auto_close = False
|
|
62
|
+
|
|
63
|
+
self.well_option = (
|
|
64
|
+
self.parent_window.parent_window.well_list.getSelectedIndices()
|
|
65
|
+
)
|
|
66
|
+
self.position_option = (
|
|
67
|
+
self.parent_window.parent_window.position_list.getSelectedIndices()
|
|
68
|
+
)
|
|
69
|
+
self.interpret_pos_location()
|
|
70
|
+
|
|
71
|
+
self.screen_height = (
|
|
72
|
+
self.parent_window.parent_window.parent_window.screen_height
|
|
73
|
+
)
|
|
74
|
+
self.populate_widget()
|
|
75
|
+
|
|
76
|
+
if self.auto_close:
|
|
77
|
+
self.close()
|
|
78
|
+
|
|
79
|
+
def interpret_pos_location(self):
|
|
80
|
+
"""
|
|
81
|
+
Read the well/position selection from the control panel to decide which data to load
|
|
82
|
+
Set position_indices to None if all positions must be taken
|
|
83
|
+
|
|
84
|
+
"""
|
|
85
|
+
|
|
86
|
+
self.well_indices = (
|
|
87
|
+
self.parent_window.parent_window.well_list.getSelectedIndices()
|
|
88
|
+
)
|
|
89
|
+
self.position_indices = (
|
|
90
|
+
self.parent_window.parent_window.position_list.getSelectedIndices()
|
|
91
|
+
)
|
|
92
|
+
if not self.parent_window.parent_window.position_list.isAnySelected():
|
|
93
|
+
self.position_indices = None
|
|
94
|
+
|
|
95
|
+
def populate_widget(self):
|
|
96
|
+
"""
|
|
97
|
+
Create the multibox design.
|
|
98
|
+
|
|
99
|
+
"""
|
|
100
|
+
|
|
101
|
+
# Create button widget and layout
|
|
102
|
+
main_layout = QVBoxLayout()
|
|
103
|
+
self.setLayout(main_layout)
|
|
104
|
+
main_layout.setContentsMargins(30, 30, 30, 30)
|
|
105
|
+
panel_title = QLabel("Options")
|
|
106
|
+
panel_title.setStyleSheet(
|
|
107
|
+
"""
|
|
89
108
|
font-weight: bold;
|
|
90
109
|
padding: 0px;
|
|
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
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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
|
-
|
|
110
|
+
"""
|
|
111
|
+
)
|
|
112
|
+
main_layout.addWidget(panel_title, alignment=Qt.AlignCenter)
|
|
113
|
+
|
|
114
|
+
pops = []
|
|
115
|
+
self.cols_per_pop = {}
|
|
116
|
+
for population in self.parent_window.parent_window.populations:
|
|
117
|
+
tables = glob(
|
|
118
|
+
self.exp_dir
|
|
119
|
+
+ os.sep.join(
|
|
120
|
+
["W*", "*", "output", "tables", f"trajectories_{population}.csv"]
|
|
121
|
+
)
|
|
122
|
+
)
|
|
123
|
+
if len(tables) > 0:
|
|
124
|
+
pops.append(population)
|
|
125
|
+
cols = extract_cols_from_table_list(tables)
|
|
126
|
+
|
|
127
|
+
# check for neighbor pairs
|
|
128
|
+
neigh_cols = [
|
|
129
|
+
c for c in cols if c.startswith("inclusive_count_neighborhood")
|
|
130
|
+
]
|
|
131
|
+
neigh_pairs = [
|
|
132
|
+
c.split("_(")[-1].split(")_")[0].split("-") for c in neigh_cols
|
|
133
|
+
]
|
|
134
|
+
neigh_pairs = ["-".join(c) for c in neigh_pairs]
|
|
135
|
+
for k in range(len(neigh_pairs)):
|
|
136
|
+
if "_self_" in neigh_pairs[k]:
|
|
137
|
+
neigh_pairs[k] = "-".join([population, population])
|
|
138
|
+
pops.extend(neigh_pairs)
|
|
139
|
+
|
|
140
|
+
self.cols_per_pop.update({population: cols})
|
|
141
|
+
|
|
142
|
+
# pops = []
|
|
143
|
+
# for population in self.parent_window.parent_window.populations+['pairs']:
|
|
144
|
+
# tables = glob(self.exp_dir+os.sep.join(['W*','*','output','tables',f'trajectories_{population}.csv']))
|
|
145
|
+
# if len(tables)>0:
|
|
146
|
+
# pops.append(population)
|
|
147
|
+
|
|
148
|
+
labels = [
|
|
149
|
+
QLabel("population: "),
|
|
150
|
+
QLabel("class: "),
|
|
151
|
+
QLabel("time of\ninterest: "),
|
|
152
|
+
QLabel("cmap: "),
|
|
153
|
+
]
|
|
154
|
+
self.cb_options = [pops, [], [], []]
|
|
155
|
+
self.cbs = [QComboBox() for i in range(len(labels))]
|
|
156
|
+
self.cbs[-1] = QColormapComboBox()
|
|
157
|
+
|
|
158
|
+
self.cbs[0].currentIndexChanged.connect(self.set_classes_and_times)
|
|
159
|
+
|
|
160
|
+
choice_layout = QVBoxLayout()
|
|
161
|
+
choice_layout.setContentsMargins(20, 20, 20, 20)
|
|
162
|
+
for i in range(len(labels)):
|
|
163
|
+
hbox = QHBoxLayout()
|
|
164
|
+
hbox.addWidget(labels[i], 33)
|
|
165
|
+
hbox.addWidget(self.cbs[i], 66)
|
|
166
|
+
if i < len(labels) - 1:
|
|
167
|
+
self.cbs[i].addItems(self.cb_options[i])
|
|
168
|
+
choice_layout.addLayout(hbox)
|
|
169
|
+
|
|
170
|
+
all_cms = list(colormaps)
|
|
171
|
+
for cm in all_cms:
|
|
172
|
+
if hasattr(matplotlib.cm, str(cm).lower()):
|
|
173
|
+
try:
|
|
174
|
+
self.cbs[-1].addColormap(cm.lower())
|
|
175
|
+
except:
|
|
176
|
+
pass
|
|
177
|
+
|
|
178
|
+
self.cbs[0].setCurrentIndex(1)
|
|
179
|
+
self.cbs[0].setCurrentIndex(0)
|
|
180
|
+
|
|
181
|
+
self.abs_time_checkbox = QCheckBox("absolute time")
|
|
182
|
+
self.frame_slider = QLabeledSlider()
|
|
183
|
+
self.frame_slider.setSingleStep(1)
|
|
184
|
+
self.frame_slider.setOrientation(Qt.Horizontal)
|
|
185
|
+
self.frame_slider.setRange(0, self.parent_window.parent_window.len_movie)
|
|
186
|
+
self.frame_slider.setValue(0)
|
|
187
|
+
self.frame_slider.setEnabled(False)
|
|
188
|
+
slider_hbox = QHBoxLayout()
|
|
189
|
+
slider_hbox.addWidget(self.abs_time_checkbox, 33)
|
|
190
|
+
slider_hbox.addWidget(self.frame_slider, 66)
|
|
191
|
+
choice_layout.addLayout(slider_hbox)
|
|
192
|
+
main_layout.addLayout(choice_layout)
|
|
193
|
+
|
|
194
|
+
self.abs_time_checkbox.stateChanged.connect(self.switch_ref_time_mode)
|
|
195
|
+
|
|
196
|
+
select_layout = QHBoxLayout()
|
|
197
|
+
select_layout.setContentsMargins(20, 3, 20, 3)
|
|
198
|
+
select_layout.addWidget(QLabel("select cells\nwith query: "), 33)
|
|
199
|
+
self.query_le = QLineEdit()
|
|
200
|
+
select_layout.addWidget(self.query_le, 66)
|
|
201
|
+
main_layout.addLayout(select_layout)
|
|
202
|
+
|
|
203
|
+
time_calib_layout = QHBoxLayout()
|
|
204
|
+
time_calib_layout.setContentsMargins(20, 3, 20, 3)
|
|
205
|
+
time_calib_layout.addWidget(QLabel("time calibration\n(frame to min)"), 33)
|
|
206
|
+
self.time_calibration_le = QLineEdit(str(self.FrameToMin).replace(".", ","))
|
|
207
|
+
self.time_calibration_le.setValidator(self.float_validator)
|
|
208
|
+
time_calib_layout.addWidget(self.time_calibration_le, 66)
|
|
209
|
+
# time_calib_layout.addWidget(QLabel(' min'))
|
|
210
|
+
main_layout.addLayout(time_calib_layout)
|
|
211
|
+
|
|
212
|
+
pool_layout = QHBoxLayout()
|
|
213
|
+
pool_layout.setContentsMargins(20, 3, 20, 3)
|
|
214
|
+
self.pool_option_cb = QComboBox()
|
|
215
|
+
self.pool_option_cb.addItems(["mean", "median"])
|
|
216
|
+
pool_layout.addWidget(QLabel("pool\nprojection:"), 33)
|
|
217
|
+
pool_layout.addWidget(self.pool_option_cb, 66)
|
|
218
|
+
main_layout.addLayout(pool_layout)
|
|
219
|
+
|
|
220
|
+
n_cells_layout = QHBoxLayout()
|
|
221
|
+
n_cells_layout.setContentsMargins(20, 3, 20, 3)
|
|
222
|
+
self.n_cells_slider = QLabeledSlider()
|
|
223
|
+
self.n_cells_slider.setSingleStep(1)
|
|
224
|
+
self.n_cells_slider.setOrientation(Qt.Horizontal)
|
|
225
|
+
self.n_cells_slider.setRange(1, 100)
|
|
226
|
+
self.n_cells_slider.setValue(2)
|
|
227
|
+
n_cells_layout.addWidget(QLabel("min # cells\nfor pool:"), 33)
|
|
228
|
+
n_cells_layout.addWidget(self.n_cells_slider, 66)
|
|
229
|
+
main_layout.addLayout(n_cells_layout)
|
|
230
|
+
|
|
231
|
+
self.submit_btn = QPushButton("Submit")
|
|
232
|
+
self.submit_btn.setStyleSheet(self.button_style_sheet)
|
|
233
|
+
self.submit_btn.clicked.connect(self.process_signal)
|
|
234
|
+
main_layout.addWidget(self.submit_btn)
|
|
235
|
+
|
|
236
|
+
# self.populate_left_panel()
|
|
237
|
+
# grid.addLayout(self.left_side, 0, 0, 1, 1)
|
|
238
|
+
|
|
239
|
+
# self.setCentralWidget(self.scroll_area)
|
|
240
|
+
# self.show()
|
|
241
|
+
|
|
242
|
+
def set_classes_and_times(self):
|
|
243
|
+
|
|
244
|
+
# Look for all classes and times
|
|
245
|
+
self.neighborhood_keys = None
|
|
246
|
+
self.population = self.cbs[0].currentText()
|
|
247
|
+
pop_split = self.population.split("-")
|
|
248
|
+
|
|
249
|
+
if len(pop_split) == 2:
|
|
250
|
+
|
|
251
|
+
self.population = "pairs"
|
|
252
|
+
tables_pairs = glob(
|
|
253
|
+
self.exp_dir
|
|
254
|
+
+ os.sep.join(
|
|
255
|
+
["W*", "*", "output", "tables", f"trajectories_pairs.csv"]
|
|
256
|
+
)
|
|
257
|
+
)
|
|
258
|
+
if not tables_pairs:
|
|
259
|
+
print("No pair table found... please compute the pair measurements...")
|
|
260
|
+
return None
|
|
261
|
+
self.cols_pairs = extract_cols_from_table_list(tables_pairs)
|
|
262
|
+
|
|
263
|
+
self.population_reference = pop_split[0]
|
|
264
|
+
self.population_neigh = pop_split[1]
|
|
265
|
+
|
|
266
|
+
cols_ref = self.cols_per_pop[self.population_reference]
|
|
267
|
+
cols_neigh = self.cols_per_pop[self.population_neigh]
|
|
268
|
+
|
|
269
|
+
time_cols_ref = np.array(
|
|
270
|
+
[s.startswith("t_") or s == "t0" for s in cols_ref]
|
|
271
|
+
)
|
|
272
|
+
if len(time_cols_ref) > 0:
|
|
273
|
+
time_cols_ref = list(cols_ref[time_cols_ref])
|
|
274
|
+
time_cols_ref = ["reference_" + t for t in time_cols_ref]
|
|
275
|
+
|
|
276
|
+
time_cols_neigh = np.array(
|
|
277
|
+
[s.startswith("t_") or s == "t0" for s in cols_neigh]
|
|
278
|
+
)
|
|
279
|
+
if len(time_cols_neigh) > 0:
|
|
280
|
+
time_cols_neigh = list(cols_neigh[time_cols_neigh])
|
|
281
|
+
time_cols_neigh = ["neighbor_" + t for t in time_cols_neigh]
|
|
282
|
+
|
|
283
|
+
if self.population_reference != self.population_neigh:
|
|
284
|
+
self.neighborhood_keys = [
|
|
285
|
+
c[16:]
|
|
286
|
+
for c in cols_ref
|
|
287
|
+
if c.startswith("inclusive_count_neighborhood")
|
|
288
|
+
and str(self.population_neigh) in c
|
|
289
|
+
]
|
|
290
|
+
else:
|
|
291
|
+
self.neighborhood_keys = [
|
|
292
|
+
c[16:]
|
|
293
|
+
for c in cols_ref
|
|
294
|
+
if c.startswith("inclusive_count_neighborhood")
|
|
295
|
+
and str(self.population_neigh) not in c
|
|
296
|
+
]
|
|
297
|
+
|
|
298
|
+
time_idx = np.array(
|
|
299
|
+
[s.startswith("t_") or s.startswith("t0") for s in self.cols_pairs]
|
|
300
|
+
)
|
|
301
|
+
time_cols_pairs = list(self.cols_pairs[time_idx])
|
|
302
|
+
time_columns = time_cols_ref + time_cols_neigh + time_cols_pairs
|
|
303
|
+
|
|
304
|
+
class_cols_ref = [
|
|
305
|
+
c.replace("reference_t_", "reference_class_") for c in time_cols_ref
|
|
306
|
+
]
|
|
307
|
+
class_cols_neigh = [
|
|
308
|
+
c.replace("neighbor_t_", "neighbor_class_") for c in time_cols_neigh
|
|
309
|
+
]
|
|
310
|
+
class_cols_pairs = [
|
|
311
|
+
c.replace("t_", "class_") for c in time_cols_neigh if c.startswith("t_")
|
|
312
|
+
]
|
|
313
|
+
class_columns = class_cols_ref + class_cols_neigh + class_cols_pairs
|
|
314
|
+
else:
|
|
315
|
+
tables = natsorted(
|
|
316
|
+
glob(
|
|
317
|
+
self.exp_dir
|
|
318
|
+
+ os.sep.join(
|
|
319
|
+
[
|
|
320
|
+
"W*",
|
|
321
|
+
"*",
|
|
322
|
+
"output",
|
|
323
|
+
"tables",
|
|
324
|
+
f"trajectories_{self.population}.csv",
|
|
325
|
+
]
|
|
326
|
+
)
|
|
327
|
+
)
|
|
328
|
+
)
|
|
329
|
+
self.all_columns = extract_cols_from_table_list(tables)
|
|
330
|
+
|
|
331
|
+
class_idx = np.array([s.startswith("class_") for s in self.all_columns])
|
|
332
|
+
time_idx = np.array(
|
|
333
|
+
[s.startswith("t_") or s.startswith("t0_") for s in self.all_columns]
|
|
334
|
+
)
|
|
335
|
+
print(f"{class_idx=} {time_idx=} {self.all_columns=}")
|
|
336
|
+
|
|
337
|
+
try:
|
|
338
|
+
if len(class_idx) > 0:
|
|
339
|
+
class_columns = list(self.all_columns[class_idx])
|
|
340
|
+
else:
|
|
341
|
+
class_columns = []
|
|
342
|
+
if len(time_idx) > 0:
|
|
343
|
+
time_columns = list(self.all_columns[time_idx])
|
|
344
|
+
else:
|
|
345
|
+
time_columns = []
|
|
346
|
+
except Exception as e:
|
|
347
|
+
print(f"L266 columns not found {e}")
|
|
348
|
+
self.auto_close = True
|
|
349
|
+
return None
|
|
350
|
+
|
|
351
|
+
if "class" in self.all_columns:
|
|
352
|
+
class_columns.append("class")
|
|
353
|
+
if "t0" in self.all_columns:
|
|
354
|
+
time_columns.append("t0")
|
|
355
|
+
|
|
356
|
+
self.class_columns = np.unique(class_columns)
|
|
357
|
+
self.time_columns = np.unique(time_columns)
|
|
358
|
+
thresh = 30
|
|
359
|
+
self.class_truncated = [
|
|
360
|
+
w[: thresh - 3] + "..." if len(w) > thresh else w
|
|
361
|
+
for w in self.class_columns
|
|
362
|
+
]
|
|
363
|
+
self.time_truncated = [
|
|
364
|
+
w[: thresh - 3] + "..." if len(w) > thresh else w for w in self.time_columns
|
|
365
|
+
]
|
|
366
|
+
|
|
367
|
+
self.cbs[2].clear()
|
|
368
|
+
self.cbs[2].addItems(self.time_truncated)
|
|
369
|
+
for i in range(len(self.time_columns)):
|
|
370
|
+
self.cbs[2].setItemData(i, self.time_columns[i], Qt.ToolTipRole)
|
|
371
|
+
|
|
372
|
+
self.cbs[1].clear()
|
|
373
|
+
self.cbs[1].addItems(self.class_truncated)
|
|
374
|
+
for i in range(len(self.class_columns)):
|
|
375
|
+
self.cbs[1].setItemData(i, self.class_columns[i], Qt.ToolTipRole)
|
|
376
|
+
|
|
377
|
+
def ask_for_feature(self):
|
|
378
|
+
|
|
379
|
+
cols = np.array(list(self.df.columns))
|
|
380
|
+
is_number = np.vectorize(lambda x: np.issubdtype(x, np.number))
|
|
381
|
+
feats = cols[is_number(self.df.dtypes)]
|
|
382
|
+
|
|
383
|
+
self.feature_choice_widget = CelldetectiveWidget()
|
|
384
|
+
self.feature_choice_widget.setWindowTitle("Select numeric feature")
|
|
385
|
+
layout = QVBoxLayout()
|
|
386
|
+
self.feature_choice_widget.setLayout(layout)
|
|
387
|
+
self.feature_cb = QComboBox()
|
|
388
|
+
self.feature_cb.addItems(feats)
|
|
389
|
+
hbox = QHBoxLayout()
|
|
390
|
+
hbox.addWidget(QLabel("feature: "), 33)
|
|
391
|
+
hbox.addWidget(self.feature_cb, 66)
|
|
392
|
+
layout.addLayout(hbox)
|
|
393
|
+
|
|
394
|
+
self.set_feature_btn = QPushButton("set")
|
|
395
|
+
self.set_feature_btn.clicked.connect(self.compute_signals)
|
|
396
|
+
layout.addWidget(self.set_feature_btn)
|
|
397
|
+
self.feature_choice_widget.show()
|
|
398
|
+
center_window(self.feature_choice_widget)
|
|
399
|
+
|
|
400
|
+
def ask_for_features(self):
|
|
401
|
+
|
|
402
|
+
cols = np.array(list(self.df.columns))
|
|
403
|
+
is_number = np.vectorize(lambda x: np.issubdtype(x, np.number))
|
|
404
|
+
feats = cols[is_number(self.df.dtypes)]
|
|
405
|
+
|
|
406
|
+
self.feature_choice_widget = CelldetectiveWidget()
|
|
407
|
+
self.feature_choice_widget.setWindowTitle("Select numeric feature")
|
|
408
|
+
layout = QVBoxLayout()
|
|
409
|
+
self.feature_choice_widget.setLayout(layout)
|
|
410
|
+
self.feature_cb = QSearchableComboBox()
|
|
411
|
+
self.feature_cb.addItems(feats)
|
|
412
|
+
hbox = QHBoxLayout()
|
|
413
|
+
hbox.addWidget(QLabel("feature: "), 33)
|
|
414
|
+
hbox.addWidget(self.feature_cb, 66)
|
|
415
|
+
# hbox.addWidget((QLabel('Plot two features')))
|
|
416
|
+
layout.addLayout(hbox)
|
|
417
|
+
|
|
418
|
+
self.set_feature_btn = QPushButton("set")
|
|
419
|
+
self.set_feature_btn.setStyleSheet(self.button_style_sheet)
|
|
420
|
+
self.set_feature_btn.clicked.connect(self.compute_signals)
|
|
421
|
+
layout.addWidget(self.set_feature_btn)
|
|
422
|
+
self.feature_choice_widget.show()
|
|
423
|
+
center_window(self.feature_choice_widget)
|
|
424
|
+
|
|
425
|
+
# def enable_second_feature(self):
|
|
426
|
+
# if self.checkBox_feature.isChecked():
|
|
427
|
+
# self.feature_two_cb.setEnabled(True)
|
|
428
|
+
# else:
|
|
429
|
+
# self.feature_two_cb.setEnabled(False)
|
|
430
|
+
|
|
431
|
+
def compute_signals(self):
|
|
432
|
+
|
|
433
|
+
if self.df is not None:
|
|
434
|
+
|
|
435
|
+
try:
|
|
436
|
+
query_text = self.query_le.text()
|
|
437
|
+
if query_text != "":
|
|
438
|
+
self.df = self.df.query(query_text)
|
|
439
|
+
except Exception as e:
|
|
440
|
+
print(e, " The query is misunderstood and will not be applied...")
|
|
441
|
+
|
|
442
|
+
self.feature_selected = self.feature_cb.currentText()
|
|
443
|
+
self.feature_choice_widget.close()
|
|
444
|
+
self.compute_signal_functions()
|
|
445
|
+
if self.open_widget:
|
|
446
|
+
self.interpret_pos_location()
|
|
447
|
+
try:
|
|
448
|
+
self.plot_window = GenericSignalPlotWidget(
|
|
449
|
+
parent_window=self,
|
|
450
|
+
df=self.df,
|
|
451
|
+
df_pos_info=self.df_pos_info,
|
|
452
|
+
df_well_info=self.df_well_info,
|
|
453
|
+
feature_selected=self.feature_selected,
|
|
454
|
+
title="plot signals",
|
|
455
|
+
)
|
|
456
|
+
self.plot_window.show()
|
|
457
|
+
except Exception as e:
|
|
458
|
+
print(f"{e=}")
|
|
459
|
+
|
|
460
|
+
def process_signal(self):
|
|
461
|
+
|
|
462
|
+
self.FrameToMin = float(self.time_calibration_le.text().replace(",", "."))
|
|
463
|
+
print(f"Time calibration set to 1 frame = {self.FrameToMin} min...")
|
|
464
|
+
|
|
465
|
+
# read instructions from combobox options
|
|
466
|
+
self.load_available_tables()
|
|
467
|
+
class_col = self.class_columns[self.cbs[1].currentIndex()]
|
|
468
|
+
print(f"{class_col=}")
|
|
469
|
+
|
|
470
|
+
if self.df is not None:
|
|
471
|
+
|
|
472
|
+
if class_col not in list(self.df.columns):
|
|
473
|
+
generic_message(
|
|
474
|
+
"The class of interest could not be found in the data. Abort."
|
|
475
|
+
)
|
|
476
|
+
return None
|
|
477
|
+
else:
|
|
478
|
+
self.ask_for_features()
|
|
479
|
+
else:
|
|
480
|
+
return None
|
|
481
|
+
|
|
482
|
+
# self.plotvbox.addWidget(self.line_choice_widget, alignment=Qt.AlignCenter)
|
|
483
|
+
|
|
484
|
+
def load_available_tables(self):
|
|
485
|
+
"""
|
|
486
|
+
Load the tables of the selected wells/positions from the control Panel for the population of interest
|
|
487
|
+
|
|
488
|
+
"""
|
|
489
|
+
|
|
490
|
+
self.well_option = (
|
|
491
|
+
self.parent_window.parent_window.well_list.getSelectedIndices()
|
|
492
|
+
)
|
|
493
|
+
self.position_option = (
|
|
494
|
+
self.parent_window.parent_window.position_list.getSelectedIndices()
|
|
495
|
+
)
|
|
496
|
+
|
|
497
|
+
self.df, self.df_pos_info = load_experiment_tables(
|
|
498
|
+
self.exp_dir,
|
|
499
|
+
well_option=self.well_option,
|
|
500
|
+
position_option=self.position_option,
|
|
501
|
+
population=self.population,
|
|
502
|
+
return_pos_info=True,
|
|
503
|
+
)
|
|
504
|
+
|
|
505
|
+
if self.population == "pairs":
|
|
506
|
+
self.df = expand_pair_table(self.df)
|
|
507
|
+
self.df = extract_neighborhood_in_pair_table(
|
|
508
|
+
self.df,
|
|
509
|
+
reference_population=self.population_reference,
|
|
510
|
+
neighbor_population=self.population_neigh,
|
|
511
|
+
neighborhood_key=self.neighborhood_keys[0],
|
|
512
|
+
contact_only=True,
|
|
513
|
+
)
|
|
514
|
+
|
|
515
|
+
if self.df is None:
|
|
516
|
+
print("No table could be found...")
|
|
517
|
+
generic_message("No table could be found to compute survival...")
|
|
518
|
+
self.close()
|
|
519
|
+
return None
|
|
520
|
+
else:
|
|
521
|
+
self.df_well_info = self.df_pos_info.loc[
|
|
522
|
+
:, ["well_path", "well_index", "well_name", "well_number", "well_alias"]
|
|
523
|
+
].drop_duplicates()
|
|
524
|
+
|
|
525
|
+
def compute_signal_functions(self):
|
|
526
|
+
|
|
527
|
+
# Check to move at the beginning
|
|
528
|
+
self.open_widget = True
|
|
529
|
+
if len(self.time_columns) == 0:
|
|
530
|
+
generic_message("No synchronizing time is available...")
|
|
531
|
+
self.open_widget = False
|
|
532
|
+
return None
|
|
533
|
+
|
|
534
|
+
# Per position signal
|
|
535
|
+
self.df = self.df.dropna(subset=["FRAME"])
|
|
536
|
+
if len(self.df) == 0:
|
|
537
|
+
print(
|
|
538
|
+
"Warning... The dataset is empty. Please check your filters. Abort..."
|
|
539
|
+
)
|
|
540
|
+
return None
|
|
541
|
+
|
|
542
|
+
pairs = False
|
|
543
|
+
if self.population == "pairs":
|
|
544
|
+
pairs = True
|
|
545
|
+
|
|
546
|
+
max_time = int(self.df.FRAME.max()) + 1
|
|
547
|
+
class_col = self.class_columns[self.cbs[1].currentIndex()]
|
|
548
|
+
time_col = self.time_columns[self.cbs[2].currentIndex()]
|
|
549
|
+
if self.abs_time_checkbox.isChecked():
|
|
550
|
+
time_col = self.frame_slider.value()
|
|
551
|
+
|
|
552
|
+
for block, movie_group in self.df.groupby(["well", "position"]):
|
|
553
|
+
|
|
554
|
+
well_signal_mean, well_std_mean, timeline_all, matrix_all = mean_signal(
|
|
555
|
+
movie_group,
|
|
556
|
+
self.feature_selected,
|
|
557
|
+
class_col,
|
|
558
|
+
time_col=time_col,
|
|
559
|
+
class_value=None,
|
|
560
|
+
return_matrix=True,
|
|
561
|
+
forced_max_duration=max_time,
|
|
562
|
+
projection=self.pool_option_cb.currentText(),
|
|
563
|
+
min_nbr_values=self.n_cells_slider.value(),
|
|
564
|
+
pairs=pairs,
|
|
565
|
+
)
|
|
566
|
+
well_signal_event, well_std_event, timeline_event, matrix_event = (
|
|
567
|
+
mean_signal(
|
|
568
|
+
movie_group,
|
|
569
|
+
self.feature_selected,
|
|
570
|
+
class_col,
|
|
571
|
+
time_col=time_col,
|
|
572
|
+
class_value=[0],
|
|
573
|
+
return_matrix=True,
|
|
574
|
+
forced_max_duration=max_time,
|
|
575
|
+
projection=self.pool_option_cb.currentText(),
|
|
576
|
+
min_nbr_values=self.n_cells_slider.value(),
|
|
577
|
+
pairs=pairs,
|
|
578
|
+
)
|
|
579
|
+
)
|
|
580
|
+
(
|
|
581
|
+
well_signal_no_event,
|
|
582
|
+
well_std_no_event,
|
|
583
|
+
timeline_no_event,
|
|
584
|
+
matrix_no_event,
|
|
585
|
+
) = mean_signal(
|
|
586
|
+
movie_group,
|
|
587
|
+
self.feature_selected,
|
|
588
|
+
class_col,
|
|
589
|
+
time_col=time_col,
|
|
590
|
+
class_value=[1],
|
|
591
|
+
return_matrix=True,
|
|
592
|
+
forced_max_duration=max_time,
|
|
593
|
+
projection=self.pool_option_cb.currentText(),
|
|
594
|
+
min_nbr_values=self.n_cells_slider.value(),
|
|
595
|
+
pairs=pairs,
|
|
596
|
+
)
|
|
597
|
+
self.mean_plots_timeline = timeline_all
|
|
598
|
+
|
|
599
|
+
self.df_pos_info.loc[self.df_pos_info["pos_path"] == block[1], "signal"] = [
|
|
600
|
+
{
|
|
601
|
+
"mean_all": well_signal_mean,
|
|
602
|
+
"std_all": well_std_mean,
|
|
603
|
+
"matrix_all": matrix_all,
|
|
604
|
+
"mean_event": well_signal_event,
|
|
605
|
+
"std_event": well_std_event,
|
|
606
|
+
"matrix_event": matrix_event,
|
|
607
|
+
"mean_no_event": well_signal_no_event,
|
|
608
|
+
"std_no_event": well_std_no_event,
|
|
609
|
+
"matrix_no_event": matrix_no_event,
|
|
610
|
+
"timeline": self.mean_plots_timeline,
|
|
611
|
+
}
|
|
612
|
+
]
|
|
613
|
+
|
|
614
|
+
# Per well
|
|
615
|
+
for well, well_group in self.df.groupby("well"):
|
|
616
|
+
|
|
617
|
+
well_signal_mean, well_std_mean, timeline_all, matrix_all = mean_signal(
|
|
618
|
+
well_group,
|
|
619
|
+
self.feature_selected,
|
|
620
|
+
class_col,
|
|
621
|
+
time_col=time_col,
|
|
622
|
+
class_value=None,
|
|
623
|
+
return_matrix=True,
|
|
624
|
+
forced_max_duration=max_time,
|
|
625
|
+
projection=self.pool_option_cb.currentText(),
|
|
626
|
+
min_nbr_values=self.n_cells_slider.value(),
|
|
627
|
+
pairs=pairs,
|
|
628
|
+
)
|
|
629
|
+
well_signal_event, well_std_event, timeline_event, matrix_event = (
|
|
630
|
+
mean_signal(
|
|
631
|
+
well_group,
|
|
632
|
+
self.feature_selected,
|
|
633
|
+
class_col,
|
|
634
|
+
time_col=time_col,
|
|
635
|
+
class_value=[0],
|
|
636
|
+
return_matrix=True,
|
|
637
|
+
forced_max_duration=max_time,
|
|
638
|
+
projection=self.pool_option_cb.currentText(),
|
|
639
|
+
min_nbr_values=self.n_cells_slider.value(),
|
|
640
|
+
pairs=pairs,
|
|
641
|
+
)
|
|
642
|
+
)
|
|
643
|
+
(
|
|
644
|
+
well_signal_no_event,
|
|
645
|
+
well_std_no_event,
|
|
646
|
+
timeline_no_event,
|
|
647
|
+
matrix_no_event,
|
|
648
|
+
) = mean_signal(
|
|
649
|
+
well_group,
|
|
650
|
+
self.feature_selected,
|
|
651
|
+
class_col,
|
|
652
|
+
time_col=time_col,
|
|
653
|
+
class_value=[1],
|
|
654
|
+
return_matrix=True,
|
|
655
|
+
forced_max_duration=max_time,
|
|
656
|
+
projection=self.pool_option_cb.currentText(),
|
|
657
|
+
min_nbr_values=self.n_cells_slider.value(),
|
|
658
|
+
pairs=pairs,
|
|
659
|
+
)
|
|
660
|
+
|
|
661
|
+
self.df_well_info.loc[self.df_well_info["well_path"] == well, "signal"] = [
|
|
662
|
+
{
|
|
663
|
+
"mean_all": well_signal_mean,
|
|
664
|
+
"std_all": well_std_mean,
|
|
665
|
+
"matrix_all": matrix_all,
|
|
666
|
+
"mean_event": well_signal_event,
|
|
667
|
+
"std_event": well_std_event,
|
|
668
|
+
"matrix_event": matrix_event,
|
|
669
|
+
"mean_no_event": well_signal_no_event,
|
|
670
|
+
"std_no_event": well_std_no_event,
|
|
671
|
+
"matrix_no_event": matrix_no_event,
|
|
672
|
+
"timeline": self.mean_plots_timeline,
|
|
673
|
+
}
|
|
674
|
+
]
|
|
675
|
+
|
|
676
|
+
self.df_pos_info.loc[:, "select"] = True
|
|
677
|
+
self.df_well_info.loc[:, "select"] = True
|
|
678
|
+
|
|
679
|
+
def generate_synchronized_matrix(
|
|
680
|
+
self, well_group, feature_selected, cclass, max_time
|
|
681
|
+
):
|
|
682
|
+
|
|
683
|
+
if isinstance(cclass, int):
|
|
684
|
+
cclass = [cclass]
|
|
685
|
+
|
|
686
|
+
class_col = self.class_columns[self.cbs[1].currentIndex()]
|
|
687
|
+
time_col = self.time_columns[self.cbs[2].currentIndex()]
|
|
688
|
+
|
|
689
|
+
n_cells = len(well_group.groupby(["position", "TRACK_ID"]))
|
|
690
|
+
depth = int(2 * max_time + 3)
|
|
691
|
+
matrix = np.zeros((n_cells, depth))
|
|
692
|
+
matrix[:, :] = np.nan
|
|
693
|
+
mapping = np.arange(-max_time - 1, max_time + 2)
|
|
694
|
+
cid = 0
|
|
695
|
+
for block, movie_group in well_group.groupby("position"):
|
|
696
|
+
for tid, track_group in movie_group.loc[
|
|
697
|
+
movie_group[class_col].isin(cclass)
|
|
698
|
+
].groupby("TRACK_ID"):
|
|
699
|
+
try:
|
|
700
|
+
timeline = track_group["FRAME"].to_numpy().astype(int)
|
|
701
|
+
feature = track_group[feature_selected].to_numpy()
|
|
702
|
+
if self.checkBox_feature.isChecked():
|
|
703
|
+
second_feature = track_group[
|
|
704
|
+
self.second_feature_selected
|
|
705
|
+
].to_numpy()
|
|
706
|
+
if (
|
|
707
|
+
self.cbs[2].currentText().startswith("t")
|
|
708
|
+
and not self.abs_time_checkbox.isChecked()
|
|
709
|
+
):
|
|
710
|
+
t0 = math.floor(track_group[time_col].to_numpy()[0])
|
|
711
|
+
timeline -= t0
|
|
712
|
+
elif (
|
|
713
|
+
self.cbs[2].currentText() == "first detection"
|
|
714
|
+
and not self.abs_time_checkbox.isChecked()
|
|
715
|
+
):
|
|
716
|
+
|
|
717
|
+
if "area" in list(track_group.columns):
|
|
718
|
+
print("area in list")
|
|
719
|
+
feat = track_group["area"].values
|
|
720
|
+
else:
|
|
721
|
+
feat = feature
|
|
722
|
+
|
|
723
|
+
first_detection = timeline[feat == feat][0]
|
|
724
|
+
timeline -= first_detection
|
|
725
|
+
|
|
726
|
+
elif self.abs_time_checkbox.isChecked():
|
|
727
|
+
timeline -= int(self.frame_slider.value())
|
|
728
|
+
|
|
729
|
+
loc_t = [np.where(mapping == t)[0][0] for t in timeline]
|
|
730
|
+
matrix[cid, loc_t] = feature
|
|
731
|
+
if second_feature:
|
|
732
|
+
matrix[cid, loc_t + 1] = second_feature
|
|
733
|
+
|
|
734
|
+
cid += 1
|
|
735
|
+
except:
|
|
736
|
+
pass
|
|
737
|
+
return matrix
|
|
738
|
+
|
|
739
|
+
def switch_ref_time_mode(self):
|
|
740
|
+
if self.abs_time_checkbox.isChecked():
|
|
741
|
+
self.frame_slider.setEnabled(True)
|
|
742
|
+
self.cbs[-2].setEnabled(False)
|
|
743
|
+
else:
|
|
744
|
+
self.frame_slider.setEnabled(False)
|
|
745
|
+
self.cbs[-2].setEnabled(True)
|