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
|
@@ -3,12 +3,20 @@ import os
|
|
|
3
3
|
import numpy as np
|
|
4
4
|
import pandas as pd
|
|
5
5
|
from PyQt5.QtGui import QKeySequence
|
|
6
|
-
from PyQt5.QtWidgets import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
from PyQt5.QtWidgets import (
|
|
7
|
+
QApplication,
|
|
8
|
+
QCheckBox,
|
|
9
|
+
QFileDialog,
|
|
10
|
+
QLineEdit,
|
|
11
|
+
QMessageBox,
|
|
12
|
+
QHBoxLayout,
|
|
13
|
+
QRadioButton,
|
|
14
|
+
QShortcut,
|
|
15
|
+
QVBoxLayout,
|
|
16
|
+
QPushButton,
|
|
17
|
+
QComboBox,
|
|
18
|
+
QLabel,
|
|
19
|
+
)
|
|
12
20
|
from PyQt5.QtCore import QSize, Qt
|
|
13
21
|
import matplotlib.pyplot as plt
|
|
14
22
|
from matplotlib.ticker import MultipleLocator
|
|
@@ -19,768 +27,893 @@ from superqt.fonticon import icon
|
|
|
19
27
|
from fonticon_mdi6 import MDI6
|
|
20
28
|
import json
|
|
21
29
|
|
|
22
|
-
from celldetective.gui import Styles
|
|
23
|
-
from celldetective.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
from celldetective.gui.base.styles import Styles
|
|
31
|
+
from celldetective.gui.base.components import (
|
|
32
|
+
CelldetectiveWidget,
|
|
33
|
+
CelldetectiveMainWindow,
|
|
34
|
+
)
|
|
35
|
+
from celldetective import get_software_location
|
|
36
|
+
from celldetective.utils.image_loaders import auto_load_number_of_frames, load_frames
|
|
37
|
+
from celldetective.utils.experiment import (
|
|
38
|
+
extract_experiment_channels,
|
|
39
|
+
get_experiment_metadata,
|
|
40
|
+
get_experiment_labels,
|
|
41
|
+
)
|
|
42
|
+
from celldetective.gui.gui_utils import (
|
|
43
|
+
color_from_status,
|
|
44
|
+
color_from_class,
|
|
45
|
+
ExportPlotBtn,
|
|
46
|
+
)
|
|
47
|
+
from celldetective.gui.base.figure_canvas import FigureCanvas
|
|
48
|
+
from celldetective.gui.base.utils import center_window
|
|
27
49
|
import gc
|
|
28
50
|
|
|
51
|
+
|
|
29
52
|
class BaseAnnotator(CelldetectiveMainWindow, Styles):
|
|
30
53
|
|
|
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
|
-
|
|
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
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
54
|
+
def __init__(self, parent_window=None, read_config=True):
|
|
55
|
+
|
|
56
|
+
super().__init__()
|
|
57
|
+
self.parent_window = parent_window
|
|
58
|
+
self.read_config = read_config
|
|
59
|
+
|
|
60
|
+
self.mode = self.parent_window.mode
|
|
61
|
+
self.pos = self.parent_window.parent_window.pos
|
|
62
|
+
self.exp_dir = self.parent_window.exp_dir
|
|
63
|
+
self.PxToUm = self.parent_window.parent_window.PxToUm
|
|
64
|
+
self.n_signals = 3
|
|
65
|
+
self.soft_path = get_software_location()
|
|
66
|
+
self.recently_modified = False
|
|
67
|
+
self.selection = []
|
|
68
|
+
self.MinMaxScaler = MinMaxScaler()
|
|
69
|
+
self.fraction = 1
|
|
70
|
+
self.log_scale = False
|
|
71
|
+
|
|
72
|
+
self.instructions_path = self.exp_dir + os.sep.join(
|
|
73
|
+
["configs", f"signal_annotator_config_{self.mode}.json"]
|
|
74
|
+
)
|
|
75
|
+
self.trajectories_path = self.pos + os.sep.join(
|
|
76
|
+
["output", "tables", f"trajectories_{self.mode}.csv"]
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
self.screen_height = (
|
|
80
|
+
self.parent_window.parent_window.parent_window.screen_height
|
|
81
|
+
)
|
|
82
|
+
self.screen_width = self.parent_window.parent_window.parent_window.screen_width
|
|
83
|
+
self.value_magnitude = 1
|
|
84
|
+
|
|
85
|
+
self.setMinimumWidth(int(0.8 * self.screen_width))
|
|
86
|
+
self.setMinimumHeight(int(0.8 * self.screen_height))
|
|
87
|
+
|
|
88
|
+
self.proceed = True
|
|
89
|
+
self.locate_stack()
|
|
90
|
+
if not self.proceed:
|
|
91
|
+
self.close()
|
|
92
|
+
else:
|
|
93
|
+
if self.read_config:
|
|
94
|
+
self.load_annotator_config()
|
|
95
|
+
self.locate_tracks()
|
|
96
|
+
self._init_base_widgets()
|
|
97
|
+
|
|
98
|
+
def _init_base_widgets(self):
|
|
99
|
+
self._init_base_widgets_left()
|
|
100
|
+
self._init_base_widgets_right()
|
|
101
|
+
|
|
102
|
+
def _init_base_widgets_right(self):
|
|
103
|
+
pass
|
|
104
|
+
|
|
105
|
+
def _init_base_widgets_left(self):
|
|
106
|
+
|
|
107
|
+
self.class_label = QLabel("event: ")
|
|
108
|
+
self.class_choice_cb = QComboBox()
|
|
109
|
+
|
|
110
|
+
cols = np.array(self.df_tracks.columns)
|
|
111
|
+
self.class_cols = np.array(
|
|
112
|
+
[c.startswith("class") for c in list(self.df_tracks.columns)]
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
self.class_cols = list(cols[self.class_cols])
|
|
116
|
+
try:
|
|
117
|
+
self.class_cols.remove("class_id")
|
|
118
|
+
except Exception:
|
|
119
|
+
pass
|
|
120
|
+
try:
|
|
121
|
+
self.class_cols.remove("class_color")
|
|
122
|
+
except Exception:
|
|
123
|
+
pass
|
|
124
|
+
|
|
125
|
+
self.class_choice_cb.addItems(self.class_cols)
|
|
126
|
+
self.class_choice_cb.currentIndexChanged.connect(self.compute_status_and_colors)
|
|
127
|
+
|
|
128
|
+
self.add_class_btn = QPushButton("")
|
|
129
|
+
self.add_class_btn.setStyleSheet(self.button_select_all)
|
|
130
|
+
self.add_class_btn.setIcon(icon(MDI6.plus, color="black"))
|
|
131
|
+
self.add_class_btn.setToolTip("Add a new event class")
|
|
132
|
+
self.add_class_btn.setIconSize(QSize(20, 20))
|
|
133
|
+
self.add_class_btn.clicked.connect(self.create_new_event_class)
|
|
134
|
+
|
|
135
|
+
self.del_class_btn = QPushButton("")
|
|
136
|
+
self.del_class_btn.setStyleSheet(self.button_select_all)
|
|
137
|
+
self.del_class_btn.setIcon(icon(MDI6.delete, color="black"))
|
|
138
|
+
self.del_class_btn.setToolTip("Delete an event class")
|
|
139
|
+
self.del_class_btn.setIconSize(QSize(20, 20))
|
|
140
|
+
self.del_class_btn.clicked.connect(self.del_event_class)
|
|
141
|
+
|
|
142
|
+
self.cell_info = QLabel("")
|
|
143
|
+
|
|
144
|
+
self.correct_btn = QPushButton("correct")
|
|
145
|
+
self.correct_btn.setIcon(icon(MDI6.redo_variant, color="white"))
|
|
146
|
+
self.correct_btn.setIconSize(QSize(20, 20))
|
|
147
|
+
self.correct_btn.setStyleSheet(self.button_style_sheet)
|
|
148
|
+
self.correct_btn.clicked.connect(self.show_annotation_buttons)
|
|
149
|
+
self.correct_btn.setEnabled(False)
|
|
150
|
+
|
|
151
|
+
self.cancel_btn = QPushButton("cancel")
|
|
152
|
+
self.cancel_btn.setStyleSheet(self.button_style_sheet_2)
|
|
153
|
+
self.cancel_btn.setShortcut(QKeySequence("Esc"))
|
|
154
|
+
self.cancel_btn.setEnabled(False)
|
|
155
|
+
self.cancel_btn.clicked.connect(self.cancel_selection)
|
|
156
|
+
|
|
157
|
+
self._init_cell_fig_widgets()
|
|
158
|
+
|
|
159
|
+
self.save_btn = QPushButton("Save")
|
|
160
|
+
self.save_btn.setStyleSheet(self.button_style_sheet)
|
|
161
|
+
self.save_btn.clicked.connect(self.save_trajectories)
|
|
162
|
+
|
|
163
|
+
self.export_btn = QPushButton("")
|
|
164
|
+
self.export_btn.setStyleSheet(self.button_select_all)
|
|
165
|
+
self.export_btn.clicked.connect(self.export_signals)
|
|
166
|
+
self.export_btn.setIcon(icon(MDI6.export, color="black"))
|
|
167
|
+
self.export_btn.setIconSize(QSize(25, 25))
|
|
168
|
+
|
|
169
|
+
def _init_cell_fig_widgets(self):
|
|
170
|
+
|
|
171
|
+
self.generate_signal_choices()
|
|
172
|
+
self.create_cell_signal_canvas()
|
|
173
|
+
self.cell_fcanvas.setMinimumHeight(int(0.2 * self.screen_height))
|
|
174
|
+
|
|
175
|
+
self.outliers_check = QCheckBox("Show outliers")
|
|
176
|
+
self.outliers_check.toggled.connect(self.show_outliers)
|
|
177
|
+
|
|
178
|
+
self.normalize_features_btn = QPushButton("")
|
|
179
|
+
self.normalize_features_btn.setStyleSheet(self.button_select_all)
|
|
180
|
+
self.normalize_features_btn.setIcon(
|
|
181
|
+
icon(MDI6.arrow_collapse_vertical, color="black")
|
|
182
|
+
)
|
|
183
|
+
self.normalize_features_btn.setIconSize(QSize(25, 25))
|
|
184
|
+
self.normalize_features_btn.setFixedSize(QSize(30, 30))
|
|
185
|
+
self.normalize_features_btn.clicked.connect(self.normalize_features)
|
|
186
|
+
self.normalized_signals = False
|
|
187
|
+
|
|
188
|
+
self.log_btn = QPushButton()
|
|
189
|
+
self.log_btn.setIcon(icon(MDI6.math_log, color="black"))
|
|
190
|
+
self.log_btn.setStyleSheet(self.button_select_all)
|
|
191
|
+
self.log_btn.clicked.connect(self.switch_to_log)
|
|
192
|
+
|
|
193
|
+
self.export_plot_btn = ExportPlotBtn(self.cell_fig, export_dir=self.exp_dir)
|
|
194
|
+
|
|
195
|
+
def close_without_new_class(self):
|
|
196
|
+
self.newClassWidget.close()
|
|
197
|
+
|
|
198
|
+
def init_class_selection_block(self):
|
|
199
|
+
|
|
200
|
+
self.class_hbox = QHBoxLayout()
|
|
201
|
+
self.class_hbox.setContentsMargins(0, 0, 0, 0)
|
|
202
|
+
|
|
203
|
+
self.class_hbox.addWidget(self.class_label, 25)
|
|
204
|
+
self.class_hbox.addWidget(self.class_choice_cb, 70)
|
|
205
|
+
self.class_hbox.addWidget(self.add_class_btn, 5)
|
|
206
|
+
self.class_hbox.addWidget(self.del_class_btn, 5)
|
|
207
|
+
|
|
208
|
+
def init_options_block(self):
|
|
209
|
+
self.options_hbox = QHBoxLayout()
|
|
210
|
+
self.options_hbox.setContentsMargins(0, 0, 0, 0)
|
|
211
|
+
|
|
212
|
+
def init_correction_block(self):
|
|
213
|
+
self.action_hbox = QHBoxLayout()
|
|
214
|
+
self.action_hbox.setContentsMargins(0, 0, 0, 0)
|
|
215
|
+
|
|
216
|
+
self.action_hbox.addWidget(self.correct_btn)
|
|
217
|
+
self.action_hbox.addWidget(self.cancel_btn)
|
|
218
|
+
|
|
219
|
+
def init_plot_buttons_block(self):
|
|
220
|
+
self.plot_buttons_hbox = QHBoxLayout()
|
|
221
|
+
self.plot_buttons_hbox.setContentsMargins(0, 0, 0, 0)
|
|
222
|
+
self.plot_buttons_hbox.addWidget(QLabel(""), 90)
|
|
223
|
+
self.plot_buttons_hbox.addWidget(self.outliers_check, 5)
|
|
224
|
+
self.plot_buttons_hbox.addWidget(self.normalize_features_btn, 5)
|
|
225
|
+
self.plot_buttons_hbox.addWidget(self.log_btn, 5)
|
|
226
|
+
self.plot_buttons_hbox.addWidget(self.export_plot_btn, 5)
|
|
227
|
+
|
|
228
|
+
def init_save_btn_block(self):
|
|
229
|
+
|
|
230
|
+
self.btn_hbox = QHBoxLayout()
|
|
231
|
+
self.btn_hbox.setContentsMargins(0, 10, 0, 0)
|
|
232
|
+
self.btn_hbox.addWidget(self.save_btn, 90)
|
|
233
|
+
self.btn_hbox.addWidget(self.export_btn, 10)
|
|
234
|
+
|
|
235
|
+
def populate_window(self):
|
|
236
|
+
"""
|
|
237
|
+
Create the multibox design.
|
|
238
|
+
|
|
239
|
+
"""
|
|
240
|
+
|
|
241
|
+
# Main layout
|
|
242
|
+
self.button_widget = CelldetectiveWidget()
|
|
243
|
+
self.main_layout = QHBoxLayout()
|
|
244
|
+
self.button_widget.setLayout(self.main_layout)
|
|
245
|
+
self.main_layout.setContentsMargins(30, 30, 30, 30)
|
|
246
|
+
|
|
247
|
+
# Left panel
|
|
248
|
+
self.left_panel = QVBoxLayout()
|
|
249
|
+
self.left_panel.setContentsMargins(30, 5, 30, 5)
|
|
250
|
+
self.left_panel.setSpacing(3)
|
|
251
|
+
|
|
252
|
+
self.init_class_selection_block()
|
|
253
|
+
self.left_panel.addLayout(self.class_hbox, 5)
|
|
254
|
+
self.left_panel.addWidget(self.cell_info, 10)
|
|
255
|
+
|
|
256
|
+
self.init_options_block()
|
|
257
|
+
self.init_correction_block()
|
|
258
|
+
self.left_panel.addLayout(self.options_hbox, 5)
|
|
259
|
+
self.left_panel.addLayout(self.action_hbox, 5)
|
|
260
|
+
|
|
261
|
+
self.left_panel.addWidget(self.cell_fcanvas, 45)
|
|
262
|
+
|
|
263
|
+
self.init_plot_buttons_block()
|
|
264
|
+
self.left_panel.addLayout(self.plot_buttons_hbox, 5)
|
|
265
|
+
|
|
266
|
+
signal_choice_vbox = QVBoxLayout()
|
|
267
|
+
signal_choice_vbox.setContentsMargins(30, 0, 30, 0)
|
|
268
|
+
for i in range(len(self.signal_choice_cb)):
|
|
269
|
+
hlayout = QHBoxLayout()
|
|
270
|
+
hlayout.addWidget(self.signal_choice_label[i], 20)
|
|
271
|
+
hlayout.addWidget(self.signal_choice_cb[i], 75)
|
|
272
|
+
signal_choice_vbox.addLayout(hlayout)
|
|
273
|
+
|
|
274
|
+
self.left_panel.addLayout(signal_choice_vbox, 15)
|
|
275
|
+
|
|
276
|
+
self.init_save_btn_block()
|
|
277
|
+
self.left_panel.addLayout(self.btn_hbox, 5)
|
|
278
|
+
|
|
279
|
+
# Right panel
|
|
280
|
+
self.right_panel = QVBoxLayout()
|
|
281
|
+
|
|
282
|
+
# add left/right to main layout
|
|
283
|
+
self.main_layout.addLayout(self.left_panel, 35)
|
|
284
|
+
self.main_layout.addLayout(self.right_panel, 65)
|
|
285
|
+
self.button_widget.adjustSize()
|
|
286
|
+
# self.compute_status_and_colors(0)
|
|
287
|
+
|
|
288
|
+
self.setCentralWidget(self.button_widget)
|
|
289
|
+
# self.show()
|
|
290
|
+
|
|
291
|
+
self.del_shortcut = QShortcut(Qt.Key_Delete, self) # QKeySequence("s")
|
|
292
|
+
self.del_shortcut.activated.connect(self.shortcut_suppr)
|
|
293
|
+
self.del_shortcut.setEnabled(False)
|
|
294
|
+
|
|
295
|
+
QApplication.processEvents()
|
|
296
|
+
|
|
297
|
+
def generate_signal_choices(self):
|
|
298
|
+
|
|
299
|
+
self.signal_choice_cb = [QSearchableComboBox() for i in range(self.n_signals)]
|
|
300
|
+
self.signal_choice_label = [
|
|
301
|
+
QLabel(f"signal {i + 1}: ") for i in range(self.n_signals)
|
|
302
|
+
]
|
|
303
|
+
# self.log_btns = [QPushButton() for i in range(self.n_signals)]
|
|
304
|
+
|
|
305
|
+
signals = list(self.df_tracks.columns)
|
|
306
|
+
|
|
307
|
+
to_remove = [
|
|
308
|
+
"FRAME",
|
|
309
|
+
"ID",
|
|
310
|
+
"POSITION_X",
|
|
311
|
+
"POSITION_Y",
|
|
312
|
+
"TRACK_ID",
|
|
313
|
+
"antibody",
|
|
314
|
+
"cell_type",
|
|
315
|
+
"class",
|
|
316
|
+
"class_color",
|
|
317
|
+
"class_id",
|
|
318
|
+
"concentration",
|
|
319
|
+
"dummy",
|
|
320
|
+
"generation",
|
|
321
|
+
"group",
|
|
322
|
+
"group_color",
|
|
323
|
+
"index",
|
|
324
|
+
"parent",
|
|
325
|
+
"pharmaceutical_agent",
|
|
326
|
+
"pos_name",
|
|
327
|
+
"position",
|
|
328
|
+
"root",
|
|
329
|
+
"state",
|
|
330
|
+
"status",
|
|
331
|
+
"status_color",
|
|
332
|
+
"t",
|
|
333
|
+
"t0",
|
|
334
|
+
"well",
|
|
335
|
+
"well_index",
|
|
336
|
+
"well_name",
|
|
337
|
+
"x_anim",
|
|
338
|
+
"y_anim",
|
|
339
|
+
]
|
|
340
|
+
|
|
341
|
+
meta = get_experiment_metadata(self.exp_dir)
|
|
342
|
+
if meta is not None:
|
|
343
|
+
keys = list(meta.keys())
|
|
344
|
+
to_remove.extend(keys)
|
|
345
|
+
|
|
346
|
+
labels = get_experiment_labels(self.exp_dir)
|
|
347
|
+
if labels is not None:
|
|
348
|
+
keys = list(labels.keys())
|
|
349
|
+
to_remove.extend(labels)
|
|
350
|
+
|
|
351
|
+
for c in to_remove:
|
|
352
|
+
if c in signals:
|
|
353
|
+
signals.remove(c)
|
|
354
|
+
|
|
355
|
+
for i in range(len(self.signal_choice_cb)):
|
|
356
|
+
self.signal_choice_cb[i].addItems(["--"] + signals)
|
|
357
|
+
self.signal_choice_cb[i].setCurrentIndex(i + 1)
|
|
358
|
+
self.signal_choice_cb[i].currentIndexChanged.connect(self.plot_signals)
|
|
359
|
+
|
|
360
|
+
def on_scatter_pick(self, event):
|
|
361
|
+
|
|
362
|
+
self.event = event
|
|
363
|
+
|
|
364
|
+
self.correct_btn.disconnect()
|
|
365
|
+
self.correct_btn.clicked.connect(self.show_annotation_buttons)
|
|
366
|
+
|
|
367
|
+
print(f"{self.selection=}")
|
|
368
|
+
|
|
369
|
+
ind = event.ind
|
|
370
|
+
|
|
371
|
+
if len(ind) > 1:
|
|
372
|
+
# More than one point in vicinity
|
|
373
|
+
datax, datay = [self.positions[self.framedata][i, 0] for i in ind], [
|
|
374
|
+
self.positions[self.framedata][i, 1] for i in ind
|
|
375
|
+
]
|
|
376
|
+
msx, msy = event.mouseevent.xdata, event.mouseevent.ydata
|
|
377
|
+
dist = np.sqrt((np.array(datax) - msx) ** 2 + (np.array(datay) - msy) ** 2)
|
|
378
|
+
ind = [ind[np.argmin(dist)]]
|
|
379
|
+
|
|
380
|
+
if len(ind) > 0 and (len(self.selection) == 0):
|
|
381
|
+
|
|
382
|
+
self.selection.append([ind[0], self.framedata])
|
|
383
|
+
self.select_single_cell(ind[0], self.framedata)
|
|
384
|
+
|
|
385
|
+
elif len(ind) > 0 and len(self.selection) == 1:
|
|
386
|
+
self.cancel_btn.click()
|
|
387
|
+
else:
|
|
388
|
+
pass
|
|
389
|
+
|
|
390
|
+
# self.draw_frame(self.current_frame)
|
|
391
|
+
# self.fcanvas.canvas.draw()
|
|
392
|
+
#
|
|
393
|
+
|
|
394
|
+
def load_annotator_config(self):
|
|
395
|
+
"""
|
|
396
|
+
Load settings from config or set default values.
|
|
397
|
+
"""
|
|
398
|
+
|
|
399
|
+
if os.path.exists(self.instructions_path):
|
|
400
|
+
with open(self.instructions_path, "r") as f:
|
|
401
|
+
|
|
402
|
+
instructions = json.load(f)
|
|
403
|
+
|
|
404
|
+
if "rgb_mode" in instructions:
|
|
405
|
+
self.rgb_mode = instructions["rgb_mode"]
|
|
406
|
+
else:
|
|
407
|
+
self.rgb_mode = False
|
|
408
|
+
|
|
409
|
+
if "percentile_mode" in instructions:
|
|
410
|
+
self.percentile_mode = instructions["percentile_mode"]
|
|
411
|
+
else:
|
|
412
|
+
self.percentile_mode = True
|
|
413
|
+
|
|
414
|
+
if "channels" in instructions:
|
|
415
|
+
self.target_channels = instructions["channels"]
|
|
416
|
+
else:
|
|
417
|
+
self.target_channels = [[self.channel_names[0], 0.01, 99.99]]
|
|
418
|
+
|
|
419
|
+
if "fraction" in instructions:
|
|
420
|
+
self.fraction = float(instructions["fraction"])
|
|
421
|
+
else:
|
|
422
|
+
self.fraction = 0.25
|
|
423
|
+
|
|
424
|
+
if "interval" in instructions:
|
|
425
|
+
self.anim_interval = int(instructions["interval"])
|
|
426
|
+
else:
|
|
427
|
+
self.anim_interval = 1
|
|
428
|
+
|
|
429
|
+
if "log" in instructions:
|
|
430
|
+
self.log_option = instructions["log"]
|
|
431
|
+
else:
|
|
432
|
+
self.log_option = False
|
|
433
|
+
else:
|
|
434
|
+
self.rgb_mode = False
|
|
435
|
+
self.log_option = False
|
|
436
|
+
self.percentile_mode = True
|
|
437
|
+
self.target_channels = [[self.channel_names[0], 0.01, 99.99]]
|
|
438
|
+
self.fraction = 0.25
|
|
439
|
+
self.anim_interval = 1
|
|
440
|
+
|
|
441
|
+
def locate_stack(self):
|
|
442
|
+
"""
|
|
443
|
+
Locate the target movie.
|
|
444
|
+
|
|
445
|
+
"""
|
|
446
|
+
|
|
447
|
+
movies = glob(
|
|
448
|
+
self.pos
|
|
449
|
+
+ os.sep.join(
|
|
450
|
+
["movie", f"{self.parent_window.parent_window.movie_prefix}*.tif"]
|
|
451
|
+
)
|
|
452
|
+
)
|
|
453
|
+
|
|
454
|
+
if len(movies) == 0:
|
|
455
|
+
msgBox = QMessageBox()
|
|
456
|
+
msgBox.setIcon(QMessageBox.Warning)
|
|
457
|
+
msgBox.setText(
|
|
458
|
+
"No movie is detected in the experiment folder.\nPlease check the stack prefix..."
|
|
459
|
+
)
|
|
460
|
+
msgBox.setWindowTitle("Warning")
|
|
461
|
+
msgBox.setStandardButtons(QMessageBox.Ok)
|
|
462
|
+
returnValue = msgBox.exec()
|
|
463
|
+
if returnValue == QMessageBox.Ok:
|
|
464
|
+
self.proceed = False
|
|
465
|
+
self.close()
|
|
466
|
+
else:
|
|
467
|
+
self.close()
|
|
468
|
+
else:
|
|
469
|
+
self.stack_path = movies[0]
|
|
470
|
+
self.len_movie = self.parent_window.parent_window.len_movie
|
|
471
|
+
len_movie_auto = auto_load_number_of_frames(self.stack_path)
|
|
472
|
+
if len_movie_auto is not None:
|
|
473
|
+
self.len_movie = len_movie_auto
|
|
474
|
+
exp_config = self.exp_dir + "config.ini"
|
|
475
|
+
self.channel_names, self.channels = extract_experiment_channels(
|
|
476
|
+
self.exp_dir
|
|
477
|
+
)
|
|
478
|
+
self.channel_names = np.array(self.channel_names)
|
|
479
|
+
self.channels = np.array(self.channels)
|
|
480
|
+
self.nbr_channels = len(self.channels)
|
|
481
|
+
self.img = load_frames(0, self.stack_path, normalize_input=False)
|
|
482
|
+
|
|
483
|
+
def create_cell_signal_canvas(self):
|
|
484
|
+
|
|
485
|
+
self.cell_fig, self.cell_ax = plt.subplots(tight_layout=True)
|
|
486
|
+
self.cell_fcanvas = FigureCanvas(self.cell_fig, interactive=True)
|
|
487
|
+
self.cell_ax.clear()
|
|
488
|
+
|
|
489
|
+
spacing = 0.5
|
|
490
|
+
minorLocator = MultipleLocator(1)
|
|
491
|
+
self.cell_ax.xaxis.set_minor_locator(minorLocator)
|
|
492
|
+
self.cell_ax.xaxis.set_major_locator(MultipleLocator(5))
|
|
493
|
+
self.cell_ax.grid(which="major")
|
|
494
|
+
self.cell_ax.set_xlabel("time [frame]")
|
|
495
|
+
self.cell_ax.set_ylabel("signal")
|
|
496
|
+
|
|
497
|
+
self.cell_fig.set_facecolor("none") # or 'None'
|
|
498
|
+
self.cell_fig.canvas.setStyleSheet("background-color: transparent;")
|
|
499
|
+
|
|
500
|
+
self.lines = [
|
|
501
|
+
self.cell_ax.plot(
|
|
502
|
+
[np.linspace(0, self.len_movie - 1, self.len_movie)],
|
|
503
|
+
[np.zeros((self.len_movie))],
|
|
504
|
+
)[0]
|
|
505
|
+
for i in range(len(self.signal_choice_cb))
|
|
506
|
+
]
|
|
507
|
+
for i in range(len(self.lines)):
|
|
508
|
+
self.lines[i].set_label(f"signal {i}")
|
|
509
|
+
|
|
510
|
+
min_val, max_val = self.cell_ax.get_ylim()
|
|
511
|
+
(self.line_dt,) = self.cell_ax.plot(
|
|
512
|
+
[-1, -1], [min_val, max_val], c="k", linestyle="--"
|
|
513
|
+
)
|
|
514
|
+
|
|
515
|
+
self.cell_ax.set_xlim(0, self.len_movie)
|
|
516
|
+
self.cell_ax.legend(fontsize=8)
|
|
517
|
+
self.cell_fcanvas.canvas.draw()
|
|
518
|
+
|
|
519
|
+
def resizeEvent(self, event):
|
|
520
|
+
|
|
521
|
+
super().resizeEvent(event)
|
|
522
|
+
try:
|
|
523
|
+
self.cell_fig.tight_layout()
|
|
524
|
+
except:
|
|
525
|
+
pass
|
|
526
|
+
|
|
527
|
+
def locate_tracks(self):
|
|
528
|
+
"""
|
|
529
|
+
Locate the tracks.
|
|
530
|
+
"""
|
|
531
|
+
|
|
532
|
+
if not os.path.exists(self.trajectories_path):
|
|
533
|
+
|
|
534
|
+
msgBox = QMessageBox()
|
|
535
|
+
msgBox.setIcon(QMessageBox.Warning)
|
|
536
|
+
msgBox.setText("The trajectories cannot be detected.")
|
|
537
|
+
msgBox.setWindowTitle("Warning")
|
|
538
|
+
msgBox.setStandardButtons(QMessageBox.Ok)
|
|
539
|
+
returnValue = msgBox.exec()
|
|
540
|
+
if returnValue == QMessageBox.Yes:
|
|
541
|
+
self.close()
|
|
542
|
+
else:
|
|
543
|
+
|
|
544
|
+
# Load and prep tracks
|
|
545
|
+
self.df_tracks = pd.read_csv(self.trajectories_path)
|
|
546
|
+
self.df_tracks = self.df_tracks.sort_values(by=["TRACK_ID", "FRAME"])
|
|
547
|
+
self.df_tracks.replace([np.inf, -np.inf], np.nan, inplace=True)
|
|
548
|
+
|
|
549
|
+
cols = np.array(self.df_tracks.columns)
|
|
550
|
+
self.class_cols = np.array(
|
|
551
|
+
[c.startswith("class") for c in list(self.df_tracks.columns)]
|
|
552
|
+
)
|
|
553
|
+
self.class_cols = list(cols[self.class_cols])
|
|
554
|
+
try:
|
|
555
|
+
self.class_cols.remove("class_id")
|
|
556
|
+
except:
|
|
557
|
+
pass
|
|
558
|
+
try:
|
|
559
|
+
self.class_cols.remove("class_color")
|
|
560
|
+
except:
|
|
561
|
+
pass
|
|
562
|
+
if len(self.class_cols) > 0:
|
|
563
|
+
self.class_name = self.class_cols[0]
|
|
564
|
+
self.expected_status = "status"
|
|
565
|
+
suffix = self.class_name.replace("class", "").replace("_", "")
|
|
566
|
+
if suffix != "":
|
|
567
|
+
self.expected_status += "_" + suffix
|
|
568
|
+
self.expected_time = "t_" + suffix
|
|
569
|
+
else:
|
|
570
|
+
self.expected_time = "t0"
|
|
571
|
+
self.time_name = self.expected_time
|
|
572
|
+
self.status_name = self.expected_status
|
|
573
|
+
else:
|
|
574
|
+
self.class_name = "class"
|
|
575
|
+
self.time_name = "t0"
|
|
576
|
+
self.status_name = "status"
|
|
577
|
+
|
|
578
|
+
if (
|
|
579
|
+
self.time_name in self.df_tracks.columns
|
|
580
|
+
and self.class_name in self.df_tracks.columns
|
|
581
|
+
and not self.status_name in self.df_tracks.columns
|
|
582
|
+
):
|
|
583
|
+
# only create the status column if it does not exist to not erase static classification results
|
|
584
|
+
self.make_status_column()
|
|
585
|
+
elif (
|
|
586
|
+
self.time_name in self.df_tracks.columns
|
|
587
|
+
and self.class_name in self.df_tracks.columns
|
|
588
|
+
):
|
|
589
|
+
# all good, do nothing
|
|
590
|
+
pass
|
|
591
|
+
else:
|
|
592
|
+
if not self.status_name in self.df_tracks.columns:
|
|
593
|
+
self.df_tracks[self.status_name] = 0
|
|
594
|
+
self.df_tracks["status_color"] = color_from_status(0)
|
|
595
|
+
self.df_tracks["class_color"] = color_from_class(1)
|
|
596
|
+
|
|
597
|
+
if not self.class_name in self.df_tracks.columns:
|
|
598
|
+
self.df_tracks[self.class_name] = 1
|
|
599
|
+
if not self.time_name in self.df_tracks.columns:
|
|
600
|
+
self.df_tracks[self.time_name] = -1
|
|
601
|
+
|
|
602
|
+
self.df_tracks["status_color"] = [
|
|
603
|
+
color_from_status(i)
|
|
604
|
+
for i in self.df_tracks[self.status_name].to_numpy()
|
|
605
|
+
]
|
|
606
|
+
self.df_tracks["class_color"] = [
|
|
607
|
+
color_from_class(i) for i in self.df_tracks[self.class_name].to_numpy()
|
|
608
|
+
]
|
|
609
|
+
|
|
610
|
+
self.df_tracks = self.df_tracks.dropna(subset=["POSITION_X", "POSITION_Y"])
|
|
611
|
+
self.df_tracks["x_anim"] = self.df_tracks["POSITION_X"] * self.fraction
|
|
612
|
+
self.df_tracks["y_anim"] = self.df_tracks["POSITION_Y"] * self.fraction
|
|
613
|
+
self.df_tracks["x_anim"] = self.df_tracks["x_anim"].astype(int)
|
|
614
|
+
self.df_tracks["y_anim"] = self.df_tracks["y_anim"].astype(int)
|
|
615
|
+
|
|
616
|
+
self.extract_scatter_from_trajectories()
|
|
617
|
+
self.track_of_interest = self.df_tracks["TRACK_ID"].min()
|
|
618
|
+
|
|
619
|
+
self.loc_t = []
|
|
620
|
+
self.loc_idx = []
|
|
621
|
+
for t in range(len(self.tracks)):
|
|
622
|
+
indices = np.where(self.tracks[t] == self.track_of_interest)[0]
|
|
623
|
+
if len(indices) > 0:
|
|
624
|
+
self.loc_t.append(t)
|
|
625
|
+
self.loc_idx.append(indices[0])
|
|
626
|
+
|
|
627
|
+
self.MinMaxScaler = MinMaxScaler()
|
|
628
|
+
self.columns_to_rescale = list(self.df_tracks.columns)
|
|
629
|
+
|
|
630
|
+
cols_to_remove = [
|
|
631
|
+
"group",
|
|
632
|
+
"group_color",
|
|
633
|
+
"status",
|
|
634
|
+
"status_color",
|
|
635
|
+
"class_color",
|
|
636
|
+
"TRACK_ID",
|
|
637
|
+
"FRAME",
|
|
638
|
+
"x_anim",
|
|
639
|
+
"y_anim",
|
|
640
|
+
"t",
|
|
641
|
+
"dummy",
|
|
642
|
+
"group_color",
|
|
643
|
+
"state",
|
|
644
|
+
"generation",
|
|
645
|
+
"root",
|
|
646
|
+
"parent",
|
|
647
|
+
"class_id",
|
|
648
|
+
"class",
|
|
649
|
+
"t0",
|
|
650
|
+
"POSITION_X",
|
|
651
|
+
"POSITION_Y",
|
|
652
|
+
"position",
|
|
653
|
+
"well",
|
|
654
|
+
"well_index",
|
|
655
|
+
"well_name",
|
|
656
|
+
"pos_name",
|
|
657
|
+
"index",
|
|
658
|
+
"concentration",
|
|
659
|
+
"cell_type",
|
|
660
|
+
"antibody",
|
|
661
|
+
"pharmaceutical_agent",
|
|
662
|
+
"ID",
|
|
663
|
+
] + self.class_cols
|
|
664
|
+
|
|
665
|
+
meta = get_experiment_metadata(self.exp_dir)
|
|
666
|
+
if meta is not None:
|
|
667
|
+
keys = list(meta.keys())
|
|
668
|
+
cols_to_remove.extend(keys)
|
|
669
|
+
|
|
670
|
+
labels = get_experiment_labels(self.exp_dir)
|
|
671
|
+
if labels is not None:
|
|
672
|
+
keys = list(labels.keys())
|
|
673
|
+
cols_to_remove.extend(labels)
|
|
674
|
+
|
|
675
|
+
cols = np.array(list(self.df_tracks.columns))
|
|
676
|
+
time_cols = np.array([c.startswith("t_") for c in cols])
|
|
677
|
+
time_cols = list(cols[time_cols])
|
|
678
|
+
cols_to_remove += time_cols
|
|
679
|
+
|
|
680
|
+
status_cols = np.array([c.startswith("status_") for c in cols])
|
|
681
|
+
status_cols = list(cols[status_cols])
|
|
682
|
+
cols_to_remove += status_cols
|
|
683
|
+
|
|
684
|
+
for tr in cols_to_remove:
|
|
685
|
+
try:
|
|
686
|
+
self.columns_to_rescale.remove(tr)
|
|
687
|
+
except:
|
|
688
|
+
pass
|
|
689
|
+
|
|
690
|
+
x = self.df_tracks[self.columns_to_rescale].values
|
|
691
|
+
self.MinMaxScaler.fit(x)
|
|
692
|
+
|
|
693
|
+
def del_event_class(self):
|
|
694
|
+
|
|
695
|
+
msgBox = QMessageBox()
|
|
696
|
+
msgBox.setIcon(QMessageBox.Warning)
|
|
697
|
+
msgBox.setText(
|
|
698
|
+
f"You are about to delete the class {self.class_choice_cb.currentText()}. The associated time and\nstatus will also be deleted. Do you still want to proceed?"
|
|
699
|
+
)
|
|
700
|
+
msgBox.setWindowTitle("Warning")
|
|
701
|
+
msgBox.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
|
|
702
|
+
returnValue = msgBox.exec()
|
|
703
|
+
if returnValue == QMessageBox.No:
|
|
704
|
+
return None
|
|
705
|
+
else:
|
|
706
|
+
class_to_delete = self.class_choice_cb.currentText()
|
|
707
|
+
time_to_delete = class_to_delete.replace("class", "t")
|
|
708
|
+
status_to_delete = class_to_delete.replace("class", "status")
|
|
709
|
+
cols_to_delete = [class_to_delete, time_to_delete, status_to_delete]
|
|
710
|
+
for c in cols_to_delete:
|
|
711
|
+
try:
|
|
712
|
+
self.df_tracks = self.df_tracks.drop([c], axis=1)
|
|
713
|
+
except Exception as e:
|
|
714
|
+
print(e)
|
|
715
|
+
item_idx = self.class_choice_cb.findText(class_to_delete)
|
|
716
|
+
self.class_choice_cb.removeItem(item_idx)
|
|
717
|
+
|
|
718
|
+
def normalize_features(self):
|
|
719
|
+
|
|
720
|
+
x = self.df_tracks[self.columns_to_rescale].values
|
|
721
|
+
|
|
722
|
+
if not self.normalized_signals:
|
|
723
|
+
x = self.MinMaxScaler.transform(x)
|
|
724
|
+
self.df_tracks[self.columns_to_rescale] = x
|
|
725
|
+
self.plot_signals()
|
|
726
|
+
self.normalized_signals = True
|
|
727
|
+
self.normalize_features_btn.setIcon(
|
|
728
|
+
icon(MDI6.arrow_collapse_vertical, color="#1565c0")
|
|
729
|
+
)
|
|
730
|
+
self.normalize_features_btn.setIconSize(QSize(25, 25))
|
|
731
|
+
else:
|
|
732
|
+
x = self.MinMaxScaler.inverse_transform(x)
|
|
733
|
+
self.df_tracks[self.columns_to_rescale] = x
|
|
734
|
+
self.plot_signals()
|
|
735
|
+
self.normalized_signals = False
|
|
736
|
+
self.normalize_features_btn.setIcon(
|
|
737
|
+
icon(MDI6.arrow_collapse_vertical, color="black")
|
|
738
|
+
)
|
|
739
|
+
self.normalize_features_btn.setIconSize(QSize(25, 25))
|
|
740
|
+
|
|
741
|
+
def switch_to_log(self):
|
|
742
|
+
"""
|
|
743
|
+
Better would be to create a log(quantity) and plot it...
|
|
744
|
+
"""
|
|
745
|
+
|
|
746
|
+
try:
|
|
747
|
+
if self.cell_ax.get_yscale() == "linear":
|
|
748
|
+
ymin, ymax = self.cell_ax.get_ylim()
|
|
749
|
+
self.cell_ax.set_yscale("log")
|
|
750
|
+
self.log_btn.setIcon(icon(MDI6.math_log, color="#1565c0"))
|
|
751
|
+
self.cell_ax.set_ylim(self.value_magnitude, ymax)
|
|
752
|
+
self.log_scale = True
|
|
753
|
+
else:
|
|
754
|
+
self.cell_ax.set_yscale("linear")
|
|
755
|
+
self.log_btn.setIcon(icon(MDI6.math_log, color="black"))
|
|
756
|
+
self.log_scale = False
|
|
757
|
+
except Exception as e:
|
|
758
|
+
print(e)
|
|
759
|
+
|
|
760
|
+
# self.cell_ax.autoscale()
|
|
761
|
+
self.cell_fcanvas.canvas.draw_idle()
|
|
762
|
+
|
|
763
|
+
def start(self):
|
|
764
|
+
"""
|
|
765
|
+
Starts interactive animation. Adds the draw frame command to the GUI
|
|
766
|
+
handler, calls show to start the event loop.
|
|
767
|
+
"""
|
|
768
|
+
self.start_btn.setShortcut(QKeySequence(""))
|
|
769
|
+
|
|
770
|
+
self.last_frame_btn.setEnabled(True)
|
|
771
|
+
self.last_frame_btn.clicked.connect(self.set_last_frame)
|
|
772
|
+
|
|
773
|
+
self.first_frame_btn.setEnabled(True)
|
|
774
|
+
self.first_frame_btn.clicked.connect(self.set_first_frame)
|
|
775
|
+
|
|
776
|
+
self.start_btn.hide()
|
|
777
|
+
self.stop_btn.show()
|
|
778
|
+
|
|
779
|
+
self.anim.event_source.start()
|
|
780
|
+
self.stop_btn.clicked.connect(self.stop)
|
|
781
|
+
|
|
782
|
+
def contrast_slider_action(self):
|
|
783
|
+
"""
|
|
784
|
+
Recontrast the imshow as the contrast slider is moved.
|
|
785
|
+
"""
|
|
786
|
+
|
|
787
|
+
self.vmin = self.contrast_slider.value()[0]
|
|
788
|
+
self.vmax = self.contrast_slider.value()[1]
|
|
789
|
+
self.im.set_clim(vmin=self.vmin, vmax=self.vmax)
|
|
790
|
+
self.fcanvas.canvas.draw_idle()
|
|
791
|
+
|
|
792
|
+
def show_outliers(self):
|
|
793
|
+
if self.outliers_check.isChecked():
|
|
794
|
+
self.show_fliers = True
|
|
795
|
+
self.plot_signals()
|
|
796
|
+
else:
|
|
797
|
+
self.show_fliers = False
|
|
798
|
+
self.plot_signals()
|
|
799
|
+
|
|
800
|
+
def export_signals(self):
|
|
801
|
+
|
|
802
|
+
auto_dataset_name = (
|
|
803
|
+
self.pos.split(os.sep)[-4] + "_" + self.pos.split(os.sep)[-2] + ".npy"
|
|
804
|
+
)
|
|
805
|
+
|
|
806
|
+
if self.normalized_signals:
|
|
807
|
+
self.normalize_features_btn.click()
|
|
808
|
+
|
|
809
|
+
training_set = []
|
|
810
|
+
cols = self.df_tracks.columns
|
|
811
|
+
tracks = np.unique(self.df_tracks["TRACK_ID"].to_numpy())
|
|
812
|
+
|
|
813
|
+
for track in tracks:
|
|
814
|
+
# Add all signals at given track
|
|
815
|
+
signals = {}
|
|
816
|
+
for c in cols:
|
|
817
|
+
signals.update(
|
|
818
|
+
{
|
|
819
|
+
c: self.df_tracks.loc[
|
|
820
|
+
self.df_tracks["TRACK_ID"] == track, c
|
|
821
|
+
].to_numpy()
|
|
822
|
+
}
|
|
823
|
+
)
|
|
824
|
+
time_of_interest = self.df_tracks.loc[
|
|
825
|
+
self.df_tracks["TRACK_ID"] == track, self.time_name
|
|
826
|
+
].to_numpy()[0]
|
|
827
|
+
cclass = self.df_tracks.loc[
|
|
828
|
+
self.df_tracks["TRACK_ID"] == track, self.class_name
|
|
829
|
+
].to_numpy()[0]
|
|
830
|
+
signals.update({"time_of_interest": time_of_interest, "class": cclass})
|
|
831
|
+
# Here auto add all available channels
|
|
832
|
+
training_set.append(signals)
|
|
833
|
+
|
|
834
|
+
pathsave = QFileDialog.getSaveFileName(
|
|
835
|
+
self, "Select file name", self.exp_dir + auto_dataset_name, ".npy"
|
|
836
|
+
)[0]
|
|
837
|
+
if pathsave != "":
|
|
838
|
+
if not pathsave.endswith(".npy"):
|
|
839
|
+
pathsave += ".npy"
|
|
840
|
+
try:
|
|
841
|
+
np.save(pathsave, training_set)
|
|
842
|
+
print(f"File successfully written in {pathsave}.")
|
|
843
|
+
except Exception as e:
|
|
844
|
+
print(f"Error {e}...")
|
|
845
|
+
|
|
846
|
+
def create_new_event_class(self):
|
|
847
|
+
|
|
848
|
+
# display qwidget to name the event
|
|
849
|
+
self.newClassWidget = CelldetectiveWidget()
|
|
850
|
+
self.newClassWidget.setWindowTitle("Create new event class")
|
|
851
|
+
|
|
852
|
+
layout = QVBoxLayout()
|
|
853
|
+
self.newClassWidget.setLayout(layout)
|
|
854
|
+
name_hbox = QHBoxLayout()
|
|
855
|
+
name_hbox.addWidget(QLabel("event name: "), 25)
|
|
856
|
+
self.class_name_le = QLineEdit("event")
|
|
857
|
+
name_hbox.addWidget(self.class_name_le, 75)
|
|
858
|
+
layout.addLayout(name_hbox)
|
|
859
|
+
|
|
860
|
+
class_labels = ["event", "no event", "else"]
|
|
861
|
+
layout.addWidget(QLabel("prefill: "))
|
|
862
|
+
radio_box = QHBoxLayout()
|
|
863
|
+
self.class_option_rb = [QRadioButton() for i in range(3)]
|
|
864
|
+
for i, c in enumerate(self.class_option_rb):
|
|
865
|
+
if i == 0:
|
|
866
|
+
c.setChecked(True)
|
|
867
|
+
c.setText(class_labels[i])
|
|
868
|
+
radio_box.addWidget(c, 33, alignment=Qt.AlignCenter)
|
|
869
|
+
layout.addLayout(radio_box)
|
|
870
|
+
|
|
871
|
+
btn_hbox = QHBoxLayout()
|
|
872
|
+
submit_btn = QPushButton("submit")
|
|
873
|
+
cancel_btn = QPushButton("cancel")
|
|
874
|
+
btn_hbox.addWidget(cancel_btn, 50)
|
|
875
|
+
btn_hbox.addWidget(submit_btn, 50)
|
|
876
|
+
layout.addLayout(btn_hbox)
|
|
877
|
+
|
|
878
|
+
submit_btn.clicked.connect(self.write_new_event_class)
|
|
879
|
+
cancel_btn.clicked.connect(self.close_without_new_class)
|
|
880
|
+
|
|
881
|
+
self.newClassWidget.show()
|
|
882
|
+
center_window(self.newClassWidget)
|
|
883
|
+
|
|
884
|
+
def shortcut_suppr(self):
|
|
885
|
+
self.correct_btn.click()
|
|
886
|
+
self.suppr_btn.click()
|
|
887
|
+
self.correct_btn.click()
|
|
888
|
+
|
|
889
|
+
def closeEvent(self, event):
|
|
890
|
+
# result = QMessageBox.question(self,
|
|
891
|
+
# "Confirm Exit...",
|
|
892
|
+
# "Are you sure you want to exit ?",
|
|
893
|
+
# QMessageBox.Yes| QMessageBox.No,
|
|
894
|
+
# )
|
|
895
|
+
# del self.img
|
|
896
|
+
gc.collect()
|
|
897
|
+
|
|
898
|
+
def save_trajectories(self):
|
|
899
|
+
# specific to signal/static annotator
|
|
900
|
+
print("Save trajectory function not implemented for BaseAnnotator class...")
|
|
901
|
+
|
|
902
|
+
def cancel_selection(self):
|
|
903
|
+
print("we are in cancel selection...")
|
|
904
|
+
self.hide_annotation_buttons()
|
|
905
|
+
self.correct_btn.setEnabled(False)
|
|
906
|
+
self.correct_btn.setText("correct")
|
|
907
|
+
self.cancel_btn.setEnabled(False)
|
|
908
|
+
|
|
909
|
+
try:
|
|
910
|
+
self.selection.pop(0)
|
|
911
|
+
except Exception as e:
|
|
912
|
+
pass
|
|
913
|
+
|
|
914
|
+
try:
|
|
915
|
+
for k, (t, idx) in enumerate(zip(self.loc_t, self.loc_idx)):
|
|
916
|
+
self.colors[t][idx, 0] = self.previous_color[k][0]
|
|
917
|
+
# self.colors[t][idx, 1] = self.previous_color[k][1]
|
|
918
|
+
except Exception as e:
|
|
919
|
+
pass
|