celldetective 1.2.0__py3-none-any.whl → 1.2.2__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/__main__.py +12 -5
- celldetective/events.py +28 -2
- celldetective/gui/about.py +0 -1
- celldetective/gui/analyze_block.py +3 -18
- celldetective/gui/btrack_options.py +126 -21
- celldetective/gui/classifier_widget.py +68 -107
- celldetective/gui/configure_new_exp.py +37 -4
- celldetective/gui/control_panel.py +14 -30
- celldetective/gui/generic_signal_plot.py +793 -0
- celldetective/gui/gui_utils.py +401 -226
- celldetective/gui/json_readers.py +0 -2
- celldetective/gui/layouts.py +269 -25
- celldetective/gui/measurement_options.py +14 -23
- celldetective/gui/neighborhood_options.py +6 -16
- celldetective/gui/plot_measurements.py +10 -23
- celldetective/gui/plot_signals_ui.py +53 -687
- celldetective/gui/process_block.py +320 -186
- celldetective/gui/retrain_segmentation_model_options.py +30 -47
- celldetective/gui/retrain_signal_model_options.py +5 -14
- celldetective/gui/seg_model_loader.py +129 -113
- celldetective/gui/signal_annotator.py +93 -103
- celldetective/gui/signal_annotator2.py +9 -13
- celldetective/gui/styles.py +32 -0
- celldetective/gui/survival_ui.py +49 -712
- celldetective/gui/tableUI.py +4 -39
- celldetective/gui/thresholds_gui.py +38 -11
- celldetective/gui/viewers.py +6 -7
- celldetective/io.py +62 -84
- celldetective/measure.py +374 -15
- celldetective/models/segmentation_effectors/ricm-bimodal/config_input.json +130 -0
- celldetective/models/segmentation_effectors/ricm-bimodal/ricm-bimodal +0 -0
- celldetective/models/segmentation_effectors/ricm-bimodal/training_instructions.json +37 -0
- celldetective/neighborhood.py +3 -7
- celldetective/preprocessing.py +2 -4
- celldetective/relative_measurements.py +0 -3
- celldetective/scripts/analyze_signals.py +0 -1
- celldetective/scripts/measure_cells.py +1 -3
- celldetective/scripts/measure_relative.py +1 -2
- celldetective/scripts/segment_cells.py +16 -12
- celldetective/scripts/segment_cells_thresholds.py +17 -10
- celldetective/scripts/track_cells.py +18 -18
- celldetective/scripts/train_segmentation_model.py +1 -2
- celldetective/scripts/train_signal_model.py +0 -3
- celldetective/segmentation.py +1 -1
- celldetective/signals.py +20 -8
- celldetective/tracking.py +2 -1
- celldetective/utils.py +126 -18
- {celldetective-1.2.0.dist-info → celldetective-1.2.2.dist-info}/METADATA +19 -12
- celldetective-1.2.2.dist-info/RECORD +92 -0
- {celldetective-1.2.0.dist-info → celldetective-1.2.2.dist-info}/WHEEL +1 -1
- celldetective-1.2.0.dist-info/RECORD +0 -88
- {celldetective-1.2.0.dist-info → celldetective-1.2.2.dist-info}/LICENSE +0 -0
- {celldetective-1.2.0.dist-info → celldetective-1.2.2.dist-info}/entry_points.txt +0 -0
- {celldetective-1.2.0.dist-info → celldetective-1.2.2.dist-info}/top_level.txt +0 -0
|
@@ -1,40 +1,24 @@
|
|
|
1
|
-
from PyQt5.QtWidgets import
|
|
2
|
-
QCheckBox,
|
|
3
|
-
|
|
4
|
-
from PyQt5.QtCore import Qt, QSize, QRect
|
|
1
|
+
from PyQt5.QtWidgets import QMessageBox, QComboBox, \
|
|
2
|
+
QCheckBox, QLineEdit, QVBoxLayout, QWidget, QLabel, QHBoxLayout, QPushButton
|
|
3
|
+
from PyQt5.QtCore import Qt
|
|
5
4
|
from PyQt5.QtGui import QIcon, QDoubleValidator
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
from celldetective.gui.
|
|
9
|
-
from superqt import QLabeledSlider, QColormapComboBox
|
|
10
|
-
from
|
|
11
|
-
from
|
|
12
|
-
from celldetective.
|
|
13
|
-
from celldetective.io import interpret_tracking_configuration, load_frames, auto_load_number_of_frames, load_experiment_tables
|
|
14
|
-
from celldetective.measure import compute_haralick_features, contour_of_instance_segmentation
|
|
15
|
-
from celldetective.signals import columnwise_mean, mean_signal
|
|
5
|
+
|
|
6
|
+
from celldetective.gui.gui_utils import center_window
|
|
7
|
+
from celldetective.gui.generic_signal_plot import GenericSignalPlotWidget
|
|
8
|
+
from superqt import QLabeledSlider, QColormapComboBox, QSearchableComboBox
|
|
9
|
+
from celldetective.utils import get_software_location, _extract_labels_from_config
|
|
10
|
+
from celldetective.io import load_experiment_tables
|
|
11
|
+
from celldetective.signals import mean_signal
|
|
16
12
|
import numpy as np
|
|
17
|
-
from tifffile import imread
|
|
18
|
-
import json
|
|
19
|
-
from shutil import copyfile
|
|
20
13
|
import os
|
|
21
14
|
import matplotlib.pyplot as plt
|
|
22
15
|
plt.rcParams['svg.fonttype'] = 'none'
|
|
23
|
-
from mpl_toolkits.axes_grid1 import make_axes_locatable
|
|
24
16
|
from glob import glob
|
|
25
17
|
from natsort import natsorted
|
|
26
|
-
from tifffile import imread
|
|
27
|
-
from pathlib import Path, PurePath
|
|
28
|
-
import gc
|
|
29
18
|
import pandas as pd
|
|
30
|
-
from tqdm import tqdm
|
|
31
|
-
from lifelines import KaplanMeierFitter
|
|
32
|
-
from matplotlib.cm import viridis, tab10
|
|
33
19
|
import math
|
|
34
20
|
from celldetective.gui import Styles
|
|
35
21
|
from matplotlib import colormaps
|
|
36
|
-
import matplotlib.cm as mcm
|
|
37
|
-
|
|
38
22
|
|
|
39
23
|
|
|
40
24
|
class ConfigSignalPlot(QWidget, Styles):
|
|
@@ -63,24 +47,17 @@ class ConfigSignalPlot(QWidget, Styles):
|
|
|
63
47
|
self.ax2=None
|
|
64
48
|
self.auto_close = False
|
|
65
49
|
|
|
66
|
-
|
|
67
|
-
print('Parent wells: ', self.wells)
|
|
68
|
-
|
|
69
|
-
|
|
70
50
|
self.well_option = self.parent_window.parent_window.well_list.currentIndex()
|
|
71
51
|
self.position_option = self.parent_window.parent_window.position_list.currentIndex()
|
|
72
52
|
self.interpret_pos_location()
|
|
73
|
-
#self.load_available_tables()
|
|
74
|
-
#self.config_path = self.exp_dir + self.config_name
|
|
75
53
|
|
|
76
54
|
self.screen_height = self.parent_window.parent_window.parent_window.screen_height
|
|
77
55
|
center_window(self)
|
|
78
|
-
#self.setMinimumHeight(int(0.8*self.screen_height))
|
|
79
|
-
#self.setMaximumHeight(int(0.8*self.screen_height))
|
|
80
56
|
self.populate_widget()
|
|
81
|
-
|
|
57
|
+
|
|
82
58
|
if self.auto_close:
|
|
83
59
|
self.close()
|
|
60
|
+
self.setAttribute(Qt.WA_DeleteOnClose)
|
|
84
61
|
|
|
85
62
|
def interpret_pos_location(self):
|
|
86
63
|
|
|
@@ -119,7 +96,7 @@ class ConfigSignalPlot(QWidget, Styles):
|
|
|
119
96
|
main_layout.addWidget(panel_title, alignment=Qt.AlignCenter)
|
|
120
97
|
|
|
121
98
|
labels = [QLabel('population: '), QLabel('class: '), QLabel('time of\ninterest: '), QLabel('cmap: ')]
|
|
122
|
-
self.cb_options = [['targets','effectors'],['class'], ['t0'],
|
|
99
|
+
self.cb_options = [['targets','effectors'],['class'], ['t0'], []]
|
|
123
100
|
self.cbs = [QComboBox() for i in range(len(labels))]
|
|
124
101
|
self.cbs[-1] = QColormapComboBox()
|
|
125
102
|
|
|
@@ -135,7 +112,8 @@ class ConfigSignalPlot(QWidget, Styles):
|
|
|
135
112
|
self.cbs[i].addItems(self.cb_options[i])
|
|
136
113
|
choice_layout.addLayout(hbox)
|
|
137
114
|
|
|
138
|
-
|
|
115
|
+
all_cms = list(colormaps)
|
|
116
|
+
for cm in all_cms:
|
|
139
117
|
try:
|
|
140
118
|
self.cbs[-1].addColormap(cm)
|
|
141
119
|
except:
|
|
@@ -244,42 +222,26 @@ class ConfigSignalPlot(QWidget, Styles):
|
|
|
244
222
|
self.feature_choice_widget.setWindowTitle("Select numeric feature")
|
|
245
223
|
layout = QVBoxLayout()
|
|
246
224
|
self.feature_choice_widget.setLayout(layout)
|
|
247
|
-
self.feature_cb =
|
|
225
|
+
self.feature_cb = QSearchableComboBox()
|
|
248
226
|
self.feature_cb.addItems(feats)
|
|
249
227
|
hbox = QHBoxLayout()
|
|
250
228
|
hbox.addWidget(QLabel('feature: '), 33)
|
|
251
229
|
hbox.addWidget(self.feature_cb, 66)
|
|
252
230
|
#hbox.addWidget((QLabel('Plot two features')))
|
|
253
231
|
layout.addLayout(hbox)
|
|
254
|
-
self.checkBox_feature = QCheckBox(self.feature_choice_widget)
|
|
255
|
-
self.checkBox_feature.setGeometry(QRect(170, 120, 81, 20))
|
|
256
|
-
self.checkBox_feature.setText('Plot two features')
|
|
257
|
-
#hbox.addWidget(self.checkBox_feature)
|
|
258
|
-
layout.addWidget(self.checkBox_feature, alignment=Qt.AlignCenter)
|
|
259
|
-
self.checkBox_feature.stateChanged.connect(self.enable_second_feature)
|
|
260
|
-
|
|
261
|
-
#layout = QVBoxLayout()
|
|
262
|
-
#self.feature_two_choice_widget.setLayout(layout)
|
|
263
|
-
self.feature_two_cb = QComboBox()
|
|
264
|
-
self.feature_two_cb.addItems(feats)
|
|
265
|
-
self.feature_two_cb.setEnabled(False)
|
|
266
|
-
hbox_two = QHBoxLayout()
|
|
267
|
-
hbox_two.addWidget(QLabel('feature two: '), 33)
|
|
268
|
-
hbox_two.addWidget(self.feature_two_cb, 66)
|
|
269
|
-
layout.addLayout(hbox_two)
|
|
270
|
-
|
|
271
232
|
|
|
272
233
|
self.set_feature_btn = QPushButton('set')
|
|
234
|
+
self.set_feature_btn.setStyleSheet(self.button_style_sheet)
|
|
273
235
|
self.set_feature_btn.clicked.connect(self.compute_signals)
|
|
274
236
|
layout.addWidget(self.set_feature_btn)
|
|
275
237
|
self.feature_choice_widget.show()
|
|
276
238
|
center_window(self.feature_choice_widget)
|
|
277
239
|
|
|
278
|
-
def enable_second_feature(self):
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
240
|
+
# def enable_second_feature(self):
|
|
241
|
+
# if self.checkBox_feature.isChecked():
|
|
242
|
+
# self.feature_two_cb.setEnabled(True)
|
|
243
|
+
# else:
|
|
244
|
+
# self.feature_two_cb.setEnabled(False)
|
|
283
245
|
|
|
284
246
|
def compute_signals(self):
|
|
285
247
|
|
|
@@ -293,245 +255,38 @@ class ConfigSignalPlot(QWidget, Styles):
|
|
|
293
255
|
print(e, ' The query is misunderstood and will not be applied...')
|
|
294
256
|
|
|
295
257
|
self.feature_selected = self.feature_cb.currentText()
|
|
296
|
-
if self.checkBox_feature.isChecked():
|
|
297
|
-
self.second_feature_selected=self.feature_two_cb.currentText()
|
|
298
|
-
print(self.second_feature_selected)
|
|
299
258
|
self.feature_choice_widget.close()
|
|
300
259
|
self.compute_signal_functions()
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
self.survivalWidget = QWidget()
|
|
305
|
-
self.scroll = QScrollArea()
|
|
306
|
-
self.survivalWidget.setMinimumHeight(int(0.8*self.screen_height))
|
|
307
|
-
self.survivalWidget.setWindowTitle('signals')
|
|
308
|
-
self.plotvbox = QVBoxLayout(self.survivalWidget)
|
|
309
|
-
self.plotvbox.setContentsMargins(30,30,30,30)
|
|
310
|
-
self.survival_title = QLabel('Signal function')
|
|
311
|
-
self.survival_title.setStyleSheet("""
|
|
312
|
-
font-weight: bold;
|
|
313
|
-
padding: 0px;
|
|
314
|
-
""")
|
|
315
|
-
self.plotvbox.addWidget(self.survival_title, alignment=Qt.AlignCenter)
|
|
316
|
-
|
|
317
|
-
plot_buttons_hbox = QHBoxLayout()
|
|
318
|
-
plot_buttons_hbox.addWidget(QLabel(''),80, alignment=Qt.AlignLeft)
|
|
319
|
-
|
|
320
|
-
self.legend_btn = QPushButton('')
|
|
321
|
-
self.legend_btn.setIcon(icon(MDI6.text_box,color="black"))
|
|
322
|
-
self.legend_btn.setStyleSheet(self.button_select_all)
|
|
323
|
-
self.legend_btn.setToolTip('Show or hide the legend')
|
|
324
|
-
self.legend_visible = True
|
|
325
|
-
self.legend_btn.clicked.connect(self.show_hide_legend)
|
|
326
|
-
plot_buttons_hbox.addWidget(self.legend_btn, 5,alignment=Qt.AlignRight)
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
self.log_btn = QPushButton('')
|
|
330
|
-
self.log_btn.setIcon(icon(MDI6.math_log,color="black"))
|
|
331
|
-
self.log_btn.setStyleSheet(self.button_select_all)
|
|
332
|
-
self.log_btn.clicked.connect(self.switch_to_log)
|
|
333
|
-
self.log_btn.setToolTip('Enable or disable log scale')
|
|
334
|
-
plot_buttons_hbox.addWidget(self.log_btn, 5, alignment=Qt.AlignRight)
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
self.ci_btn = QPushButton('')
|
|
338
|
-
self.ci_btn.setIcon(icon(MDI6.arrow_expand_horizontal,color="blue"))
|
|
339
|
-
self.ci_btn.setStyleSheet(self.button_select_all)
|
|
340
|
-
self.ci_btn.clicked.connect(self.switch_ci)
|
|
341
|
-
self.ci_btn.setToolTip('Show or hide confidence intervals.')
|
|
342
|
-
plot_buttons_hbox.addWidget(self.ci_btn, 5, alignment=Qt.AlignRight)
|
|
343
|
-
|
|
344
|
-
self.cell_lines_btn = QPushButton('')
|
|
345
|
-
self.cell_lines_btn.setIcon(icon(MDI6.view_headline,color="black"))
|
|
346
|
-
self.cell_lines_btn.setStyleSheet(self.button_select_all)
|
|
347
|
-
self.cell_lines_btn.clicked.connect(self.switch_cell_lines)
|
|
348
|
-
self.cell_lines_btn.setToolTip('Show or hide individual cell signals.')
|
|
349
|
-
plot_buttons_hbox.addWidget(self.cell_lines_btn, 5, alignment=Qt.AlignRight)
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
self.fig, self.ax = plt.subplots(1,1,figsize=(4,3))
|
|
353
|
-
#self.setMinimumHeight(100)
|
|
354
|
-
self.survival_window = FigureCanvas(self.fig, title="Survival")
|
|
355
|
-
self.survival_window.setContentsMargins(0,0,0,0)
|
|
356
|
-
if self.df is not None:
|
|
357
|
-
self.initialize_axis()
|
|
358
|
-
plt.tight_layout()
|
|
359
|
-
|
|
360
|
-
cmap_lbl = self.cbs[-1].currentText()
|
|
361
|
-
self.cmap = getattr(mcm, cmap_lbl)
|
|
362
|
-
self.ax.set_prop_cycle('color',[self.cmap(i) for i in np.linspace(0, 1, len(self.well_indices))])
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
self.fig.set_facecolor('none') # or 'None'
|
|
366
|
-
self.fig.canvas.setStyleSheet("background-color: transparent;")
|
|
367
|
-
self.survival_window.canvas.draw()
|
|
368
|
-
|
|
369
|
-
#self.survival_window.layout.addWidget(QLabel('WHAAAAATTT???'))
|
|
370
|
-
|
|
371
|
-
self.plot_options = [QRadioButton() for i in range(3)]
|
|
372
|
-
self.radio_labels = ['well', 'pos', 'both']
|
|
373
|
-
radio_hbox = QHBoxLayout()
|
|
374
|
-
radio_hbox.setContentsMargins(30,30,30,30)
|
|
375
|
-
self.plot_btn_group = QButtonGroup()
|
|
376
|
-
for i in range(3):
|
|
377
|
-
self.plot_options[i].setText(self.radio_labels[i])
|
|
378
|
-
#self.plot_options[i].toggled.connect(self.plot_survivals)
|
|
379
|
-
self.plot_btn_group.addButton(self.plot_options[i])
|
|
380
|
-
radio_hbox.addWidget(self.plot_options[i], 33, alignment=Qt.AlignCenter)
|
|
381
|
-
self.plot_btn_group.buttonClicked[int].connect(self.plot_survivals)
|
|
382
|
-
|
|
383
|
-
if self.position_indices is not None:
|
|
384
|
-
if len(self.well_indices)>1 and len(self.position_indices)==1:
|
|
385
|
-
self.plot_btn_group.buttons()[0].click()
|
|
386
|
-
for i in [1,2]:
|
|
387
|
-
self.plot_options[i].setEnabled(False)
|
|
388
|
-
elif len(self.well_indices)>1:
|
|
389
|
-
self.plot_btn_group.buttons()[0].click()
|
|
390
|
-
elif len(self.well_indices)==1 and len(self.position_indices)==1:
|
|
391
|
-
self.plot_btn_group.buttons()[1].click()
|
|
392
|
-
for i in [0,2]:
|
|
393
|
-
self.plot_options[i].setEnabled(False)
|
|
394
|
-
else:
|
|
395
|
-
if len(self.well_indices)>1:
|
|
396
|
-
self.plot_btn_group.buttons()[0].click()
|
|
397
|
-
elif len(self.well_indices)==1:
|
|
398
|
-
self.plot_btn_group.buttons()[2].click()
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
# elif len(self.well_indices)>1:
|
|
402
|
-
# self.plot_btn_group.buttons()[0].click()
|
|
403
|
-
# else:
|
|
404
|
-
# self.plot_btn_group.buttons()[1].click()
|
|
405
|
-
|
|
406
|
-
# if self.position_indices is not None:
|
|
407
|
-
# for i in [0,2]:
|
|
408
|
-
# self.plot_options[i].setEnabled(False)
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
#self.plot_options[0].setChecked(True)
|
|
412
|
-
self.plotvbox.addLayout(radio_hbox)
|
|
413
|
-
self.plotvbox.addLayout(plot_buttons_hbox)
|
|
414
|
-
self.plotvbox.addWidget(self.survival_window)
|
|
415
|
-
self.class_selection_lbl = QLabel('Select class')
|
|
416
|
-
self.class_selection_lbl.setStyleSheet("""
|
|
417
|
-
font-weight: bold;
|
|
418
|
-
padding: 0px;
|
|
419
|
-
""")
|
|
420
|
-
self.plotvbox.addWidget(self.class_selection_lbl, alignment=Qt.AlignCenter)
|
|
421
|
-
class_selection_hbox = QHBoxLayout()
|
|
422
|
-
class_selection_hbox.setContentsMargins(30,30,30,30)
|
|
423
|
-
self.all_btn = QRadioButton('*')
|
|
424
|
-
self.all_btn.setChecked(True)
|
|
425
|
-
self.event_btn = QRadioButton('event')
|
|
426
|
-
self.no_event_btn = QRadioButton('no event')
|
|
427
|
-
self.class_btn_group = QButtonGroup()
|
|
428
|
-
for btn in [self.all_btn, self.event_btn, self.no_event_btn]:
|
|
429
|
-
self.class_btn_group.addButton(btn)
|
|
430
|
-
|
|
431
|
-
self.class_btn_group.buttonClicked[int].connect(self.set_class_to_plot)
|
|
432
|
-
|
|
433
|
-
class_selection_hbox.addWidget(self.all_btn, 33, alignment=Qt.AlignLeft)
|
|
434
|
-
class_selection_hbox.addWidget(self.event_btn, 33, alignment=Qt.AlignCenter)
|
|
435
|
-
class_selection_hbox.addWidget(self.no_event_btn, 33, alignment=Qt.AlignRight)
|
|
436
|
-
self.plotvbox.addLayout(class_selection_hbox)
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
self.select_pos_label = QLabel('Select positions')
|
|
440
|
-
self.select_pos_label.setStyleSheet("""
|
|
441
|
-
font-weight: bold;
|
|
442
|
-
padding: 0px;
|
|
443
|
-
""")
|
|
444
|
-
self.plotvbox.addWidget(self.select_pos_label, alignment=Qt.AlignCenter)
|
|
445
|
-
|
|
446
|
-
self.select_option = [QRadioButton() for i in range(2)]
|
|
447
|
-
self.select_label = ['name', 'spatial']
|
|
448
|
-
select_hbox = QHBoxLayout()
|
|
449
|
-
select_hbox.setContentsMargins(30,30,30,30)
|
|
450
|
-
self.select_btn_group = QButtonGroup()
|
|
451
|
-
for i in range(2):
|
|
452
|
-
self.select_option[i].setText(self.select_label[i])
|
|
453
|
-
#self.select_option[i].toggled.connect(self.switch_selection_mode)
|
|
454
|
-
self.select_btn_group.addButton(self.select_option[i])
|
|
455
|
-
select_hbox.addWidget(self.select_option[i],33, alignment=Qt.AlignCenter)
|
|
456
|
-
self.select_btn_group.buttonClicked[int].connect(self.switch_selection_mode)
|
|
457
|
-
self.plotvbox.addLayout(select_hbox)
|
|
458
|
-
|
|
459
|
-
self.look_for_metadata()
|
|
460
|
-
if self.metadata_found:
|
|
461
|
-
self.fig_scatter, self.ax_scatter = plt.subplots(1,1,figsize=(4,3))
|
|
462
|
-
self.position_scatter = FigureCanvas(self.fig_scatter)
|
|
463
|
-
self.load_coordinates()
|
|
464
|
-
self.plot_spatial_location()
|
|
465
|
-
#self.plot_positions()
|
|
466
|
-
self.ax_scatter.spines['top'].set_visible(False)
|
|
467
|
-
self.ax_scatter.spines['right'].set_visible(False)
|
|
468
|
-
self.ax_scatter.set_aspect('equal')
|
|
469
|
-
self.ax_scatter.set_xticks([])
|
|
470
|
-
self.ax_scatter.set_yticks([])
|
|
471
|
-
plt.tight_layout()
|
|
472
|
-
|
|
473
|
-
self.fig_scatter.set_facecolor('none') # or 'None'
|
|
474
|
-
self.fig_scatter.canvas.setStyleSheet("background-color: transparent;")
|
|
475
|
-
self.plotvbox.addWidget(self.position_scatter)
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
self.generate_pos_selection_widget()
|
|
480
|
-
|
|
481
|
-
# if self.df is not None and len(self.ks_estimators_per_position)>0:
|
|
482
|
-
# self.plot_survivals()
|
|
483
|
-
self.select_btn_group.buttons()[0].click()
|
|
484
|
-
self.scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
|
|
485
|
-
self.scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
|
486
|
-
#self.scroll.setWidgetResizable(True)
|
|
487
|
-
self.scroll.setWidget(self.survivalWidget)
|
|
488
|
-
|
|
489
|
-
self.scroll.setMinimumHeight(int(0.8*self.screen_height))
|
|
490
|
-
self.survivalWidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
|
491
|
-
self.scroll.show()
|
|
492
|
-
|
|
260
|
+
self.interpret_pos_location()
|
|
261
|
+
self.plot_window = GenericSignalPlotWidget(parent_window=self, df=self.df, df_pos_info = self.df_pos_info, df_well_info = self.df_well_info, feature_selected=self.feature_selected, title='plot signals')
|
|
262
|
+
self.plot_window.show()
|
|
493
263
|
|
|
494
264
|
def process_signal(self):
|
|
495
265
|
|
|
496
|
-
print('you clicked!!')
|
|
497
266
|
self.FrameToMin = float(self.time_calibration_le.text().replace(',','.'))
|
|
498
|
-
print(self.FrameToMin
|
|
267
|
+
print(f'Time calibration set to 1 frame = {self.FrameToMin} min...')
|
|
499
268
|
|
|
500
269
|
# read instructions from combobox options
|
|
501
270
|
self.load_available_tables()
|
|
271
|
+
class_col = self.cbs[1].currentText()
|
|
272
|
+
|
|
502
273
|
if self.df is not None:
|
|
503
|
-
self.ask_for_features()
|
|
504
|
-
else:
|
|
505
|
-
return None
|
|
506
274
|
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
self.line_choice_widget = QWidget()
|
|
519
|
-
self.line_check_vbox = QVBoxLayout()
|
|
520
|
-
self.line_choice_widget.setLayout(self.line_check_vbox)
|
|
521
|
-
if len(self.well_indices)>1:
|
|
522
|
-
self.well_display_options = [QCheckBox(self.usable_well_labels[i]) for i in range(len(self.usable_well_labels))]
|
|
523
|
-
for i in range(len(self.well_names)):
|
|
524
|
-
self.line_check_vbox.addWidget(self.well_display_options[i], alignment=Qt.AlignLeft)
|
|
525
|
-
self.well_display_options[i].setChecked(True)
|
|
526
|
-
self.well_display_options[i].toggled.connect(self.select_survival_lines)
|
|
275
|
+
if class_col not in list(self.df.columns):
|
|
276
|
+
msgBox = QMessageBox()
|
|
277
|
+
msgBox.setIcon(QMessageBox.Warning)
|
|
278
|
+
msgBox.setText("The class of interest could not be found in the data. Abort.")
|
|
279
|
+
msgBox.setWindowTitle("Warning")
|
|
280
|
+
msgBox.setStandardButtons(QMessageBox.Ok)
|
|
281
|
+
returnValue = msgBox.exec()
|
|
282
|
+
if returnValue == QMessageBox.Ok:
|
|
283
|
+
return None
|
|
284
|
+
else:
|
|
285
|
+
self.ask_for_features()
|
|
527
286
|
else:
|
|
528
|
-
|
|
529
|
-
for i in range(len(self.pos_names)):
|
|
530
|
-
self.line_check_vbox.addWidget(self.pos_display_options[i], alignment=Qt.AlignLeft)
|
|
531
|
-
self.pos_display_options[i].setChecked(True)
|
|
532
|
-
self.pos_display_options[i].toggled.connect(self.select_survival_lines)
|
|
287
|
+
return None
|
|
533
288
|
|
|
534
|
-
self.plotvbox.addWidget(self.line_choice_widget, alignment=Qt.AlignCenter)
|
|
289
|
+
#self.plotvbox.addWidget(self.line_choice_widget, alignment=Qt.AlignCenter)
|
|
535
290
|
|
|
536
291
|
def load_available_tables(self):
|
|
537
292
|
|
|
@@ -579,7 +334,8 @@ class ConfigSignalPlot(QWidget, Styles):
|
|
|
579
334
|
max_time = int(self.df.FRAME.max()) + 1
|
|
580
335
|
class_col = self.cbs[1].currentText()
|
|
581
336
|
time_col = self.cbs[2].currentText()
|
|
582
|
-
|
|
337
|
+
if self.abs_time_checkbox.isChecked():
|
|
338
|
+
time_col = self.frame_slider.value()
|
|
583
339
|
|
|
584
340
|
for block,movie_group in self.df.groupby(['well','position']):
|
|
585
341
|
|
|
@@ -587,28 +343,13 @@ class ConfigSignalPlot(QWidget, Styles):
|
|
|
587
343
|
well_signal_event, well_std_event, timeline_event, matrix_event = mean_signal(movie_group, self.feature_selected, class_col, time_col=time_col, class_value=[0], return_matrix=True, forced_max_duration=max_time)
|
|
588
344
|
well_signal_no_event, well_std_no_event, timeline_no_event, matrix_no_event = mean_signal(movie_group, self.feature_selected, class_col, time_col=time_col, class_value=[1], return_matrix=True, forced_max_duration=max_time)
|
|
589
345
|
self.mean_plots_timeline = timeline_all
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
self.second_mean_plots_timeline = second_timeline_all
|
|
598
|
-
self.df_pos_info.loc[self.df_pos_info['pos_path'] == block[1], 'signal'] = [
|
|
599
|
-
{'mean_all': well_signal_mean, 'std_all': well_std_mean,'matrix_all': matrix_all,'mean_event': well_signal_event, 'std_event': well_std_event,
|
|
600
|
-
'matrix_event': matrix_event,'mean_no_event': well_signal_no_event, 'std_no_event': well_std_no_event, 'matrix_no_event': matrix_no_event, 'timeline': self.mean_plots_timeline,'second_mean_all': second_well_signal_mean, 'second_std_all': second_well_std_mean, 'second_matrix_all': second_matrix_all,
|
|
601
|
-
'second_mean_event': second_well_signal_event, 'second_std_event': second_well_std_event,
|
|
602
|
-
'second_matrix_event': second_matrix_event, 'second_mean_no_event': second_well_signal_no_event,
|
|
603
|
-
'second_std_no_event': second_well_std_no_event, 'second_matrix_no_event': second_matrix_no_event,
|
|
604
|
-
'second_timeline': self.second_mean_plots_timeline}]
|
|
605
|
-
else:
|
|
606
|
-
self.df_pos_info.loc[self.df_pos_info['pos_path'] == block[1], 'signal'] = [
|
|
607
|
-
{'mean_all': well_signal_mean, 'std_all': well_std_mean, 'matrix_all': matrix_all,
|
|
608
|
-
'mean_event': well_signal_event, 'std_event': well_std_event,
|
|
609
|
-
'matrix_event': matrix_event, 'mean_no_event': well_signal_no_event,
|
|
610
|
-
'std_no_event': well_std_no_event, 'matrix_no_event': matrix_no_event,
|
|
611
|
-
'timeline': self.mean_plots_timeline}]
|
|
346
|
+
|
|
347
|
+
self.df_pos_info.loc[self.df_pos_info['pos_path'] == block[1], 'signal'] = [
|
|
348
|
+
{'mean_all': well_signal_mean, 'std_all': well_std_mean, 'matrix_all': matrix_all,
|
|
349
|
+
'mean_event': well_signal_event, 'std_event': well_std_event,
|
|
350
|
+
'matrix_event': matrix_event, 'mean_no_event': well_signal_no_event,
|
|
351
|
+
'std_no_event': well_std_no_event, 'matrix_no_event': matrix_no_event,
|
|
352
|
+
'timeline': self.mean_plots_timeline}]
|
|
612
353
|
|
|
613
354
|
# Per well
|
|
614
355
|
for well,well_group in self.df.groupby('well'):
|
|
@@ -616,24 +357,12 @@ class ConfigSignalPlot(QWidget, Styles):
|
|
|
616
357
|
well_signal_mean, well_std_mean, timeline_all, matrix_all = mean_signal(well_group, self.feature_selected, class_col, time_col=time_col, class_value=[0,1], return_matrix=True, forced_max_duration=max_time)
|
|
617
358
|
well_signal_event, well_std_event, timeline_event, matrix_event = mean_signal(well_group, self.feature_selected, class_col, time_col=time_col, class_value=[0], return_matrix=True, forced_max_duration=max_time)
|
|
618
359
|
well_signal_no_event, well_std_no_event, timeline_no_event, matrix_no_event = mean_signal(well_group, self.feature_selected, class_col, time_col=time_col, class_value=[1], return_matrix=True, forced_max_duration=max_time)
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
second_well_signal_event, second_well_std_event, second_timeline_event, second_matrix_event = mean_signal(movie_group, self.second_feature_selected, class_col, time_col=time_col, class_value=[0], return_matrix=True, forced_max_duration=max_time)
|
|
622
|
-
second_well_signal_no_event, second_well_std_no_event, second_timeline_no_event, second_matrix_no_event = mean_signal(movie_group, self.second_feature_selected, class_col, time_col=time_col, class_value=[1], return_matrix=True, forced_max_duration=max_time)
|
|
623
|
-
self.df_well_info.loc[self.df_well_info['well_path'] == well, 'signal'] = [
|
|
624
|
-
{'mean_all': well_signal_mean, 'std_all': well_std_mean,'matrix_all': matrix_all,'mean_event': well_signal_event, 'std_event': well_std_event,
|
|
625
|
-
'matrix_event': matrix_event,'mean_no_event': well_signal_no_event, 'std_no_event': well_std_no_event, 'matrix_no_event': matrix_no_event, 'timeline': self.mean_plots_timeline,'second_mean_all': second_well_signal_mean, 'second_std_all': second_well_std_mean, 'second_matrix_all': second_matrix_all,
|
|
626
|
-
'second_mean_event': second_well_signal_event, 'second_std_event': second_well_std_event,
|
|
627
|
-
'second_matrix_event': second_matrix_event, 'second_mean_no_event': second_well_signal_no_event,
|
|
628
|
-
'second_std_no_event': second_well_std_no_event, 'second_matrix_no_event': second_matrix_no_event,
|
|
629
|
-
'second_timeline': self.second_mean_plots_timeline}]
|
|
630
|
-
else:
|
|
631
|
-
self.df_well_info.loc[self.df_well_info['well_path']==well,'signal'] = [{'mean_all': well_signal_mean, 'std_all': well_std_mean,'matrix_all': matrix_all,'mean_event': well_signal_event, 'std_event': well_std_event,
|
|
360
|
+
|
|
361
|
+
self.df_well_info.loc[self.df_well_info['well_path']==well,'signal'] = [{'mean_all': well_signal_mean, 'std_all': well_std_mean,'matrix_all': matrix_all,'mean_event': well_signal_event, 'std_event': well_std_event,
|
|
632
362
|
'matrix_event': matrix_event,'mean_no_event': well_signal_no_event, 'std_no_event': well_std_no_event, 'matrix_no_event': matrix_no_event, 'timeline': self.mean_plots_timeline}]
|
|
633
363
|
|
|
634
364
|
self.df_pos_info.loc[:,'select'] = True
|
|
635
365
|
self.df_well_info.loc[:,'select'] = True
|
|
636
|
-
self.df_pos_info.to_csv('pos_info.csv')
|
|
637
366
|
|
|
638
367
|
|
|
639
368
|
def generate_synchronized_matrix(self, well_group, feature_selected, cclass, max_time):
|
|
@@ -698,337 +427,6 @@ class ConfigSignalPlot(QWidget, Styles):
|
|
|
698
427
|
|
|
699
428
|
return mean_line, std_line
|
|
700
429
|
|
|
701
|
-
def initialize_axis(self):
|
|
702
|
-
|
|
703
|
-
self.ax.clear()
|
|
704
|
-
self.ax.plot([],[])
|
|
705
|
-
self.ax.spines['top'].set_visible(False)
|
|
706
|
-
self.ax.spines['right'].set_visible(False)
|
|
707
|
-
self.ax.set_ylim(self.df[self.feature_selected].min(),self.df[self.feature_selected].max())
|
|
708
|
-
self.ax.set_xlim(-(self.df['FRAME'].max()+2)*self.FrameToMin,(self.df['FRAME'].max()+2)*self.FrameToMin)
|
|
709
|
-
self.ax.set_xlabel('time [min]')
|
|
710
|
-
self.ax.set_ylabel(self.feature_selected)
|
|
711
|
-
if self.checkBox_feature.isChecked():
|
|
712
|
-
if self.ax2:
|
|
713
|
-
self.ax2.clear()
|
|
714
|
-
self.ax2.get_yaxis().set_visible(False)
|
|
715
|
-
self.ax2 = self.ax.twinx()
|
|
716
|
-
#self.ax2.plot([], color='red', label='Feature 2')
|
|
717
|
-
self.ax2.set_ylim(self.df[self.second_feature_selected].min(), self.df[self.second_feature_selected].max())
|
|
718
|
-
self.ax2.set_ylabel(self.second_feature_selected, color='red')
|
|
719
|
-
self.ax2.get_yaxis().set_visible(True)
|
|
720
|
-
#self.ax2.tick_params('y', colors='red')
|
|
721
|
-
|
|
722
|
-
def plot_survivals(self, id):
|
|
723
|
-
|
|
724
|
-
for i in range(3):
|
|
725
|
-
if self.plot_options[i].isChecked():
|
|
726
|
-
self.plot_mode = self.radio_labels[i]
|
|
727
|
-
|
|
728
|
-
if self.target_class==[0,1]:
|
|
729
|
-
mean_signal = 'mean_all'
|
|
730
|
-
std_signal = 'std_all'
|
|
731
|
-
matrix = 'matrix_all'
|
|
732
|
-
if self.checkBox_feature.isChecked():
|
|
733
|
-
second_mean_signal='second_mean_all'
|
|
734
|
-
second_std_signal='second_std_all'
|
|
735
|
-
second_matrix='second_matrix_all'
|
|
736
|
-
elif self.target_class==[0]:
|
|
737
|
-
mean_signal = 'mean_event'
|
|
738
|
-
std_signal = 'std_event'
|
|
739
|
-
matrix = 'matrix_event'
|
|
740
|
-
if self.checkBox_feature.isChecked():
|
|
741
|
-
second_mean_signal='second_mean_event'
|
|
742
|
-
second_std_signal='second_std_event'
|
|
743
|
-
second_matrix='second_matrix_event'
|
|
744
|
-
else:
|
|
745
|
-
mean_signal = 'mean_no_event'
|
|
746
|
-
std_signal = 'std_no_event'
|
|
747
|
-
matrix = 'matrix_no_event'
|
|
748
|
-
if self.checkBox_feature.isChecked():
|
|
749
|
-
second_mean_signal='second_mean_no_event'
|
|
750
|
-
second_std_signal='second_std_no_event'
|
|
751
|
-
second_matrix='second_matrix_no_event'
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
colors = np.array([self.cmap(i / len(self.df_pos_info)) for i in range(len(self.df_pos_info))])
|
|
755
|
-
if self.checkBox_feature.isChecked():
|
|
756
|
-
second_colors = self.cmap(np.linspace(0.5, 1.5, len(self.df_pos_info)))
|
|
757
|
-
well_color = [self.cmap(i / len(self.df_well_info)) for i in range(len(self.df_well_info))]
|
|
758
|
-
|
|
759
|
-
if self.plot_mode=='pos':
|
|
760
|
-
self.initialize_axis()
|
|
761
|
-
lines = self.df_pos_info.loc[self.df_pos_info['select'],'signal'].values
|
|
762
|
-
pos_labels = self.df_pos_info.loc[self.df_pos_info['select'],'pos_name'].values
|
|
763
|
-
pos_indices = self.df_pos_info.loc[self.df_pos_info['select'],'pos_index'].values
|
|
764
|
-
well_index = self.df_pos_info.loc[self.df_pos_info['select'],'well_index'].values
|
|
765
|
-
for i in range(len(lines)):
|
|
766
|
-
if len(self.well_indices)<=1:
|
|
767
|
-
self.plot_line(lines[i], colors[pos_indices[i]], pos_labels[i], mean_signal, std_signal=std_signal, ci_option=self.show_ci, cell_lines_option=self.show_cell_lines, matrix=matrix)
|
|
768
|
-
if self.checkBox_feature.isChecked():
|
|
769
|
-
self.plot_line(lines[i],second_colors[pos_indices[i]],pos_labels[i],second_mean_signal,std_signal=second_std_signal,ci_option=self.show_ci, cell_lines_option=self.show_cell_lines, matrix=second_matrix)
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
else:
|
|
773
|
-
self.plot_line(lines[i], well_color[well_index[i]], pos_labels[i], mean_signal, std_signal=std_signal, ci_option=self.show_ci, cell_lines_option=self.show_cell_lines, matrix=matrix)
|
|
774
|
-
if self.checkBox_feature.isChecked():
|
|
775
|
-
self.plot_line(lines[i],second_colors[pos_indices[i]],pos_labels[i],second_mean_signal,std_signal=second_std_signal,ci_option=self.show_ci, cell_lines_option=self.show_cell_lines, matrix=second_matrix)
|
|
776
|
-
|
|
777
|
-
elif self.plot_mode=='well':
|
|
778
|
-
self.initialize_axis()
|
|
779
|
-
lines = self.df_well_info.loc[self.df_well_info['select'],'signal'].values
|
|
780
|
-
well_index = self.df_well_info.loc[self.df_well_info['select'],'well_index'].values
|
|
781
|
-
well_labels = self.df_well_info.loc[self.df_well_info['select'],'well_name'].values
|
|
782
|
-
for i in range(len(lines)):
|
|
783
|
-
if len(self.well_indices)<=1:
|
|
784
|
-
self.plot_line(lines[i], 'k', well_labels[i], mean_signal, std_signal=std_signal, ci_option=self.show_ci, cell_lines_option=self.show_cell_lines,matrix=matrix)
|
|
785
|
-
if self.checkBox_feature.isChecked():
|
|
786
|
-
self.plot_line(lines[i], 'k', well_labels[i], second_mean_signal, std_signal=second_std_signal,
|
|
787
|
-
ci_option=self.show_ci, cell_lines_option=self.show_cell_lines, matrix=second_matrix)
|
|
788
|
-
else:
|
|
789
|
-
self.plot_line(lines[i], well_color[well_index[i]], well_labels[i], mean_signal, std_signal=std_signal, ci_option=self.show_ci, cell_lines_option=self.show_cell_lines,matrix=matrix)
|
|
790
|
-
if self.checkBox_feature.isChecked():
|
|
791
|
-
self.plot_line(lines[i], well_color[well_index[i]], well_labels[i], second_mean_signal, std_signal=second_std_signal, ci_option=self.show_ci, cell_lines_option=self.show_cell_lines,matrix=second_matrix)
|
|
792
|
-
|
|
793
|
-
elif self.plot_mode=='both':
|
|
794
|
-
self.initialize_axis()
|
|
795
|
-
lines_pos = self.df_pos_info.loc[self.df_pos_info['select'],'signal'].values
|
|
796
|
-
lines_well = self.df_well_info.loc[self.df_well_info['select'],'signal'].values
|
|
797
|
-
|
|
798
|
-
pos_indices = self.df_pos_info.loc[self.df_pos_info['select'],'pos_index'].values
|
|
799
|
-
well_index_pos = self.df_pos_info.loc[self.df_pos_info['select'],'well_index'].values
|
|
800
|
-
well_index = self.df_well_info.loc[self.df_well_info['select'],'well_index'].values
|
|
801
|
-
well_labels = self.df_well_info.loc[self.df_well_info['select'],'well_name'].values
|
|
802
|
-
pos_labels = self.df_pos_info.loc[self.df_pos_info['select'],'pos_name'].values
|
|
803
|
-
|
|
804
|
-
for i in range(len(lines_pos)):
|
|
805
|
-
if len(self.well_indices)<=1:
|
|
806
|
-
self.plot_line(lines_pos[i], colors[pos_indices[i]], pos_labels[i], mean_signal, std_signal=std_signal, ci_option=self.show_ci, cell_lines_option=self.show_cell_lines,matrix=matrix)
|
|
807
|
-
if self.checkBox_feature.isChecked():
|
|
808
|
-
self.plot_line(lines_pos[i], second_colors[pos_indices[i]], pos_labels[i], second_mean_signal,
|
|
809
|
-
std_signal=second_std_signal, ci_option=self.show_ci,
|
|
810
|
-
cell_lines_option=self.show_cell_lines, matrix=second_matrix)
|
|
811
|
-
|
|
812
|
-
else:
|
|
813
|
-
self.plot_line(lines_pos[i], well_color[well_index_pos[i]], None, mean_signal, std_signal=std_signal, ci_option=False)
|
|
814
|
-
if self.checkBox_feature.isChecked():
|
|
815
|
-
self.plot_line(lines_pos[i], well_color[well_index_pos[i]], None, second_mean_signal,
|
|
816
|
-
std_signal=second_std_signal, ci_option=False)
|
|
817
|
-
|
|
818
|
-
for i in range(len(lines_well)):
|
|
819
|
-
if len(self.well_indices)<=1:
|
|
820
|
-
self.plot_line(lines_well[i], 'k', 'pool', mean_signal, std_signal=std_signal, ci_option=False)
|
|
821
|
-
else:
|
|
822
|
-
self.plot_line(lines_well[i], well_color[well_index[i]], well_labels[i], mean_signal, std_signal=std_signal, ci_option=False)
|
|
823
|
-
self.survival_window.setMinimumHeight(int(0.5*self.screen_height))
|
|
824
|
-
self.survival_window.setMinimumWidth(int(0.8 * self.survivalWidget.width()))
|
|
825
|
-
self.survival_window.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
|
826
|
-
|
|
827
|
-
self.survival_window.canvas.draw()
|
|
828
|
-
|
|
829
|
-
def plot_line(self, line, color, label, mean_signal, ci_option=True, cell_lines_option=False, alpha_ci=0.5, alpha_cell_lines=0.5, std_signal=None, matrix=None):
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
try:
|
|
833
|
-
if 'second' in str(mean_signal):
|
|
834
|
-
self.ax2.plot(line['timeline'] * self.FrameToMin, line[mean_signal], color=color, label=label)
|
|
835
|
-
else:
|
|
836
|
-
self.ax.plot(line['timeline']*self.FrameToMin, line[mean_signal], color=color, label=label)
|
|
837
|
-
if ci_option and std_signal is not None:
|
|
838
|
-
if 'second' in str(mean_signal):
|
|
839
|
-
self.ax2.fill_between(line['timeline'] * self.FrameToMin,
|
|
840
|
-
[a - b for a, b in zip(line[mean_signal], line[std_signal])],
|
|
841
|
-
[a + b for a, b in zip(line[mean_signal], line[std_signal])],
|
|
842
|
-
color=color,
|
|
843
|
-
alpha=alpha_ci,
|
|
844
|
-
)
|
|
845
|
-
else:
|
|
846
|
-
self.ax.fill_between(line['timeline']*self.FrameToMin,
|
|
847
|
-
[a-b for a,b in zip(line[mean_signal], line[std_signal])],
|
|
848
|
-
[a+b for a,b in zip(line[mean_signal], line[std_signal])],
|
|
849
|
-
color=color,
|
|
850
|
-
alpha=alpha_ci,
|
|
851
|
-
)
|
|
852
|
-
if cell_lines_option and matrix is not None:
|
|
853
|
-
print(mean_signal)
|
|
854
|
-
mat = line[matrix]
|
|
855
|
-
if 'second' in str(mean_signal):
|
|
856
|
-
for i in range(mat.shape[0]):
|
|
857
|
-
self.ax2.plot(line['timeline'] * self.FrameToMin, mat[i, :], color=color, alpha=alpha_cell_lines)
|
|
858
|
-
else:
|
|
859
|
-
for i in range(mat.shape[0]):
|
|
860
|
-
self.ax.plot(line['timeline']*self.FrameToMin, mat[i,:], color=color, alpha=alpha_cell_lines)
|
|
861
|
-
|
|
862
|
-
except Exception as e:
|
|
863
|
-
print(f'Exception {e}')
|
|
864
|
-
|
|
865
|
-
def switch_to_log(self):
|
|
866
|
-
|
|
867
|
-
"""
|
|
868
|
-
Switch threshold histogram to log scale. Auto adjust.
|
|
869
|
-
"""
|
|
870
|
-
|
|
871
|
-
if self.ax.get_yscale()=='linear':
|
|
872
|
-
self.ax.set_yscale('log')
|
|
873
|
-
#self.ax.set_ylim(0.01,1.05)
|
|
874
|
-
else:
|
|
875
|
-
self.ax.set_yscale('linear')
|
|
876
|
-
#self.ax.set_ylim(0.01,1.05)
|
|
877
|
-
|
|
878
|
-
#self.ax.autoscale()
|
|
879
|
-
self.survival_window.canvas.draw_idle()
|
|
880
|
-
|
|
881
|
-
def show_hide_legend(self):
|
|
882
|
-
if self.legend_visible:
|
|
883
|
-
self.ax.legend().set_visible(False)
|
|
884
|
-
self.legend_visible = False
|
|
885
|
-
self.legend_btn.setIcon(icon(MDI6.text_box_outline,color="black"))
|
|
886
|
-
else:
|
|
887
|
-
self.ax.legend().set_visible(True)
|
|
888
|
-
self.legend_visible = True
|
|
889
|
-
self.legend_btn.setIcon(icon(MDI6.text_box,color="black"))
|
|
890
|
-
|
|
891
|
-
self.survival_window.canvas.draw_idle()
|
|
892
|
-
|
|
893
|
-
def look_for_metadata(self):
|
|
894
|
-
|
|
895
|
-
self.metadata_found = False
|
|
896
|
-
self.metafiles = glob(self.exp_dir+os.sep.join([f'W*','*','movie','*metadata.txt'])) \
|
|
897
|
-
+ glob(self.exp_dir+os.sep.join([f'W*','*','*metadata.txt'])) \
|
|
898
|
-
+ glob(self.exp_dir+os.sep.join([f'W*','*metadata.txt'])) \
|
|
899
|
-
+ glob(self.exp_dir+'*metadata.txt')
|
|
900
|
-
print(f'Found {len(self.metafiles)} metadata files...')
|
|
901
|
-
if len(self.metafiles)>0:
|
|
902
|
-
self.metadata_found = True
|
|
903
|
-
|
|
904
|
-
def switch_selection_mode(self, id):
|
|
905
|
-
print(f'button {id} was clicked')
|
|
906
|
-
for i in range(2):
|
|
907
|
-
if self.select_option[i].isChecked():
|
|
908
|
-
self.selection_mode = self.select_label[i]
|
|
909
|
-
if self.selection_mode=='name':
|
|
910
|
-
if len(self.metafiles)>0:
|
|
911
|
-
self.position_scatter.hide()
|
|
912
|
-
self.line_choice_widget.show()
|
|
913
|
-
else:
|
|
914
|
-
if len(self.metafiles)>0:
|
|
915
|
-
self.position_scatter.show()
|
|
916
|
-
self.line_choice_widget.hide()
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
def load_coordinates(self):
|
|
920
|
-
|
|
921
|
-
"""
|
|
922
|
-
Read metadata and try to extract position coordinates
|
|
923
|
-
"""
|
|
924
|
-
|
|
925
|
-
self.no_meta = False
|
|
926
|
-
try:
|
|
927
|
-
with open(self.metafiles[0], 'r') as f:
|
|
928
|
-
data = json.load(f)
|
|
929
|
-
positions = data['Summary']['InitialPositionList']
|
|
930
|
-
except Exception as e:
|
|
931
|
-
print(f'Trouble loading metadata: error {e}...')
|
|
932
|
-
return None
|
|
933
|
-
|
|
934
|
-
for k in range(len(positions)):
|
|
935
|
-
pos_label = positions[k]['Label']
|
|
936
|
-
try:
|
|
937
|
-
coords = positions[k]['DeviceCoordinatesUm']['XYStage']
|
|
938
|
-
except:
|
|
939
|
-
try:
|
|
940
|
-
coords = positions[k]['DeviceCoordinatesUm']['PIXYStage']
|
|
941
|
-
except:
|
|
942
|
-
self.no_meta = True
|
|
943
|
-
|
|
944
|
-
if not self.no_meta:
|
|
945
|
-
files = self.df_pos_info['stack_path'].values
|
|
946
|
-
pos_loc = [pos_label in f for f in files]
|
|
947
|
-
self.df_pos_info.loc[pos_loc, 'x'] = coords[0]
|
|
948
|
-
self.df_pos_info.loc[pos_loc, 'y'] = coords[1]
|
|
949
|
-
self.df_pos_info.loc[pos_loc, 'metadata_tag'] = pos_label
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
def update_annot(self, ind):
|
|
953
|
-
|
|
954
|
-
pos = self.sc.get_offsets()[ind["ind"][0]]
|
|
955
|
-
self.annot.xy = pos
|
|
956
|
-
text = self.scat_labels[ind["ind"][0]]
|
|
957
|
-
self.annot.set_text(text)
|
|
958
|
-
self.annot.get_bbox_patch().set_facecolor('k')
|
|
959
|
-
self.annot.get_bbox_patch().set_alpha(0.4)
|
|
960
|
-
|
|
961
|
-
def hover(self, event):
|
|
962
|
-
vis = self.annot.get_visible()
|
|
963
|
-
if event.inaxes == self.ax_scatter:
|
|
964
|
-
cont, ind = self.sc.contains(event)
|
|
965
|
-
if cont:
|
|
966
|
-
self.update_annot(ind)
|
|
967
|
-
self.annot.set_visible(True)
|
|
968
|
-
self.fig_scatter.canvas.draw_idle()
|
|
969
|
-
else:
|
|
970
|
-
if vis:
|
|
971
|
-
self.annot.set_visible(False)
|
|
972
|
-
self.fig_scatter.canvas.draw_idle()
|
|
973
|
-
|
|
974
|
-
def unselect_position(self, event):
|
|
975
|
-
|
|
976
|
-
ind = event.ind # index of selected position
|
|
977
|
-
well_idx = self.df_pos_info.iloc[ind]['well_index'].values[0]
|
|
978
|
-
selectedPos = self.df_pos_info.iloc[ind]['pos_path'].values[0]
|
|
979
|
-
currentSelState = self.df_pos_info.iloc[ind]['select'].values[0]
|
|
980
|
-
if self.plot_options[0].isChecked() or self.plot_options[2].isChecked():
|
|
981
|
-
self.df_pos_info.loc[self.df_pos_info['well_index']==well_idx,'select'] = not currentSelState
|
|
982
|
-
self.df_well_info.loc[self.df_well_info['well_index']==well_idx, 'select'] = not currentSelState
|
|
983
|
-
if len(self.well_indices)>1:
|
|
984
|
-
self.well_display_options[well_idx].setChecked(not currentSelState)
|
|
985
|
-
else:
|
|
986
|
-
for p in self.pos_display_options:
|
|
987
|
-
p.setChecked(not currentSelState)
|
|
988
|
-
else:
|
|
989
|
-
self.df_pos_info.loc[self.df_pos_info['pos_path']==selectedPos,'select'] = not currentSelState
|
|
990
|
-
if len(self.well_indices)<=1:
|
|
991
|
-
self.pos_display_options[ind[0]].setChecked(not currentSelState)
|
|
992
|
-
|
|
993
|
-
self.sc.set_color(self.select_color(self.df_pos_info["select"].values))
|
|
994
|
-
self.position_scatter.canvas.draw_idle()
|
|
995
|
-
self.plot_survivals(0)
|
|
996
|
-
|
|
997
|
-
def select_survival_lines(self):
|
|
998
|
-
|
|
999
|
-
if len(self.well_indices)>1:
|
|
1000
|
-
for i in range(len(self.well_display_options)):
|
|
1001
|
-
self.df_well_info.loc[self.df_well_info['well_index']==i,'select'] = self.well_display_options[i].isChecked()
|
|
1002
|
-
self.df_pos_info.loc[self.df_pos_info['well_index']==i,'select'] = self.well_display_options[i].isChecked()
|
|
1003
|
-
else:
|
|
1004
|
-
for i in range(len(self.pos_display_options)):
|
|
1005
|
-
self.df_pos_info.loc[self.df_pos_info['pos_index']==i,'select'] = self.pos_display_options[i].isChecked()
|
|
1006
|
-
|
|
1007
|
-
if len(self.metafiles)>0:
|
|
1008
|
-
self.sc.set_color(self.select_color(self.df_pos_info["select"].values))
|
|
1009
|
-
self.position_scatter.canvas.draw_idle()
|
|
1010
|
-
self.plot_survivals(0)
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
def select_color(self, selection):
|
|
1014
|
-
colors = [tab10(0) if s else tab10(0.1) for s in selection]
|
|
1015
|
-
return colors
|
|
1016
|
-
|
|
1017
|
-
def plot_spatial_location(self):
|
|
1018
|
-
|
|
1019
|
-
try:
|
|
1020
|
-
self.sc = self.ax_scatter.scatter(self.df_pos_info["x"].values, self.df_pos_info["y"].values, picker=True, pickradius=1, color=self.select_color(self.df_pos_info["select"].values))
|
|
1021
|
-
self.scat_labels = self.df_pos_info['metadata_tag'].values
|
|
1022
|
-
self.ax_scatter.invert_xaxis()
|
|
1023
|
-
self.annot = self.ax_scatter.annotate("", xy=(0,0), xytext=(10,10),textcoords="offset points",
|
|
1024
|
-
bbox=dict(boxstyle="round", fc="w"),
|
|
1025
|
-
arrowprops=dict(arrowstyle="->"))
|
|
1026
|
-
self.annot.set_visible(False)
|
|
1027
|
-
self.fig_scatter.canvas.mpl_connect("motion_notify_event", self.hover)
|
|
1028
|
-
self.fig_scatter.canvas.mpl_connect("pick_event", self.unselect_position)
|
|
1029
|
-
except Exception as e:
|
|
1030
|
-
pass
|
|
1031
|
-
|
|
1032
430
|
|
|
1033
431
|
def switch_ref_time_mode(self):
|
|
1034
432
|
if self.abs_time_checkbox.isChecked():
|
|
@@ -1036,36 +434,4 @@ class ConfigSignalPlot(QWidget, Styles):
|
|
|
1036
434
|
self.cbs[-2].setEnabled(False)
|
|
1037
435
|
else:
|
|
1038
436
|
self.frame_slider.setEnabled(False)
|
|
1039
|
-
self.cbs[-2].setEnabled(True)
|
|
1040
|
-
|
|
1041
|
-
def switch_ci(self):
|
|
1042
|
-
|
|
1043
|
-
if self.show_ci:
|
|
1044
|
-
self.ci_btn.setIcon(icon(MDI6.arrow_expand_horizontal,color="black"))
|
|
1045
|
-
else:
|
|
1046
|
-
self.ci_btn.setIcon(icon(MDI6.arrow_expand_horizontal,color="blue"))
|
|
1047
|
-
self.show_ci = not self.show_ci
|
|
1048
|
-
self.plot_survivals(0)
|
|
1049
|
-
|
|
1050
|
-
def switch_cell_lines(self):
|
|
1051
|
-
|
|
1052
|
-
if self.show_cell_lines:
|
|
1053
|
-
self.cell_lines_btn.setIcon(icon(MDI6.view_headline,color="black"))
|
|
1054
|
-
else:
|
|
1055
|
-
self.cell_lines_btn.setIcon(icon(MDI6.view_headline,color="blue"))
|
|
1056
|
-
self.show_cell_lines = not self.show_cell_lines
|
|
1057
|
-
self.plot_survivals(0)
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
def set_class_to_plot(self):
|
|
1061
|
-
|
|
1062
|
-
if self.all_btn.isChecked():
|
|
1063
|
-
self.target_class=[0,1]
|
|
1064
|
-
elif self.event_btn.isChecked():
|
|
1065
|
-
self.target_class = [0]
|
|
1066
|
-
else:
|
|
1067
|
-
self.target_class = [1]
|
|
1068
|
-
|
|
1069
|
-
self.plot_survivals(0)
|
|
1070
|
-
|
|
1071
|
-
|
|
437
|
+
self.cbs[-2].setEnabled(True)
|