-
Notifications
You must be signed in to change notification settings - Fork 0
/
BetaSingleCycleGui_v4_0.py
4222 lines (3323 loc) · 174 KB
/
BetaSingleCycleGui_v4_0.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
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
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""This is the main window of the software to exytract and analyze bursty time series.
This is version 4.0. Since October 2021.
"""
import os
import sys
import glob
import time
import traceback
from importlib import reload
from functools import reduce
import numpy as np
import pyqtgraph as pg
import tifffile
import skimage.morphology as skmr
from skimage.measure import regionprops, label
from PyQt5.QtCore import Qt
from PyQt5 import QtGui, QtWidgets, QtCore
from openpyxl import load_workbook
import AnalysisConverter
import NucleiDetectLog
import NucleiDetect
import NucleiSegmentStackMultiCore
import NucleiConnectMultiCore
import NucleiSpotsConnection
import MultiLoadLsmOrTif5D
import MultiLoadCzi5D
import MultiLoadLif5D
import SpotsConnection
import LabelsModify
import AnalysisSaver
import SpotsDetectionChopper
import SpotsDetection3D
import ParametersExtraction
import FalseColored3Ch
import BurstStatisticWriter
import FromTile2GlobCoordinate
import FromJournal2Fitting
import RemoveBadNuclei
import AnalysisLoader
import MultiTracePlotting_v2
import VisualNucSpot_v2
import ComprehensiveBurstAnalysisWriter
import ComprehensiveActivationWriter
import RemoveShortTraces2
import MergeXlsFiles
import WriteSteadySpotsBursting
import MultiColorIntensityGenerator
import WriteSptsIntsMinusBkg
import WriteSptsIntsDividedByBkg
import AvSpotsTime
import TimeavSptsIntensity
import SpatialDividedByBkg
import PopUpTool
import GalleryDividedByBackground
import CalibrationSpatial
import RescueFunctions
import SpotTracker
import VisualTracked
import TracesImage
class MainWindow(QtWidgets.QMainWindow):
"""Main windows: coordinates all the actions, algorithms, visualization tools and analysis tools"""
def __init__(self, parent=None):
QtWidgets.QMainWindow.__init__(self, parent)
widget = QtWidgets.QWidget(self)
self.setCentralWidget(widget)
exit_action = QtWidgets.QAction(QtGui.QIcon('Icons/exit.png'), '&Exit', self)
exit_action.setShortcut('Ctrl+Q')
exit_action.setStatusTip("Exit application")
exit_action.triggered.connect(self.close)
multiload_action = QtWidgets.QAction(QtGui.QIcon('Icons/load-hi.png'), "&Load data file", self)
multiload_action.setShortcut('Ctrl+L')
multiload_action.setStatusTip("Load .tif, .lsm, .czi or .lif files: if they are more than one, they will be concatenate")
multiload_action.triggered.connect(self.load_several_files)
load_analysis_action = QtWidgets.QAction(QtGui.QIcon('Icons/load-hi.png'), "&Load analysis", self)
load_analysis_action.setShortcut('Ctrl+A')
load_analysis_action.setStatusTip("Load analysis")
load_analysis_action.triggered.connect(self.load_analysis)
save_action = QtWidgets.QAction(QtGui.QIcon('Icons/save-md.png'), "&Save analysis", self)
save_action.setShortcut('Ctrl+S')
save_action.setStatusTip("Save analysis")
save_action.triggered.connect(self.find_zero_in_mtss)
rescue_analysis_action = QtWidgets.QAction(QtGui.QIcon('Icons/float-blisters.png'), "&Rescue analysis", self)
rescue_analysis_action.setShortcut('Ctrl+K')
rescue_analysis_action.setStatusTip("Rescue analysis")
rescue_analysis_action.triggered.connect(self.rescue_analysis)
popup_nuclei_raw_action = QtWidgets.QAction("&Pop-up Raw Nuclei", self)
popup_nuclei_raw_action.setStatusTip("Generate figures with the raw nuclei data")
popup_nuclei_raw_action.triggered.connect(self.popup_nuclei_raw)
popup_nuclei_detected_action = QtWidgets.QAction("&Pop-up Detected Nuclei", self)
popup_nuclei_detected_action.setStatusTip("Generate figures with the detected nuclei")
popup_nuclei_detected_action.triggered.connect(self.popup_nuclei_detected)
popup_nuclei_segmented_action = QtWidgets.QAction("&Pop-up Segmented Nuclei", self)
popup_nuclei_segmented_action.setStatusTip("Generate figures with the detected nuclei")
popup_nuclei_segmented_action.triggered.connect(self.popup_nuclei_segmented)
popup_nuclei_tracked_action = QtWidgets.QAction("&Pop-up Tracked Nuclei", self)
popup_nuclei_tracked_action.setStatusTip("Generate figures with the tracked nuclei")
popup_nuclei_tracked_action.triggered.connect(self.popup_nuclei_trackeded)
popup_spots_raw_action = QtWidgets.QAction("&Pop-up Raw Spots", self)
popup_spots_raw_action.setStatusTip("Generate figures with the raw spots")
popup_spots_raw_action.triggered.connect(self.popup_spots_raw)
popup_spots_segm_action = QtWidgets.QAction("&Pop-up Segmented Spots", self)
popup_spots_segm_action.setStatusTip("Generate figures with the segmented spots")
popup_spots_segm_action.triggered.connect(self.popup_spots_segm)
popup_nucactive_action = QtWidgets.QAction(QtGui.QIcon('Icons/popup.png'), "&Pop-up Active Nuclei", self)
popup_nucactive_action.setStatusTip("Generate a figure with the active nuclei map")
popup_nucactive_action.triggered.connect(self.popup_nucactive)
del_frame_action = QtWidgets.QAction(QtGui.QIcon('Icons/delete_frame.png'), "&Delete Current Frame", self)
del_frame_action.setStatusTip("Delete the current frame from raw data")
del_frame_action.triggered.connect(self.del_frame)
roi_crop_action = QtWidgets.QAction(QtGui.QIcon('Icons/crop.png'), "&Crop Stack", self)
roi_crop_action.setStatusTip("Define a ROI to crop data stack")
roi_crop_action.triggered.connect(self.roi_crop)
activ_dynamic_fitting_action = QtWidgets.QAction("&Activation Dynamic", self)
activ_dynamic_fitting_action.setStatusTip("Perform an analysis on the dynamic of nuclei activation")
activ_dynamic_fitting_action.triggered.connect(self.act_dynamic_study)
test_spots_detection_action = QtWidgets.QAction(QtGui.QIcon('Icons/sccpre.png'), "&Test Spots Detection", self)
test_spots_detection_action.setStatusTip("Test the spots detection on a sample of your data")
test_spots_detection_action.triggered.connect(self.test_spots_detection)
test_nuclei_detection_action = QtWidgets.QAction(QtGui.QIcon('Icons/sccpre.png'), "&Test Nuclei Detection", self)
test_nuclei_detection_action.setStatusTip("Test the nuclei detection on a sample of your data")
test_nuclei_detection_action.triggered.connect(self.test_nuclei_detection)
test_nuclei_detection_action.setShortcut("Ctrl+N")
spatial_comprehensive_action = QtWidgets.QAction(QtGui.QIcon('Icons/geo_pin.jpg'), "&Spatial Comprehensive", self)
spatial_comprehensive_action.setStatusTip('Perform a comprehensive spatial analysis for bursting')
spatial_comprehensive_action.triggered.connect(self.spatial_comprehensive)
spatial_comprehensive_action.setShortcut('Ctrl+H')
single_nucleus_action = QtWidgets.QAction(QtGui.QIcon('Icons/plot_single_trace.png'), "&Single Nucleus Inspection", self)
single_nucleus_action.setStatusTip('Perform a comprehensive spatial analysis for bursting')
single_nucleus_action.triggered.connect(self.single_nucleus)
single_nucleus_action.setShortcut('Ctrl+B')
multi_plot_show_action = QtWidgets.QAction(QtGui.QIcon('Icons/plot_multi_trace.png'), "&Show Multi Plot", self)
multi_plot_show_action.setStatusTip("Inspection of All Spots Traces")
multi_plot_show_action.triggered.connect(self.multi_plot_show)
multi_plot_show_action.setShortcut('Ctrl+M')
set_color_channel_action = QtWidgets.QAction(QtGui.QIcon('Icons/set_channels.png'), "&Set Channels Numbers", self)
set_color_channel_action.setStatusTip("&Set Channels Numbers")
set_color_channel_action.triggered.connect(self.set_color_channel)
multi_color_intensity_action = QtWidgets.QAction(QtGui.QIcon('Icons/multi_color_icon.png'), "&Multi Color Intensity", self)
multi_color_intensity_action.setStatusTip("Visualize spots intensity as color on nuclei")
multi_color_intensity_action.triggered.connect(self.multi_color_intensity)
multi_color_intensity_action.setShortcut('Ctrl+Y')
spts_intensity_minus_bkg_action = QtWidgets.QAction(QtGui.QIcon('Icons/background_remove.jpg'), "&Spots Remove Bkg", self)
spts_intensity_minus_bkg_action.setStatusTip("Write an .xls file with the intensity of the spots minus the background")
spts_intensity_minus_bkg_action.triggered.connect(self.spts_intensity_minus_bkg)
timeav_spts_intensity_action = QtWidgets.QAction(QtGui.QIcon('Icons/clessidra.svg'), "&Time Average Spots by Bkg", self)
timeav_spts_intensity_action.setStatusTip("Write an .xls file with the average time intensity of the spots normalized by the background")
timeav_spts_intensity_action.triggered.connect(self.timeav_spts_intensity)
timeav_spts_intensity_action.setShortcut('Ctrl+E')
check_saturation_action = QtWidgets.QAction(QtGui.QIcon('Icons/check_saturation.png'), "&Check Saturation", self)
check_saturation_action.setStatusTip('Inspection of All Spots Traces')
check_saturation_action.triggered.connect(self.check_saturation)
calibration_spatial_action = QtWidgets.QAction(QtGui.QIcon('Icons/caliber.png'), '&Traces Calibration', self)
calibration_spatial_action.setStatusTip("Shows the gallery of the spots spatially selected divided by the background")
calibration_spatial_action.triggered.connect(self.calibration_spatial)
traces_image_action = QtWidgets.QAction(QtGui.QIcon('Icons/foot_traces.png'), '&Traces Image', self)
traces_image_action.setStatusTip("Plot the traces as a image, even pooling togheter several analyses")
traces_image_action.triggered.connect(self.traces_image)
rmv_mitoticalTS_action = QtWidgets.QAction(QtGui.QIcon('Icons/eraser.png'), '&Remove Mitotical TS', self)
rmv_mitoticalTS_action.setStatusTip("Pop up tool to remove mitotical spots")
rmv_mitoticalTS_action.triggered.connect(self.rmv_mitoticalTS)
rmv_mitoticalTS_action.setShortcut('Ctrl+U')
# sisters_split_action = QtWidgets.QAction(QtGui.QIcon('Icons/sisters_split.png'), '&Allele Split', self)
# sisters_split_action.setStatusTip("Split the sister chromatine tracking")
# sisters_split_action.triggered.connect(self.sisters_split)
# sisters_split_action.setShortcut('Ctrl+G')
remove_nucsdust_action = QtWidgets.QAction(QtGui.QIcon('Icons/duster.png'), '&Remove Nuclear Dust', self)
remove_nucsdust_action.setStatusTip("Remove small objects detected in the nuclei channel")
remove_nucsdust_action.triggered.connect(self.remove_nucsdust)
remove_nucsdust_action.setShortcut('Ctrl+O')
analysis_conversion_action = QtWidgets.QAction('&Analysis Converter', self)
analysis_conversion_action.setStatusTip("Convert analysis 3.3 -> 4.0")
analysis_conversion_action.triggered.connect(self.analysis_conversion)
self.statusBar()
menubar = self.menuBar()
fileMenu = menubar.addMenu('&File')
fileMenu.addAction(multiload_action)
fileMenu.addAction(save_action)
fileMenu.addAction(load_analysis_action)
fileMenu.addAction(rescue_analysis_action)
fileMenu.addAction(exit_action)
modifyMenu = menubar.addMenu('&Modify')
modifyMenu.addAction(roi_crop_action)
modifyMenu.addAction(del_frame_action)
modifyMenu.addAction(set_color_channel_action)
modifyMenu.addAction(rmv_mitoticalTS_action)
modifyMenu.addAction(remove_nucsdust_action)
testMenu = menubar.addMenu('&Test Analysis')
testMenu.addAction(test_nuclei_detection_action)
testMenu.addAction(test_spots_detection_action)
checkMenu = menubar.addMenu('&Check Data')
checkMenu.addAction(check_saturation_action)
posterioriMenu = menubar.addMenu('&Post Processing')
posterioriMenu.addAction(spatial_comprehensive_action)
posterioriMenu.addAction(single_nucleus_action)
posterioriMenu.addAction(multi_plot_show_action)
posterioriMenu.addAction(multi_color_intensity_action)
posterioriMenu.addAction(spts_intensity_minus_bkg_action)
posterioriMenu.addAction(timeav_spts_intensity_action)
posterioriMenu.addAction(calibration_spatial_action)
posterioriMenu.addAction(traces_image_action)
# posterioriMenu.addAction(sisters_split_action)
popupMenu = menubar.addMenu('&PopUp')
popup_nuclei = popupMenu.addMenu(QtGui.QIcon('Icons/popup.png'), "PopUp Nuclei")
popup_nuclei.addAction(popup_nuclei_raw_action)
popup_nuclei.addAction(popup_nuclei_detected_action)
popup_nuclei.addAction(popup_nuclei_segmented_action)
popup_nuclei.addAction(popup_nuclei_tracked_action)
popup_spots = popupMenu.addMenu(QtGui.QIcon('Icons/popup.png'), "PopUp Spots")
popup_spots.addAction(popup_spots_raw_action)
popup_spots.addAction(popup_spots_segm_action)
popupMenu.addAction(popup_nucactive_action)
momentaryMenu = menubar.addMenu("&Temporary")
momentaryMenu.addAction(activ_dynamic_fitting_action)
momentaryMenu.addAction(analysis_conversion_action)
# helpMenu = menubar.addMenu('&Help')
frame1 = pg.ImageView(self)
frame1.ui.roiBtn.hide()
frame1.ui.menuBtn.hide()
frame2 = pg.ImageView(self)
frame2.ui.roiBtn.hide()
frame2.ui.menuBtn.hide()
frame2.ui.histogram.hide()
frame3 = pg.ImageView(self)
frame3.ui.roiBtn.hide()
frame3.ui.menuBtn.hide()
frame4 = pg.ImageView(self)
frame4.ui.roiBtn.hide()
frame4.ui.menuBtn.hide()
frame4.ui.histogram.hide()
fname_edt = QtWidgets.QLineEdit(self)
fname_edt.setToolTip('Name of the file you are working on')
sld1 = QtWidgets.QSlider(QtCore.Qt.Horizontal, self)
sld1.valueChanged.connect(self.sld1_update)
start_cut_btn = QtWidgets.QPushButton("Start", self)
start_cut_btn.clicked.connect(self.start_cut)
start_cut_btn.setToolTip('Select the first frame to consider')
start_cut_btn.setFixedSize(50, 25)
end_cut_btn = QtWidgets.QPushButton("End", self)
end_cut_btn.clicked.connect(self.end_cut)
end_cut_btn.setToolTip('Select the last frame to consider')
end_cut_btn.setFixedSize(50, 25)
reload_cut_btn = QtWidgets.QPushButton("Reload", self)
reload_cut_btn.clicked.connect(self.reload_files)
reload_cut_btn.setToolTip('Reload selected files')
reload_cut_btn.setFixedSize(110, 25)
auto_run_btn = QtWidgets.QPushButton("Auto Run", self)
auto_run_btn.clicked.connect(self.auto_run)
auto_run_btn.setToolTip('Run all the unsupervised analysis in a row')
auto_run_btn.setFixedSize(110, 25)
auto_run_btn.setEnabled(False)
auto_run_tggl = QtWidgets.QCheckBox('Enable Auto', self)
auto_run_tggl.stateChanged.connect(self.auto_run_enable)
auto_run_tggl.setFixedSize(110, 25)
nuc_detect_btn = QtWidgets.QPushButton("N-Detect", self)
nuc_detect_btn.clicked.connect(self.nuclei_detection)
nuc_detect_btn.setToolTip('Nuclei detection')
nuc_detect_btn.setFixedSize(110, 25)
param_detect_lbl = QtWidgets.QLabel("Gauss Size", self)
param_detect_lbl.setFixedSize(60, 25)
param_detect_edt = QtWidgets.QLineEdit(self)
param_detect_edt.textChanged[str].connect(self.param_detect_var)
param_detect_edt.setToolTip('Sets the size of the Gaussian Filter for the pre-smoothing (1.5) or for the logharitmic detection (0.995 - 1.005)')
param_detect_edt.setFixedSize(35, 25)
param_detect_box = QtWidgets.QHBoxLayout()
param_detect_box.addWidget(param_detect_lbl)
param_detect_box.addWidget(param_detect_edt)
gaus_log_detect_combo = QtWidgets.QComboBox(self)
gaus_log_detect_combo.addItem("Gauss Flt")
gaus_log_detect_combo.addItem("Log Flt")
gaus_log_detect_combo.setCurrentIndex(0)
gaus_log_detect_combo.setToolTip('Switch between a linear nuclei detection and a logaritmic nuclei detection')
gaus_log_detect_combo.activated[str].connect(self.gaus_log_detect)
nuc_segment_btn = QtWidgets.QPushButton("N-Segment", self)
nuc_segment_btn.clicked.connect(self.nuclei_segmentation)
nuc_segment_btn.setToolTip('Nuclei Segmentation')
nuc_segment_btn.setFixedSize(110, 25)
gfilt_water_lbl = QtWidgets.QLabel('W-Shed', self)
gfilt_water_lbl.setFixedSize(60, 25)
gfilt_water_edt = QtWidgets.QLineEdit(self)
gfilt_water_edt.textChanged[str].connect(self.gfilt_water_var)
gfilt_water_edt.setToolTip('Sets the size parameter for the Water Shed algorithm, suggested value 7')
gfilt_water_edt.setFixedSize(35, 25)
circ_thr_lbl = QtWidgets.QLabel('Circ Thr', self)
circ_thr_lbl.setFixedSize(60, 25)
circ_thr_edt = QtWidgets.QLineEdit(self)
circ_thr_edt.textChanged[str].connect(self.circ_thr_var)
circ_thr_edt.setToolTip('Circularity Threshold of the detected nuclei, suggested value is 0.65')
circ_thr_edt.setFixedSize(35, 25)
modify_segm_btn = QtWidgets.QPushButton("Modify Segm", self)
modify_segm_btn.clicked.connect(self.modify_tool)
modify_segm_btn.setToolTip('Modify Nuclei Segmentation')
modify_segm_btn.setFixedSize(110, 25)
nuc_track_btn = QtWidgets.QPushButton("N-Track", self)
nuc_track_btn.clicked.connect(self.nuclei_tracking)
nuc_track_btn.setToolTip('Nuclei Tracking')
nuc_track_btn.setFixedSize(110, 25)
dist_thr_lbl = QtWidgets.QLabel('Dist Thr', self)
dist_thr_lbl.setFixedSize(60, 25)
dist_thr_edt = QtWidgets.QLineEdit(self)
dist_thr_edt.textChanged[str].connect(self.dist_thr_var)
dist_thr_edt.setToolTip('Distance threshold to track nuclei; suggested value 10')
dist_thr_edt.setFixedSize(35, 25)
spots_thr_lbl = QtWidgets.QLabel('Spots Thr', self)
spots_thr_lbl.setFixedSize(60, 25)
spots_thr_edt = QtWidgets.QLineEdit(self)
spots_thr_edt.textChanged[str].connect(self.spots_thr_var)
spots_thr_edt.setToolTip('Intensity threshold to segment spots: it is expressed in terms of standard deviation, suggested value 7')
spots_thr_edt.setFixedSize(35, 25)
volume_thr_lbl = QtWidgets.QLabel('Vol Thr', self)
volume_thr_lbl.setFixedSize(60, 25)
volume_thr_edt = QtWidgets.QLineEdit(self)
volume_thr_edt.textChanged[str].connect(self.volume_thr_var)
volume_thr_edt.setToolTip('Threshold volume on spot detection: suggested value 5')
volume_thr_edt.setFixedSize(35, 25)
spots_detect_btn = QtWidgets.QPushButton("S-Detect", self)
spots_detect_btn.clicked.connect(self.spots_detect)
spots_detect_btn.setToolTip('Spots Detection')
spots_detect_btn.setFixedSize(110, 25)
spots_visual_btn = QtWidgets.QPushButton("Visualize Spots", self)
spots_visual_btn.clicked.connect(self.spots_visual)
spots_visual_btn.setToolTip('Updates Spots Detection')
spots_visual_btn.setFixedSize(110, 25)
nuc_spots_conn_btn = QtWidgets.QPushButton("S-N Connect", self)
nuc_spots_conn_btn.clicked.connect(self.nuc_spots_conn)
nuc_spots_conn_btn.setToolTip('Connect Spots to Nuclei')
nuc_spots_conn_btn.setFixedSize(110, 25)
fake_coloured_time_btn = QtWidgets.QPushButton("False Clrs Time", self)
fake_coloured_time_btn.clicked.connect(self.fake_coloured_time)
fake_coloured_time_btn.setToolTip('Generate false coloured movie with time information')
fake_coloured_time_btn.setFixedSize(110, 25)
time_step_lbl = QtWidgets.QLabel('T Step', self)
time_step_lbl.setFixedSize(50, 25)
time_step_edt = QtWidgets.QLineEdit(self)
time_step_edt.textChanged[str].connect(self.time_step_var)
time_step_edt.setToolTip('Duration in seconds of the time step')
time_step_edt.setFixedSize(55, 25)
busy_lbl = QtWidgets.QLabel("Ready")
busy_lbl.setStyleSheet('color: green')
busy_box = QtWidgets.QHBoxLayout()
busy_box.addWidget(busy_lbl)
busy_box.addStretch()
time_lbl = QtWidgets.QLabel("time " + '0', self)
time_lbl.setFixedSize(110, 13)
frame_numb_lbl = QtWidgets.QLabel("frame " + '0', self)
frame_numb_lbl.setFixedSize(110, 13)
hor_line_one = QtWidgets.QFrame()
hor_line_one.setFrameStyle(QtWidgets.QFrame.HLine)
hor_line_two = QtWidgets.QFrame()
hor_line_two.setFrameStyle(QtWidgets.QFrame.HLine)
cut_box_h = QtWidgets.QHBoxLayout()
cut_box_h.addWidget(start_cut_btn)
cut_box_h.addWidget(end_cut_btn)
cut_box = QtWidgets.QVBoxLayout()
cut_box.addLayout(cut_box_h)
cut_box.addWidget(reload_cut_btn)
h1box = QtWidgets.QHBoxLayout()
h1box.addWidget(frame1)
h1box.addWidget(frame2)
h2box = QtWidgets.QHBoxLayout()
h2box.addWidget(frame3)
h2box.addWidget(frame4)
v2box = QtWidgets.QVBoxLayout()
v2box.addWidget(fname_edt)
v2box.addLayout(h1box)
v2box.addLayout(h2box)
v2box.addWidget(sld1)
v2box.addLayout(busy_box)
key_ver1 = QtWidgets.QVBoxLayout()
key_ver1.addWidget(hor_line_one)
key_ver1.addWidget(auto_run_tggl)
key_ver1.addWidget(auto_run_btn)
key_ver1.addWidget(hor_line_two)
key_ver1.addLayout(param_detect_box)
key_ver1.addWidget(gaus_log_detect_combo)
key_ver1.addWidget(nuc_detect_btn)
key_ver1.addStretch()
gseg_hor = QtWidgets.QHBoxLayout()
gseg_hor.addWidget(gfilt_water_lbl)
gseg_hor.addWidget(gfilt_water_edt)
circ_thr_hor = QtWidgets.QHBoxLayout()
circ_thr_hor.addWidget(circ_thr_lbl)
circ_thr_hor.addWidget(circ_thr_edt)
key_ver2 = QtWidgets.QVBoxLayout()
key_ver2.addLayout(gseg_hor)
key_ver2.addLayout(circ_thr_hor)
key_ver2.addWidget(nuc_segment_btn)
key_ver2.addStretch()
dist_thr_hor = QtWidgets.QHBoxLayout()
dist_thr_hor.addWidget(dist_thr_lbl)
dist_thr_hor.addWidget(dist_thr_edt)
key_modifing = QtWidgets.QVBoxLayout()
key_modifing.addWidget(modify_segm_btn)
key_ver3 = QtWidgets.QVBoxLayout()
key_ver3.addLayout(dist_thr_hor)
key_ver3.addWidget(nuc_track_btn)
key_ver3.addStretch()
spots_thr_hor = QtWidgets.QHBoxLayout()
spots_thr_hor.addWidget(spots_thr_lbl)
spots_thr_hor.addWidget(spots_thr_edt)
volume_thr_hor = QtWidgets.QHBoxLayout()
volume_thr_hor.addWidget(volume_thr_lbl)
volume_thr_hor.addWidget(volume_thr_edt)
key_ver4 = QtWidgets.QVBoxLayout()
key_ver4.addLayout(spots_thr_hor)
key_ver4.addLayout(volume_thr_hor)
key_ver4.addWidget(spots_detect_btn)
key_ver4.addStretch()
key_ver4.addWidget(nuc_spots_conn_btn)
key_ver4.addWidget(spots_visual_btn)
key_ver4.addWidget(fake_coloured_time_btn)
key_time_step = QtWidgets.QHBoxLayout()
key_time_step.addWidget(time_step_lbl)
key_time_step.addWidget(time_step_edt)
key_tot = QtWidgets.QVBoxLayout()
key_tot.addLayout(cut_box)
key_tot.addStretch()
key_tot.addLayout(key_ver1)
key_tot.addLayout(key_ver2)
key_tot.addLayout(key_modifing)
key_tot.addLayout(key_ver3)
key_tot.addStretch()
key_tot.addLayout(key_ver4)
key_tot.addStretch()
key_tot.addLayout(key_time_step)
key_tot.addWidget(time_lbl)
key_tot.addWidget(frame_numb_lbl)
layout = QtWidgets.QHBoxLayout(widget)
layout.addLayout(v2box)
layout.addLayout(key_tot)
mycmap = np.fromfile("mycmap.bin", "uint16").reshape((10000, 3)) # / 255.0
self.colors4map = []
for k in range(mycmap.shape[0]):
self.colors4map.append(mycmap[k, :])
self.colors4map[0] = np.array([0, 0, 0])
self.frame1 = frame1
self.frame2 = frame2
self.frame3 = frame3
self.frame4 = frame4
self.fname_edt = fname_edt
self.sld1 = sld1
self.nuc_segment_btn = nuc_segment_btn
self.auto_run_btn = auto_run_btn
self.nuc_detect_btn = nuc_detect_btn
self.gfilt_water_lbl = gfilt_water_lbl
self.gfilt_water_edt = gfilt_water_edt
self.circ_thr_lbl = circ_thr_lbl
self.circ_thr_edt = circ_thr_edt
self.modify_segm_btn = modify_segm_btn
self.nuc_track_btn = nuc_track_btn
self.dist_thr_lbl = dist_thr_lbl
self.dist_thr_edt = dist_thr_edt
self.spots_thr_edt = spots_thr_edt
self.volume_thr_edt = volume_thr_edt
self.volume_thr_lbl = volume_thr_lbl
self.spots_detect_btn = spots_detect_btn
self.param_detect_lbl = param_detect_lbl
self.param_detect_edt = param_detect_edt
self.gaus_log_detect_combo = gaus_log_detect_combo
self.time_step_edt = time_step_edt
self.gaus_log_detect_value = "Gauss Flt"
self.data_flag = 0
self.labbs_flag = 0
self.nuclei_flag = 0
self.nuclei_t_visual_flag = 0
self.spots_segm_flag = 0
self.spots_trk_flag = 0
self.start_cut_value = 0
self.end_cut_value = 0
self.bm_dm_am = 0
self.log_flag = 0
self.nucs_spts_ch = np.array([1, 0])
self.busy_lbl = busy_lbl
self.t_track_end_value = 0
self.time_lbl = time_lbl
self.frame_numb_lbl = frame_numb_lbl
self.software_version = "SegmentTrackSingleCycleGUI_v4.0"
self.setGeometry(100, 100, 1200, 800)
self.setWindowTitle(self.software_version)
self.setWindowIcon(QtGui.QIcon('Icons/MLL_Logo2.png'))
self.show()
def closeEvent(self, event):
"Close the GUI, asking confirmation"
quit_msg = "Are you sure you want to exit the program?"
reply = QtWidgets.QMessageBox.question(self, 'Message', quit_msg, QtWidgets.QMessageBox.Yes, QtWidgets.QMessageBox.No)
if reply == QtWidgets.QMessageBox.Yes:
event.accept()
else:
event.ignore()
def busy_indicator(self):
"""Write a red text (BUSY) as a label on the GUI (bottom left)"""
self.busy_lbl.setText("Busy")
self.busy_lbl.setStyleSheet('color: red')
def ready_indicator(self):
"""Write a green text (READY) as a label on the GUI (bottom left)"""
self.busy_lbl.setText("Ready")
self.busy_lbl.setStyleSheet('color: green')
def auto_run_enable(self, state):
"""Enable the possibility to run all the unsupervised part in a row"""
if state == QtCore.Qt.Checked:
self.auto_run_btn.setEnabled(True)
self.nuc_detect_btn.setEnabled(False)
self.nuc_segment_btn.setEnabled(False)
self.spots_detect_btn.setEnabled(False)
else:
self.auto_run_btn.setEnabled(False)
self.nuc_detect_btn.setEnabled(True)
self.nuc_segment_btn.setEnabled(True)
self.spots_detect_btn.setEnabled(True)
def roi_crop(self):
"""Call CroppingTool Tool"""
self.mpp8 = CroppingTool(self.filedata.imarray_red, self.filedata.imarray_green)
self.mpp8.show()
self.mpp8.procStart.connect(self.crop_tool_sgnl)
def load_several_files(self):
"""Load, concatenate and visualize raw data to start the analysis"""
self.busy_indicator()
app.processEvents()
app.processEvents()
try:
self.fnames = QtWidgets.QFileDialog.getOpenFileNames(None, "Select czi (or lsm) data files to concatenate...", filter="*.lsm *.czi *.tif *.lif")[0]
if str(self.fnames[0])[-3:] == 'lsm' or str(self.fnames[0])[-3:] == 'tif':
self.filedata = MultiLoadLsmOrTif5D.MultiLoadLsmOrTif5D(self.fnames, self.nucs_spts_ch)
self.time_step_edt.setText(str(self.filedata.time_step_value))
if str(self.fnames[0])[-3:] == 'czi':
self.filedata = MultiLoadCzi5D.MultiProcLoadCzi5D(self.fnames, self.nucs_spts_ch)
self.time_step_edt.setText(str(self.filedata.time_step_value))
if str(self.fnames[0])[-3:] == 'lif':
self.filedata = MultiLoadLif5D.MultiLoadLif5D(self.fnames, self.nucs_spts_ch)
self.time_step_edt.setText(str(self.filedata.time_step_value))
self.frame1.setImage(self.filedata.imarray_red[0, :, :])
self.frame3.setImage(self.filedata.imarray_green[0, :, :])
self.data_flag = 1
self.sld1.setMaximum(self.filedata.imarray_red.shape[0] - 1)
self.sld1.setValue(0)
joined_fnames = ' '
for s in range(len(self.fnames)):
joined_fnames += str(self.fnames[s]) + ' ----- '
self.fname_edt.setText(joined_fnames)
except Exception:
traceback.print_exc()
self.ready_indicator()
def load_analysis(self):
"""Load an already done analysis"""
self.busy_indicator()
app.processEvents()
app.processEvents()
try:
foldername = str(QtWidgets.QFileDialog.getExistingDirectory(None, "Select the folder with the analyzed data"))
self.fname_edt.setText(foldername)
app.processEvents()
app.processEvents()
self.filedata = AnalysisLoader.RawData(foldername)
self.spots_3D = AnalysisLoader.SpotsIntsVol(foldername)
self.features_3D = AnalysisLoader.Features(foldername)
self.nucs_spts_ch = np.fromfile(foldername + '/nucs_spts_ch.bin', "uint16")
self.nuclei_tracked = np.load(foldername + '/nuclei_tracked.npy')
self.labbs = np.sign(self.nuclei_tracked)
# wb = open_workbook(foldername + '/journal.xls')
wb = load_workbook(foldername + '/journal.xlsx')
s_wb = wb.worksheets[0]
# if s_wb.col(1)[1].value == "Log Flt":
if s_wb["B2"].value == "Log Flt":
self.gaus_log_detect_combo.setCurrentIndex(0)
self.param_detect_lbl.setText("Gauss Size")
else:
self.gaus_log_detect_combo.setCurrentIndex(1)
self.param_detect_lbl.setText("Thr Coeff")
self.param_detect_edt.setText(str(s_wb["B3"].value))
self.gfilt_water_edt.setText(str(int(s_wb["B4"].value)))
self.circ_thr_edt.setText(str(s_wb["B5"].value))
self.dist_thr_edt.setText(str(int(s_wb["B6"].value)))
self.spots_thr_edt.setText(str(s_wb["B7"].value))
self.volume_thr_edt.setText(str(int(s_wb["B8"].value)))
self.time_step_edt.setText(str(float(s_wb["B12"].value)))
self.gaus_log_detect_value = s_wb["B2"].value
self.gfilt_water_value = int(s_wb["B4"].value)
self.circ_thr_value = s_wb["B5"].value
self.dist_thr_value = int(s_wb["B6"].value)
self.spots_thr_value = s_wb["B7"].value
self.volume_thr_value = int(s_wb["B8"].value)
self.max_dist = int(s_wb["B11"].value)
self.time_step_value = float(s_wb["B12"].value)
self.px_brd = int(s_wb["B13"].value)
self.nuclei_seg = np.zeros(self.filedata.imarray_red.shape, dtype=np.uint32)
for t in range(self.nuclei_tracked.shape[0]):
self.nuclei_seg[t, :, :] = skmr.label(self.nuclei_tracked[t, :, :], connectivity=1)
self.sld1.setMaximum(self.filedata.imarray_red.shape[0] - 1)
self.data_flag = 1
self.nuclei_t_visual_flag = 1
self.spots_segm_flag = 1
self.frame1.setImage(self.filedata.imarray_red[0, :, :])
self.frame3.setImage(self.filedata.imarray_green[0, :, :])
self.frame2.setImage(self.nuclei_tracked[0, :, :], levels=(0, self.nuclei_tracked.max()))
self.mycmap = pg.ColorMap(np.linspace(0, 1, self.nuclei_tracked.max()), color=self.colors4map)
self.frame2.setColorMap(self.mycmap)
self.fnames = foldername
self.nuc_spots_conn4load_analysis()
except Exception:
traceback.print_exc()
self.ready_indicator()
def start_cut(self):
"""Select the current frame as first frame to analyze"""
self.filedata.imarray_red = self.filedata.imarray_red[self.sld1.value():, :, :]
self.filedata.imarray_green = self.filedata.imarray_green[self.sld1.value():, :, :]
self.filedata.green4D = self.filedata.green4D[self.sld1.value():, :, :, :]
self.start_cut_value = self.sld1.value()
self.sld1.setMaximum(self.filedata.imarray_red[:, 0, 0].size - 1)
self.sld1.setValue(0)
def end_cut(self):
"""Select the current frame as last frame to analyze"""
self.filedata.imarray_red = self.filedata.imarray_red[:self.sld1.value() + 1, :, :]
self.filedata.imarray_green = self.filedata.imarray_green[:self.sld1.value() + 1, :, :]
self.filedata.green4D = self.filedata.green4D[:self.sld1.value() + 1, :, :, :]
self.end_cut_value = self.sld1.value()
self.sld1.setMaximum(self.filedata.imarray_red[:, 0, 0].size - 1)
self.sld1.setValue(self.filedata.imarray_red[:, 0, 0].size - 1)
def reload_files(self):
"""reload( and concatenate the files already selected"""
self.busy_indicator()
app.processEvents()
app.processEvents()
try:
if str(self.fnames[0])[-3:] == 'lsm' or str(self.fnames[0])[-3:] == 'tif':
self.filedata = MultiLoadLsmOrTif5D.MultiLoadLsmOrTif5D(self.fnames, self.nucs_spts_ch)
if str(self.fnames[0])[-3:] == 'czi':
self.filedata = MultiLoadCzi5D.MultiProcLoadCzi5D(self.fnames, self.nucs_spts_ch)
self.frame1.setImage(self.filedata.imarray_red[0, :, :])
self.frame3.setImage(self.filedata.imarray_green[0, :, :])
self.data_flag = 1
self.sld1.setMaximum(self.filedata.imarray_red[:, 0, 0].size - 1)
self.sld1.setValue(0)
except Exception:
traceback.print_exc()
self.ready_indicator()
def sld1_update(self):
self.time_lbl.setText("time " + time.strftime("%M:%S", time.gmtime(self.sld1.value() * self.time_step_value)))
self.frame_numb_lbl.setText("frame " + str(self.sld1.value()))
if self.data_flag == 1:
self.frame1.setImage(self.filedata.imarray_red[self.sld1.value(), :, :])
self.frame3.setImage(self.filedata.imarray_green[self.sld1.value(), :, :])
if self.labbs_flag == 1:
self.frame2.setImage(np.sign(self.labbs[self.sld1.value(), :, :]))
if self.nuclei_flag == 1:
self.frame2.setImage(self.nuclei_seg[self.sld1.value(), :, :])
if self.nuclei_t_visual_flag == 1:
self.frame2.setImage(self.nuclei_tracked[self.sld1.value(), :, :], levels=(0, self.nuclei_tracked.max()))
if self.spots_segm_flag == 1:
self.frame4.setImage(np.sign(self.spots_3D.spots_ints[self.sld1.value(), :, :]))
if self.spots_trk_flag == 1:
self.frame4.setImage(np.sign(self.spots_tracked_3D[self.sld1.value(), :, :]))
def find_zero_in_mtss(self):
"""Launch the tool to set the time zero on the mitosis"""
self.busy_indicator()
app.processEvents()
app.processEvents()
try:
self.mpp17 = CheckSelectedRawData(self.filedata.imarray_red[0], self.nucs_spts_ch)
self.mpp17.show()
except Exception:
traceback.print_exc()
self.ready_indicator()
self.mpp17.procStart.connect(self.loop_for_find_mtss)
def loop_for_find_mtss(self):
"""Manage the possible situation of the tool to check the zero"""
if self.mpp17.flag_yes_no == "yes":
self.time_zero = self.mpp17.pz[0] - self.mpp17.mtss_frame
print(self.time_zero)
self.save_analysis()
self.mpp17.close()
if self.mpp17.flag_yes_no == "no":
print("no")
self.mpp17.close()
self.find_zero_in_mtss()
def save_analysis(self):
"""Save the analysis"""
self.busy_indicator()
app.processEvents()
app.processEvents()
try:
fwritename = QtWidgets.QFileDialog.getSaveFileName()[0]
reload(AnalysisSaver)
reload(WriteSptsIntsDividedByBkg)
AnalysisSaver.AnalysisSaver(fwritename, self.fnames, self.nuc_active.nuclei_active3c, self.nuclei_tracked, self.spots_tracked_3D, self.features_3D, self.nuc_active.n_active_vector,
self.filedata.imarray_red, self.filedata.imarray_green, self.spots_3D, self.gfilt_water_value, self.circ_thr_value, self.dist_thr_value, self.spots_thr_value,
self.volume_thr_value, self.start_cut_value, self.end_cut_value, self.nuc_active.popt, self.nuc_active.perr, self.max_dist, self.gaus_log_detect_value,
self.param_detect_value, self.time_step_value, self.time_zero, self.px_brd, self.filedata.pix_size, self.filedata.pix_size_Z, self.nucs_spts_ch, self.t_track_end_value, self.software_version)
BurstStatisticWriter.BurstStatisticWriter(fwritename, self.features_3D)
WriteSptsIntsDividedByBkg.WriteSptsIntsDividedByBkg(fwritename, self.filedata.green4D, self.spots_3D, self.spots_tracked_3D)
os.remove('rescue_fnames.txt')
rescue_del = glob.glob("*.npy")
for k in rescue_del:
os.remove(k)
except Exception:
traceback.print_exc()
self.ready_indicator()
def gaus_log_detect(self, text):
"""Change label for nucs detection parameters"""
self.gaus_log_detect_value = text
if text == "Gauss Flt":
self.param_detect_lbl.setText("Gauss Size")
else:
self.param_detect_lbl.setText("Thr Coeff")
def param_detect_var(self, text):
"""Set nuclei detection parameter"""
self.param_detect_value = float(text)
def gfilt_water_var(self, text):
"""Set gaussian filter kernel size for water shed pre smoothing"""
self.gfilt_water_value = int(text)
def circ_thr_var(self, text):
"""Set circularity parameter"""
self.circ_thr_value = float(text)
def dist_thr_var(self, text):
self.dist_thr_value = float(text)
def spots_thr_var(self, text):
self.spots_thr_value = float(text)
def volume_thr_var(self, text):
self.volume_thr_value = int(text)
def time_step_var(self, text):
self.time_step_value = float(text)
def popup_nuclei_raw(self):
"""Popup raw nuclei"""
PopUpTool.PopUpTool(self.filedata.imarray_red, 'Nuclei Raw Data')
def popup_nuclei_detected(self):
"""Popup detected nuclei"""
PopUpTool.PopUpTool(np.sign(self.labbs), 'Detected Nuclei')
def popup_nuclei_segmented(self):
"""Popup segmented nuclei"""
PopUpTool.PopUpToolWithMap(self.nuclei_seg, 'Segmented Nuclei', self.mycmap)
def popup_nuclei_trackeded(self):
""""Popup tracked nuclei"""
PopUpTool.PopUpToolWithMap(self.nuclei_tracked, 'Tracked Nuclei', self.mycmap)
def popup_spots_raw(self):
"""Popup green raw data"""
PopUpTool.PopUpTool(self.filedata.imarray_green, 'Spots Raw Data')
def popup_spots_segm(self):
"""Popup tracked spots"""
PopUpTool.PopUpTool(np.sign(self.spots_tracked_3D), 'Segmented Spots')
def popup_nucactive(self):
"""Popup false colored movie"""
pg.image(self.nuc_active.nuclei_active3c, title="Active Nuclei")
pg.plot(self.nuc_active.n_active_vector, pen='r', symbol='x')
def nuclei_detection(self):
"""Detect raw data nuclei"""
self.busy_indicator()
app.processEvents()
app.processEvents()
try:
if self.gaus_log_detect_value == "Log Flt":
self.labbs = NucleiDetectLog.NucleiDetectLog(self.filedata.imarray_red, self.param_detect_value).labbs
else:
self.labbs = NucleiDetect.NucleiDetect(self.filedata.imarray_red, self.param_detect_value).labbs
self.labbs_flag = 1
self.nuclei_flag = 0
self.nuclei_t_visual_flag = 0
self.frame2.setImage(np.sign(self.labbs[self.sld1.value(), :, :]))
np.save('rescue_labbs', self.labbs)
np.save('rescue_rawnucs', self.filedata.imarray_red)
if self.gaus_log_detect_value == "Log Flt":
np.save('rescue_labbs_info', np.array([self.param_detect_value, 1]))
else:
np.save('rescue_labbs_info', np.array([self.param_detect_value, 0]))
file = open('rescue_fnames.txt', "w")
file.write(self.fnames[0])
for k in range(1, len(self.fnames)):
file.write('\n' + self.fnames[k])
file.close()
except Exception:
traceback.print_exc()
self.ready_indicator()
def nuclei_segmentation(self):
"""Segments detected nuclei"""
self.busy_indicator()
app.processEvents()
app.processEvents()
try:
self.nuclei_seg = NucleiSegmentStackMultiCore.NucleiSegmentStackMultiCore(self.labbs, self.circ_thr_value, self.gfilt_water_value).nuclei_labels
self.labbs_flag = 0
self.nuclei_flag = 1
self.nuclei_t_visual_flag = 0
self.frame2.setImage(self.nuclei_seg[self.sld1.value(), :, :])
self.mycmap = pg.ColorMap(np.linspace(0, 1, self.nuclei_seg.max()), color=self.colors4map)
self.frame2.setColorMap(self.mycmap)
np.save('rescue_nuclei_seg', self.nuclei_seg)
np.save('rescue_nuclei_seg_info', np.array([self.circ_thr_value, self.gfilt_water_value]))
except Exception:
traceback.print_exc()
self.ready_indicator()
def nuclei_tracking(self):
"""Track segmented nuclei"""
self.busy_indicator()
app.processEvents()
app.processEvents()
try:
# self.px_brd = BorderPixelRemove.getNumb()
self.px_brd = 3
nuclei_tracked = NucleiConnectMultiCore.NucleiConnectMultiCore(self.nuclei_seg, self.dist_thr_value).nuclei_tracked
self.nuclei_tracked = RemoveBadNuclei.RemoveBorderNuclei(nuclei_tracked, self.px_brd).nuclei_tracked
self.labbs_flag = 0
self.nuclei_flag = 0
self.nuclei_t_visual_flag = 1
self.frame2.setImage(self.nuclei_tracked[self.sld1.value(), :, :], levels=(0, self.nuclei_tracked.max()))
self.mycmap = pg.ColorMap(np.linspace(0, 1, self.nuclei_tracked.max()), color=self.colors4map)
self.frame2.setColorMap(self.mycmap)
np.save('rescue_nuclei_tracked', self.nuclei_tracked)
np.save('rescue_nuclei_tracked_info', np.array([self.dist_thr_value, self.px_brd]))