celldetective 1.4.2__py3-none-any.whl → 1.5.0b0__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 +304 -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/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 +197 -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.0b0.dist-info}/METADATA +1 -1
- celldetective-1.5.0b0.dist-info/RECORD +187 -0
- {celldetective-1.4.2.dist-info → celldetective-1.5.0b0.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/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/{gui/processes → processes}/downloader.py +0 -0
- {celldetective-1.4.2.dist-info → celldetective-1.5.0b0.dist-info}/entry_points.txt +0 -0
- {celldetective-1.4.2.dist-info → celldetective-1.5.0b0.dist-info}/licenses/LICENSE +0 -0
- {celldetective-1.4.2.dist-info → celldetective-1.5.0b0.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
from PyQt5.QtWidgets import
|
|
1
|
+
from PyQt5.QtWidgets import (
|
|
2
|
+
QApplication,
|
|
3
|
+
QComboBox,
|
|
4
|
+
QFrame,
|
|
5
|
+
QCheckBox,
|
|
6
|
+
QVBoxLayout,
|
|
7
|
+
QLabel,
|
|
8
|
+
QHBoxLayout,
|
|
9
|
+
QPushButton,
|
|
10
|
+
)
|
|
2
11
|
from PyQt5.QtCore import Qt, QSize
|
|
3
|
-
from celldetective.gui.gui_utils import
|
|
12
|
+
from celldetective.gui.gui_utils import DistanceChoice
|
|
13
|
+
from celldetective.gui.base.list_widget import ListWidget
|
|
14
|
+
from celldetective.gui.base.utils import center_window
|
|
4
15
|
from superqt.fonticon import icon
|
|
5
16
|
from fonticon_mdi6 import MDI6
|
|
6
17
|
import numpy as np
|
|
@@ -8,492 +19,567 @@ import json
|
|
|
8
19
|
import os
|
|
9
20
|
from glob import glob
|
|
10
21
|
import pandas as pd
|
|
11
|
-
from celldetective.gui.viewers import
|
|
12
|
-
from celldetective.gui import
|
|
22
|
+
from celldetective.gui.viewers.contour_viewer import CellEdgeVisualizer
|
|
23
|
+
from celldetective.gui.viewers.size_viewer import CellSizeViewer
|
|
24
|
+
|
|
25
|
+
from celldetective.gui.base.components import CelldetectiveWidget
|
|
13
26
|
|
|
14
27
|
|
|
15
28
|
class SettingsNeighborhood(CelldetectiveWidget):
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
|
|
29
|
+
"""
|
|
30
|
+
Widget to configure neighborhood measurements.
|
|
31
|
+
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
def __init__(
|
|
35
|
+
self,
|
|
36
|
+
neighborhood_type="distance_threshold",
|
|
37
|
+
neighborhood_parameter_name="threshold distance",
|
|
38
|
+
parent_window=None,
|
|
39
|
+
*args,
|
|
40
|
+
**kwargs,
|
|
41
|
+
):
|
|
42
|
+
|
|
43
|
+
super().__init__(*args, **kwargs)
|
|
44
|
+
self.parent_window = parent_window
|
|
45
|
+
self.attr_parent = self.parent_window.parent_window
|
|
46
|
+
|
|
47
|
+
self.neighborhood_type = neighborhood_type
|
|
48
|
+
self.neighborhood_parameter_name = neighborhood_parameter_name
|
|
49
|
+
|
|
50
|
+
self.setWindowTitle("Configure neighborhoods")
|
|
51
|
+
self.neigh_instructions = self.attr_parent.exp_dir + os.sep.join(
|
|
52
|
+
["configs", "neighborhood_instructions.json"]
|
|
53
|
+
)
|
|
54
|
+
self.clear_previous = False
|
|
55
|
+
self.not_status_reference = False
|
|
56
|
+
self.not_status_neighbor = False
|
|
57
|
+
|
|
58
|
+
self.screen_height = self.attr_parent.screen_height
|
|
59
|
+
self.setMinimumWidth(750)
|
|
60
|
+
self.setMinimumHeight(int(0.5 * self.screen_height))
|
|
61
|
+
self.setMaximumHeight(int(0.95 * self.screen_height))
|
|
62
|
+
|
|
63
|
+
self.generate_main_layout()
|
|
64
|
+
self.load_previous_neighborhood_instructions()
|
|
65
|
+
center_window(self)
|
|
66
|
+
|
|
67
|
+
def generate_main_layout(self):
|
|
68
|
+
|
|
69
|
+
main_layout = QVBoxLayout(self)
|
|
70
|
+
main_layout.setContentsMargins(30, 30, 30, 30)
|
|
71
|
+
|
|
72
|
+
populations_layout = QHBoxLayout()
|
|
73
|
+
|
|
74
|
+
# Reference population
|
|
75
|
+
self.reference_population_frame = QFrame()
|
|
76
|
+
self.reference_population_frame.setFrameStyle(
|
|
77
|
+
QFrame.StyledPanel | QFrame.Raised
|
|
78
|
+
)
|
|
79
|
+
self.populate_reference_frame()
|
|
80
|
+
populations_layout.addWidget(self.reference_population_frame, 50)
|
|
81
|
+
|
|
82
|
+
# Neighbor population
|
|
83
|
+
self.neigh_population_frame = QFrame()
|
|
84
|
+
self.neigh_population_frame.setFrameStyle(QFrame.StyledPanel | QFrame.Raised)
|
|
85
|
+
self.populate_neighbor_frame()
|
|
86
|
+
populations_layout.addWidget(self.neigh_population_frame, 50)
|
|
87
|
+
main_layout.addLayout(populations_layout)
|
|
88
|
+
|
|
89
|
+
# Measurements
|
|
90
|
+
|
|
91
|
+
self.measurement_frame = QFrame()
|
|
92
|
+
self.measurement_frame.setFrameStyle(QFrame.StyledPanel | QFrame.Raised)
|
|
93
|
+
self.populate_measurement_frame()
|
|
94
|
+
# if self.neighborhood_type=='distance_threshold':
|
|
95
|
+
# self.populate_radii_frame()
|
|
96
|
+
# elif self.neighborhood_type=='mask_contact':
|
|
97
|
+
# self.populate_contact_frame()
|
|
98
|
+
main_layout.addWidget(self.measurement_frame)
|
|
99
|
+
|
|
100
|
+
self.clear_previous_btn = QCheckBox("clear previous neighborhoods")
|
|
101
|
+
self.clear_previous_btn.setToolTip(
|
|
102
|
+
"Clear all previous neighborhood measurements."
|
|
103
|
+
)
|
|
104
|
+
self.clear_previous_btn.setIcon(icon(MDI6.broom, color="black"))
|
|
105
|
+
|
|
106
|
+
main_layout.addWidget(self.clear_previous_btn, alignment=Qt.AlignRight)
|
|
107
|
+
|
|
108
|
+
main_layout.addWidget(QLabel(""))
|
|
109
|
+
self.submit_btn = QPushButton("Set")
|
|
110
|
+
self.submit_btn.setStyleSheet(self.button_style_sheet)
|
|
111
|
+
self.submit_btn.clicked.connect(self.write_instructions)
|
|
112
|
+
main_layout.addWidget(self.submit_btn)
|
|
113
|
+
|
|
114
|
+
self.adjustSize()
|
|
115
|
+
QApplication.processEvents()
|
|
116
|
+
|
|
117
|
+
def populate_measurement_frame(self):
|
|
118
|
+
"""
|
|
119
|
+
Add widgets and layout in the radii frame.
|
|
120
|
+
"""
|
|
121
|
+
|
|
122
|
+
grid = QVBoxLayout(self.measurement_frame)
|
|
123
|
+
|
|
124
|
+
self.dist_lbl = QLabel(
|
|
125
|
+
f"NEIGHBORHOOD {self.neighborhood_parameter_name.upper()}"
|
|
126
|
+
)
|
|
127
|
+
self.dist_lbl.setStyleSheet(self.block_title)
|
|
128
|
+
grid.addWidget(self.dist_lbl, alignment=Qt.AlignCenter)
|
|
129
|
+
|
|
130
|
+
self.ContentsMeasurements = QFrame()
|
|
131
|
+
layout = QVBoxLayout(self.ContentsMeasurements)
|
|
132
|
+
layout.setContentsMargins(0, 0, 0, 0)
|
|
133
|
+
|
|
134
|
+
list_header_layout = QHBoxLayout()
|
|
135
|
+
meas = self.neighborhood_parameter_name.split(" ")[-1]
|
|
136
|
+
lbl = QLabel(f"{meas} [px]:")
|
|
137
|
+
lbl.setToolTip("")
|
|
138
|
+
list_header_layout.addWidget(lbl, 85)
|
|
139
|
+
|
|
140
|
+
self.delete_measurement_btn = QPushButton("")
|
|
141
|
+
self.delete_measurement_btn.setStyleSheet(self.button_select_all)
|
|
142
|
+
self.delete_measurement_btn.setIcon(icon(MDI6.trash_can, color="black"))
|
|
143
|
+
self.delete_measurement_btn.setToolTip("Remove measurement.")
|
|
144
|
+
self.delete_measurement_btn.setIconSize(QSize(20, 20))
|
|
145
|
+
list_header_layout.addWidget(self.delete_measurement_btn, 5)
|
|
146
|
+
|
|
147
|
+
self.add_measurement_btn = QPushButton("")
|
|
148
|
+
self.add_measurement_btn.setStyleSheet(self.button_select_all)
|
|
149
|
+
self.add_measurement_btn.setIcon(icon(MDI6.plus, color="black"))
|
|
150
|
+
self.add_measurement_btn.setToolTip("Add a neighborhood measurement.")
|
|
151
|
+
self.add_measurement_btn.setIconSize(QSize(20, 20))
|
|
152
|
+
list_header_layout.addWidget(self.add_measurement_btn, 5)
|
|
153
|
+
|
|
154
|
+
self.viewer_btn = QPushButton()
|
|
155
|
+
self.viewer_btn.setStyleSheet(self.button_select_all)
|
|
156
|
+
self.viewer_btn.setIcon(icon(MDI6.image_check, color="black"))
|
|
157
|
+
self.viewer_btn.setToolTip("View stack and set measurement.")
|
|
158
|
+
self.viewer_btn.setIconSize(QSize(20, 20))
|
|
159
|
+
if self.neighborhood_type == "distance_threshold":
|
|
160
|
+
self.viewer_btn.clicked.connect(self.view_current_stack_with_circle)
|
|
161
|
+
elif self.neighborhood_type == "mask_contact":
|
|
162
|
+
self.viewer_btn.clicked.connect(self.view_current_stack_with_edge)
|
|
163
|
+
list_header_layout.addWidget(self.viewer_btn, 5)
|
|
164
|
+
|
|
165
|
+
layout.addLayout(list_header_layout)
|
|
166
|
+
|
|
167
|
+
self.measurements_list = ListWidget(
|
|
168
|
+
DistanceChoice, initial_features=[], dtype=int
|
|
169
|
+
)
|
|
170
|
+
self.measurements_list.setToolTip("Neighborhoods to compute.")
|
|
171
|
+
layout.addWidget(self.measurements_list)
|
|
172
|
+
|
|
173
|
+
self.delete_measurement_btn.clicked.connect(self.measurements_list.removeSel)
|
|
174
|
+
self.add_measurement_btn.clicked.connect(self.measurements_list.addItem)
|
|
175
|
+
|
|
176
|
+
grid.addWidget(self.ContentsMeasurements)
|
|
177
|
+
|
|
178
|
+
def view_current_stack_with_circle(self):
|
|
179
|
+
|
|
180
|
+
self.parent_window.parent_window.locate_image()
|
|
181
|
+
if self.parent_window.parent_window.current_stack is not None:
|
|
182
|
+
self.viewer = CellSizeViewer(
|
|
183
|
+
initial_diameter=100,
|
|
184
|
+
parent_list_widget=self.measurements_list.list_widget,
|
|
185
|
+
set_radius_in_list=True,
|
|
186
|
+
stack_path=self.parent_window.parent_window.current_stack,
|
|
187
|
+
window_title=f"Position {self.parent_window.parent_window.position_list.currentText()}",
|
|
188
|
+
frame_slider=True,
|
|
189
|
+
contrast_slider=True,
|
|
190
|
+
channel_cb=True,
|
|
191
|
+
diameter_slider_range=(0, 300),
|
|
192
|
+
channel_names=self.parent_window.parent_window.exp_channels,
|
|
193
|
+
n_channels=self.parent_window.parent_window.nbr_channels,
|
|
194
|
+
PxToUm=1,
|
|
195
|
+
)
|
|
196
|
+
self.viewer.show()
|
|
197
|
+
|
|
198
|
+
def view_current_stack_with_edge(self):
|
|
199
|
+
|
|
200
|
+
self.attr_parent.locate_image()
|
|
201
|
+
if self.attr_parent.current_stack is not None:
|
|
202
|
+
self.viewer = CellEdgeVisualizer(
|
|
203
|
+
cell_type=self.reference_population_cb.currentText(),
|
|
204
|
+
edge_range=(1, 30),
|
|
205
|
+
invert=True,
|
|
206
|
+
initial_edge=3,
|
|
207
|
+
parent_list_widget=self.measurements_list.list_widget,
|
|
208
|
+
stack_path=self.attr_parent.current_stack,
|
|
209
|
+
window_title=f"Position {self.attr_parent.position_list.currentText()}",
|
|
210
|
+
frame_slider=True,
|
|
211
|
+
contrast_slider=True,
|
|
212
|
+
channel_cb=True,
|
|
213
|
+
channel_names=self.attr_parent.exp_channels,
|
|
214
|
+
n_channels=self.attr_parent.nbr_channels,
|
|
215
|
+
PxToUm=1,
|
|
216
|
+
)
|
|
217
|
+
self.viewer.show()
|
|
218
|
+
|
|
219
|
+
def populate_reference_frame(self):
|
|
220
|
+
"""
|
|
221
|
+
Add widgets and layout in the reference population frame.
|
|
222
|
+
"""
|
|
223
|
+
|
|
224
|
+
grid = QVBoxLayout(self.reference_population_frame)
|
|
225
|
+
grid.setSpacing(15)
|
|
226
|
+
self.ref_lbl = QLabel("REFERENCE")
|
|
227
|
+
self.ref_lbl.setStyleSheet(self.block_title)
|
|
228
|
+
self.ref_lbl.setToolTip("Reference population settings.")
|
|
229
|
+
grid.addWidget(self.ref_lbl, 30, alignment=Qt.AlignCenter)
|
|
230
|
+
|
|
231
|
+
self.ContentsReference = QFrame()
|
|
232
|
+
layout = QVBoxLayout(self.ContentsReference)
|
|
233
|
+
layout.setContentsMargins(15, 15, 15, 15)
|
|
234
|
+
|
|
235
|
+
population_layout = QHBoxLayout()
|
|
236
|
+
population_layout.addWidget(QLabel("population: "), 30)
|
|
237
|
+
self.reference_population_cb = QComboBox()
|
|
238
|
+
self.reference_population_cb.addItems(
|
|
239
|
+
self.parent_window.parent_window.populations
|
|
240
|
+
)
|
|
241
|
+
self.reference_population_cb.setToolTip("Select a reference population.")
|
|
242
|
+
population_layout.addWidget(self.reference_population_cb, 70)
|
|
243
|
+
layout.addLayout(population_layout)
|
|
244
|
+
|
|
245
|
+
status_layout = QHBoxLayout()
|
|
246
|
+
|
|
247
|
+
# status_layout.addWidget(QLabel('status: '), 30)
|
|
248
|
+
|
|
249
|
+
status_sublayout = QHBoxLayout()
|
|
250
|
+
self.reference_population_status_cb = QComboBox()
|
|
251
|
+
self.reference_population_status_cb.setToolTip(
|
|
252
|
+
"Status of the reference population."
|
|
253
|
+
)
|
|
254
|
+
self.reference_population_status_cb.hide()
|
|
255
|
+
status_sublayout.addWidget(self.reference_population_status_cb, 95)
|
|
256
|
+
|
|
257
|
+
self.reference_switch_status_btn = QPushButton("")
|
|
258
|
+
self.reference_switch_status_btn.setStyleSheet(self.button_select_all)
|
|
259
|
+
self.reference_switch_status_btn.setIcon(
|
|
260
|
+
icon(MDI6.invert_colors, color="black")
|
|
261
|
+
)
|
|
262
|
+
self.reference_switch_status_btn.setIconSize(QSize(20, 20))
|
|
263
|
+
self.reference_switch_status_btn.clicked.connect(self.switch_not_reference)
|
|
264
|
+
self.reference_switch_status_btn.setToolTip("Invert status values.")
|
|
265
|
+
self.reference_switch_status_btn.hide()
|
|
266
|
+
|
|
267
|
+
status_sublayout.addWidget(self.reference_switch_status_btn, 5)
|
|
268
|
+
|
|
269
|
+
status_layout.addLayout(status_sublayout, 70)
|
|
270
|
+
layout.addLayout(status_layout)
|
|
271
|
+
|
|
272
|
+
event_layout = QHBoxLayout()
|
|
273
|
+
event_layout.addWidget(QLabel("event time: "), 30)
|
|
274
|
+
self.event_time_cb = QComboBox()
|
|
275
|
+
self.event_time_cb.setToolTip(
|
|
276
|
+
"Compute average neighborhood metrics before and after this event time."
|
|
277
|
+
)
|
|
278
|
+
event_layout.addWidget(self.event_time_cb, 70)
|
|
279
|
+
layout.addLayout(event_layout)
|
|
280
|
+
|
|
281
|
+
self.fill_cbs_of_reference_population()
|
|
282
|
+
self.reference_population_cb.currentIndexChanged.connect(
|
|
283
|
+
self.fill_cbs_of_reference_population
|
|
284
|
+
)
|
|
285
|
+
|
|
286
|
+
grid.addWidget(self.ContentsReference, 70)
|
|
287
|
+
|
|
288
|
+
def populate_neighbor_frame(self):
|
|
289
|
+
"""
|
|
290
|
+
Add widgets and layout in the neighbor population frame.
|
|
291
|
+
"""
|
|
292
|
+
|
|
293
|
+
grid = QVBoxLayout(self.neigh_population_frame)
|
|
294
|
+
grid.setSpacing(15)
|
|
295
|
+
self.ref_lbl = QLabel("NEIGHBOR")
|
|
296
|
+
self.ref_lbl.setStyleSheet(self.block_title)
|
|
297
|
+
self.ref_lbl.setToolTip("Neighbor population settings.")
|
|
298
|
+
grid.addWidget(self.ref_lbl, 30, alignment=Qt.AlignCenter)
|
|
299
|
+
|
|
300
|
+
self.ContentsNeigh = QFrame()
|
|
301
|
+
layout = QVBoxLayout(self.ContentsNeigh)
|
|
302
|
+
layout.setContentsMargins(15, 15, 15, 15)
|
|
303
|
+
|
|
304
|
+
population_layout = QHBoxLayout()
|
|
305
|
+
population_layout.addWidget(QLabel("population: "), 30)
|
|
306
|
+
self.neighbor_population_cb = QComboBox()
|
|
307
|
+
self.neighbor_population_cb.addItems(
|
|
308
|
+
self.parent_window.parent_window.populations
|
|
309
|
+
)
|
|
310
|
+
self.neighbor_population_cb.setToolTip("Select a neighbor population.")
|
|
311
|
+
population_layout.addWidget(self.neighbor_population_cb, 70)
|
|
312
|
+
layout.addLayout(population_layout)
|
|
313
|
+
|
|
314
|
+
status_layout = QHBoxLayout()
|
|
315
|
+
|
|
316
|
+
status_layout.addWidget(QLabel("status: "), 30)
|
|
317
|
+
status_sublayout = QHBoxLayout()
|
|
318
|
+
|
|
319
|
+
self.neighbor_population_status_cb = QComboBox()
|
|
320
|
+
self.neighbor_population_status_cb.setToolTip(
|
|
321
|
+
"Status of the neighbor population."
|
|
322
|
+
)
|
|
323
|
+
status_sublayout.addWidget(self.neighbor_population_status_cb, 95)
|
|
324
|
+
|
|
325
|
+
self.neighbor_switch_status_btn = QPushButton("")
|
|
326
|
+
self.neighbor_switch_status_btn.setStyleSheet(self.button_select_all)
|
|
327
|
+
self.neighbor_switch_status_btn.setIcon(icon(MDI6.invert_colors, color="black"))
|
|
328
|
+
self.neighbor_switch_status_btn.setToolTip("Invert status values.")
|
|
329
|
+
self.neighbor_switch_status_btn.setIconSize(QSize(20, 20))
|
|
330
|
+
self.neighbor_switch_status_btn.clicked.connect(self.switch_not_neigh)
|
|
331
|
+
status_sublayout.addWidget(self.neighbor_switch_status_btn, 5)
|
|
332
|
+
status_layout.addLayout(status_sublayout, 70)
|
|
333
|
+
layout.addLayout(status_layout)
|
|
334
|
+
|
|
335
|
+
self.cumulated_presence_btn = QCheckBox("cumulated presence")
|
|
336
|
+
self.cumulated_presence_btn.setToolTip(
|
|
337
|
+
"Compute the cumulated presence time of each neighbor around a reference cell."
|
|
338
|
+
)
|
|
339
|
+
self.cumulated_presence_btn.setIcon(icon(MDI6.timer_outline, color="black"))
|
|
340
|
+
|
|
341
|
+
layout.addWidget(self.cumulated_presence_btn)
|
|
342
|
+
|
|
343
|
+
# self.symmetrize_btn = QCheckBox('symmetrize')
|
|
344
|
+
# self.symmetrize_btn.setToolTip("Write the neighborhood of the neighbor cells with respect to the reference cells.")
|
|
345
|
+
# layout.addWidget(self.symmetrize_btn)
|
|
346
|
+
|
|
347
|
+
self.fill_cbs_of_neighbor_population()
|
|
348
|
+
self.neighbor_population_cb.currentIndexChanged.connect(
|
|
349
|
+
self.fill_cbs_of_neighbor_population
|
|
350
|
+
)
|
|
351
|
+
|
|
352
|
+
grid.addWidget(self.ContentsNeigh, 70)
|
|
353
|
+
|
|
354
|
+
def fill_cbs_of_neighbor_population(self):
|
|
355
|
+
|
|
356
|
+
population = self.neighbor_population_cb.currentText()
|
|
357
|
+
class_cols, status_cols, group_cols, time_cols = (
|
|
358
|
+
self.locate_population_specific_columns(population)
|
|
359
|
+
)
|
|
360
|
+
self.neighbor_population_status_cb.clear()
|
|
361
|
+
self.neighbor_population_status_cb.addItems(
|
|
362
|
+
list(
|
|
363
|
+
np.unique(
|
|
364
|
+
["--", "class", "status"] + class_cols + status_cols + group_cols
|
|
365
|
+
)
|
|
366
|
+
)
|
|
367
|
+
)
|
|
368
|
+
|
|
369
|
+
def fill_cbs_of_reference_population(self):
|
|
370
|
+
|
|
371
|
+
population = self.reference_population_cb.currentText()
|
|
372
|
+
class_cols, status_cols, group_cols, time_cols = (
|
|
373
|
+
self.locate_population_specific_columns(population)
|
|
374
|
+
)
|
|
375
|
+
self.event_time_cb.clear()
|
|
376
|
+
self.event_time_cb.addItems(list(np.unique(["--", "t0"] + time_cols)))
|
|
377
|
+
|
|
378
|
+
def switch_not_reference(self):
|
|
379
|
+
|
|
380
|
+
self.not_status_reference = not self.not_status_reference
|
|
381
|
+
if self.not_status_reference:
|
|
382
|
+
self.reference_switch_status_btn.setIcon(
|
|
383
|
+
icon(MDI6.invert_colors, color=self.celldetective_blue)
|
|
384
|
+
)
|
|
385
|
+
self.reference_switch_status_btn.setIconSize(QSize(20, 20))
|
|
386
|
+
else:
|
|
387
|
+
self.reference_switch_status_btn.setIcon(
|
|
388
|
+
icon(MDI6.invert_colors, color="black")
|
|
389
|
+
)
|
|
390
|
+
self.reference_switch_status_btn.setIconSize(QSize(20, 20))
|
|
391
|
+
|
|
392
|
+
def switch_not_neigh(self):
|
|
393
|
+
|
|
394
|
+
self.not_status_neighbor = not self.not_status_neighbor
|
|
395
|
+
if self.not_status_neighbor:
|
|
396
|
+
self.neighbor_switch_status_btn.setIcon(
|
|
397
|
+
icon(MDI6.invert_colors, color=self.celldetective_blue)
|
|
398
|
+
)
|
|
399
|
+
self.neighbor_switch_status_btn.setIconSize(QSize(20, 20))
|
|
400
|
+
else:
|
|
401
|
+
self.neighbor_switch_status_btn.setIcon(
|
|
402
|
+
icon(MDI6.invert_colors, color="black")
|
|
403
|
+
)
|
|
404
|
+
self.neighbor_switch_status_btn.setIconSize(QSize(20, 20))
|
|
405
|
+
|
|
406
|
+
def locate_population_specific_columns(self, population):
|
|
407
|
+
|
|
408
|
+
# Look for all classes and times
|
|
409
|
+
tables = glob(
|
|
410
|
+
self.attr_parent.exp_dir
|
|
411
|
+
+ os.sep.join(
|
|
412
|
+
["W*", "*", "output", "tables", f"trajectories_{population}.csv"]
|
|
413
|
+
)
|
|
414
|
+
)
|
|
415
|
+
self.all_columns = []
|
|
416
|
+
for tab in tables:
|
|
417
|
+
cols = pd.read_csv(tab, nrows=1).columns.tolist()
|
|
418
|
+
self.all_columns.extend(cols)
|
|
419
|
+
self.all_columns = np.unique(self.all_columns)
|
|
420
|
+
|
|
421
|
+
class_idx = np.array([s.startswith("class_") for s in self.all_columns])
|
|
422
|
+
status_idx = np.array([s.startswith("status_") for s in self.all_columns])
|
|
423
|
+
group_idx = np.array([s.startswith("group_") for s in self.all_columns])
|
|
424
|
+
time_idx = np.array([s.startswith("t_") for s in self.all_columns])
|
|
425
|
+
|
|
426
|
+
if len(class_idx) > 0:
|
|
427
|
+
class_columns = list(self.all_columns[class_idx])
|
|
428
|
+
for c in ["class_id", "class_color"]:
|
|
429
|
+
if c in class_columns:
|
|
430
|
+
class_columns.remove(c)
|
|
431
|
+
else:
|
|
432
|
+
class_columns = []
|
|
433
|
+
|
|
434
|
+
if len(status_idx) > 0:
|
|
435
|
+
status_columns = list(self.all_columns[status_idx])
|
|
436
|
+
else:
|
|
437
|
+
status_columns = []
|
|
438
|
+
|
|
439
|
+
if len(group_idx) > 0:
|
|
440
|
+
group_columns = list(self.all_columns[group_idx])
|
|
441
|
+
else:
|
|
442
|
+
group_columns = []
|
|
443
|
+
|
|
444
|
+
if len(time_idx) > 0:
|
|
445
|
+
time_columns = list(self.all_columns[time_idx])
|
|
446
|
+
else:
|
|
447
|
+
time_columns = []
|
|
448
|
+
|
|
449
|
+
return class_columns, status_columns, group_columns, time_columns
|
|
450
|
+
|
|
451
|
+
def write_instructions(self):
|
|
452
|
+
"""
|
|
453
|
+
Write the selected options in a json file for later reading by the software.
|
|
454
|
+
"""
|
|
455
|
+
|
|
456
|
+
print("Writing instructions...")
|
|
457
|
+
|
|
458
|
+
neighborhood_options = {}
|
|
459
|
+
pop = [
|
|
460
|
+
self.reference_population_cb.currentText(),
|
|
461
|
+
self.neighbor_population_cb.currentText(),
|
|
462
|
+
]
|
|
463
|
+
neighborhood_options.update({"population": pop})
|
|
464
|
+
|
|
465
|
+
status_options = [
|
|
466
|
+
self.reference_population_status_cb.currentText(),
|
|
467
|
+
self.neighbor_population_status_cb.currentText(),
|
|
468
|
+
]
|
|
469
|
+
for k in range(2):
|
|
470
|
+
if status_options[k] == "--" or status_options[k] == "":
|
|
471
|
+
status_options[k] = None
|
|
472
|
+
if pop[0] != pop[1]:
|
|
473
|
+
mode = "two-pop"
|
|
474
|
+
else:
|
|
475
|
+
mode = "self"
|
|
476
|
+
|
|
477
|
+
# TO ADAPT
|
|
478
|
+
distances = self.measurements_list.getItems()
|
|
479
|
+
neighborhood_options.update({"neighborhood_type": self.neighborhood_type})
|
|
480
|
+
neighborhood_options.update({"distance": distances})
|
|
481
|
+
neighborhood_options.update(
|
|
482
|
+
{"clear_neigh": self.clear_previous_btn.isChecked()}
|
|
483
|
+
)
|
|
484
|
+
event_time_col = self.event_time_cb.currentText()
|
|
485
|
+
if event_time_col == "--":
|
|
486
|
+
event_time_col = None
|
|
487
|
+
neighborhood_options.update({"event_time_col": event_time_col})
|
|
488
|
+
|
|
489
|
+
neighborhood_kwargs = {
|
|
490
|
+
"mode": mode,
|
|
491
|
+
"status": status_options,
|
|
492
|
+
"not_status_option": [self.not_status_reference, self.not_status_neighbor],
|
|
493
|
+
"compute_cum_sum": self.cumulated_presence_btn.isChecked(),
|
|
494
|
+
"attention_weight": True,
|
|
495
|
+
"symmetrize": False,
|
|
496
|
+
"include_dead_weight": True,
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
neighborhood_options.update({"neighborhood_kwargs": neighborhood_kwargs})
|
|
500
|
+
|
|
501
|
+
print("Neighborhood instructions: ", neighborhood_options)
|
|
502
|
+
file_name = self.neigh_instructions
|
|
503
|
+
with open(file_name, "w") as f:
|
|
504
|
+
json.dump(neighborhood_options, f, indent=4)
|
|
505
|
+
|
|
506
|
+
self.parent_window.protocols.append(neighborhood_options)
|
|
507
|
+
correction_description = ""
|
|
508
|
+
for index, (key, value) in enumerate(neighborhood_options.items()):
|
|
509
|
+
if index > 0:
|
|
510
|
+
correction_description += ", "
|
|
511
|
+
correction_description += str(key) + " : " + str(value)
|
|
512
|
+
self.parent_window.protocol_list.addItem(correction_description)
|
|
513
|
+
|
|
514
|
+
print("Done.")
|
|
515
|
+
self.close()
|
|
516
|
+
|
|
517
|
+
def load_previous_neighborhood_instructions(self):
|
|
518
|
+
"""
|
|
519
|
+
Read the measurmeent options from a previously written json file and format properly for the UI.
|
|
520
|
+
"""
|
|
521
|
+
|
|
522
|
+
print("Reading instructions..")
|
|
523
|
+
if os.path.exists(self.neigh_instructions):
|
|
524
|
+
with open(self.neigh_instructions, "r") as f:
|
|
525
|
+
|
|
526
|
+
neigh_instructions = json.load(f)
|
|
527
|
+
print(f"Loading the instructions: {neigh_instructions}...")
|
|
528
|
+
|
|
529
|
+
if "neighborhood_type" not in neigh_instructions:
|
|
530
|
+
neigh_instructions.update(
|
|
531
|
+
{"neighborhood_type": self.neighborhood_type}
|
|
532
|
+
)
|
|
533
|
+
|
|
534
|
+
if self.neighborhood_type == neigh_instructions["neighborhood_type"]:
|
|
535
|
+
|
|
536
|
+
if "distance" in neigh_instructions:
|
|
537
|
+
distances = neigh_instructions["distance"]
|
|
538
|
+
distances = [str(d) for d in distances]
|
|
539
|
+
self.measurements_list.list_widget.clear()
|
|
540
|
+
self.measurements_list.list_widget.addItems(distances)
|
|
541
|
+
|
|
542
|
+
if "population" in neigh_instructions:
|
|
543
|
+
|
|
544
|
+
pop = neigh_instructions["population"]
|
|
545
|
+
idx0 = self.reference_population_cb.findText(pop[0])
|
|
546
|
+
self.reference_population_cb.setCurrentIndex(idx0)
|
|
547
|
+
idx1 = self.neighbor_population_cb.findText(pop[1])
|
|
548
|
+
self.neighbor_population_cb.setCurrentIndex(idx1)
|
|
549
|
+
|
|
550
|
+
if "clear_neigh" in neigh_instructions:
|
|
551
|
+
clear_neigh = neigh_instructions["clear_neigh"]
|
|
552
|
+
self.clear_previous_btn.setChecked(clear_neigh)
|
|
553
|
+
|
|
554
|
+
if "event_time_col" in neigh_instructions:
|
|
555
|
+
event_time_col = neigh_instructions["event_time_col"]
|
|
556
|
+
if event_time_col is None:
|
|
557
|
+
event_time_col = "--"
|
|
558
|
+
idx = self.event_time_cb.findText(event_time_col)
|
|
559
|
+
self.event_time_cb.setCurrentIndex(idx)
|
|
560
|
+
|
|
561
|
+
if "neighborhood_kwargs" in neigh_instructions:
|
|
562
|
+
neighborhood_kwargs = neigh_instructions["neighborhood_kwargs"]
|
|
563
|
+
if "compute_cum_sum" in neighborhood_kwargs:
|
|
564
|
+
self.cumulated_presence_btn.setChecked(
|
|
565
|
+
neighborhood_kwargs["compute_cum_sum"]
|
|
566
|
+
)
|
|
567
|
+
if "status" in neighborhood_kwargs:
|
|
568
|
+
status_options = neighborhood_kwargs["status"]
|
|
569
|
+
status_options = [
|
|
570
|
+
"--" if s is None else s for s in status_options
|
|
571
|
+
]
|
|
572
|
+
idx0 = self.reference_population_status_cb.findText(
|
|
573
|
+
status_options[0]
|
|
574
|
+
)
|
|
575
|
+
self.reference_population_status_cb.setCurrentIndex(idx0)
|
|
576
|
+
idx1 = self.neighbor_population_status_cb.findText(
|
|
577
|
+
status_options[1]
|
|
578
|
+
)
|
|
579
|
+
self.neighbor_population_status_cb.setCurrentIndex(idx1)
|
|
580
|
+
if "not_status_option" in neighborhood_kwargs:
|
|
581
|
+
not_status_option = neighborhood_kwargs["not_status_option"]
|
|
582
|
+
if not_status_option[0]:
|
|
583
|
+
self.reference_switch_status_btn.click()
|
|
584
|
+
if not_status_option[1]:
|
|
585
|
+
self.neighbor_switch_status_btn.click()
|