cellects 0.1.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.
Files changed (44) hide show
  1. cellects/__init__.py +0 -0
  2. cellects/__main__.py +49 -0
  3. cellects/config/__init__.py +0 -0
  4. cellects/config/all_vars_dict.py +155 -0
  5. cellects/core/__init__.py +0 -0
  6. cellects/core/cellects_paths.py +31 -0
  7. cellects/core/cellects_threads.py +1451 -0
  8. cellects/core/motion_analysis.py +2010 -0
  9. cellects/core/one_image_analysis.py +1061 -0
  10. cellects/core/one_video_per_blob.py +540 -0
  11. cellects/core/program_organizer.py +1316 -0
  12. cellects/core/script_based_run.py +154 -0
  13. cellects/gui/__init__.py +0 -0
  14. cellects/gui/advanced_parameters.py +1258 -0
  15. cellects/gui/cellects.py +189 -0
  16. cellects/gui/custom_widgets.py +790 -0
  17. cellects/gui/first_window.py +449 -0
  18. cellects/gui/if_several_folders_window.py +239 -0
  19. cellects/gui/image_analysis_window.py +2066 -0
  20. cellects/gui/required_output.py +232 -0
  21. cellects/gui/video_analysis_window.py +656 -0
  22. cellects/icons/__init__.py +0 -0
  23. cellects/icons/cellects_icon.icns +0 -0
  24. cellects/icons/cellects_icon.ico +0 -0
  25. cellects/image_analysis/__init__.py +0 -0
  26. cellects/image_analysis/cell_leaving_detection.py +54 -0
  27. cellects/image_analysis/cluster_flux_study.py +102 -0
  28. cellects/image_analysis/image_segmentation.py +706 -0
  29. cellects/image_analysis/morphological_operations.py +1635 -0
  30. cellects/image_analysis/network_functions.py +1757 -0
  31. cellects/image_analysis/one_image_analysis_threads.py +289 -0
  32. cellects/image_analysis/progressively_add_distant_shapes.py +508 -0
  33. cellects/image_analysis/shape_descriptors.py +1016 -0
  34. cellects/utils/__init__.py +0 -0
  35. cellects/utils/decorators.py +14 -0
  36. cellects/utils/formulas.py +637 -0
  37. cellects/utils/load_display_save.py +1054 -0
  38. cellects/utils/utilitarian.py +490 -0
  39. cellects-0.1.2.dist-info/LICENSE.odt +0 -0
  40. cellects-0.1.2.dist-info/METADATA +132 -0
  41. cellects-0.1.2.dist-info/RECORD +44 -0
  42. cellects-0.1.2.dist-info/WHEEL +5 -0
  43. cellects-0.1.2.dist-info/entry_points.txt +2 -0
  44. cellects-0.1.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,232 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ This module contains the widget allowing the user to set which variables Cellects will compute during analysis.
4
+ A first kind of variable is raw data: presence/absence coordinates of the specimens, network, oscillating pixels
5
+ A second kind of variable describe the specimen at each time frame and for each arena of the image stack or video
6
+ """
7
+
8
+ from PySide6 import QtWidgets, QtCore
9
+ import logging
10
+ from cellects.gui.custom_widgets import (
11
+ WindowType, PButton, Checkbox, FixedText)
12
+ from cellects.image_analysis.shape_descriptors import descriptors_names_to_display
13
+
14
+
15
+ class RequiredOutput(WindowType):
16
+ def __init__(self, parent, night_mode):
17
+ super().__init__(parent, night_mode)
18
+ self.setParent(parent)
19
+ # Create the main Title
20
+ self.true_init(night_mode)
21
+
22
+ def true_init(self, night_mode):
23
+
24
+ logging.info("Initialize RequiredOutput window")
25
+ self.title = FixedText('Required Output', police=30, night_mode=self.parent().po.all['night_mode'])
26
+ self.title.setAlignment(QtCore.Qt.AlignHCenter)
27
+ # Create the main layout
28
+ self.vlayout = QtWidgets.QVBoxLayout()
29
+ self.vlayout.addWidget(self.title) #
30
+ horzspaceItem = QtWidgets.QSpacerItem(1, 1, QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.MinimumExpanding)
31
+ self.vlayout.addItem(horzspaceItem) #
32
+
33
+ # Create the stylesheet for the boxes allowing to categorize required outputs.
34
+ boxstylesheet = \
35
+ ".QWidget {\n" \
36
+ + "border: 1px solid black;\n" \
37
+ + "border-radius: 20px;\n" \
38
+ + "}"
39
+
40
+ # I/ First box: Save presence coordinates
41
+ # I/A/ Title
42
+ self.save_presence_coordinates_label = FixedText('Save presence coordinates:', tip="Saved in the python numpy format: .npy",
43
+ night_mode=self.parent().po.all['night_mode'])
44
+ self.vlayout.addWidget(self.save_presence_coordinates_label) #
45
+
46
+ # I/B/ Create the box
47
+ self.save_presence_coordinates_layout = QtWidgets.QGridLayout()
48
+ self.save_presence_coordinates_widget = QtWidgets.QWidget()
49
+ self.save_presence_coordinates_widget.setStyleSheet(boxstylesheet)
50
+
51
+ # I/C/ Create widgets
52
+ self.save_coord_specimen = Checkbox(self.parent().po.vars['save_coord_specimen'])
53
+ # self.save_coord_specimen.stateChanged.connect(self.save_coord_specimen_saving)
54
+ self.save_coord_specimen_label = FixedText('All pixels covered by the specimen(s)', tip="",
55
+ night_mode=self.parent().po.all['night_mode'])
56
+
57
+ self.save_coord_contour = Checkbox(self.parent().po.vars['save_coord_contour'])
58
+ # self.save_coord_contour.stateChanged.connect(self.save_coord_contour_saving)
59
+ self.save_coord_contour_label = FixedText('Contours of the specimen(s)', tip="",
60
+ night_mode=self.parent().po.all['night_mode'])
61
+ self.save_coord_thickening_slimming = Checkbox(self.parent().po.vars['save_coord_thickening_slimming'])
62
+ # self.save_coord_thickening_slimming.stateChanged.connect(self.save_coord_thickening_slimming_saving)
63
+ self.save_coord_thickening_slimming_label = FixedText('Thickening and slimming areas in the specimen(s)', tip="",
64
+ night_mode=self.parent().po.all['night_mode'])
65
+ self.save_coord_network = Checkbox(self.parent().po.vars['save_coord_network'])
66
+ # self.save_coord_network.stateChanged.connect(self.save_coord_network_saving)
67
+ self.save_coord_network_label = FixedText('Tubular network in the specimen(s)', tip="",
68
+ night_mode=self.parent().po.all['night_mode'])
69
+
70
+ # I/D/ Arrange widgets in the box
71
+ self.save_presence_coordinates_layout.addWidget(self.save_coord_specimen_label, 0, 0)
72
+ self.save_presence_coordinates_layout.addWidget(self.save_coord_specimen, 0, 1)
73
+ self.save_presence_coordinates_layout.addWidget(self.save_coord_contour_label, 1, 0)
74
+ self.save_presence_coordinates_layout.addWidget(self.save_coord_contour, 1, 1)
75
+
76
+ self.save_presence_coordinates_layout.addWidget(self.save_coord_thickening_slimming_label, 0, 2)
77
+ self.save_presence_coordinates_layout.addWidget(self.save_coord_thickening_slimming, 0, 3)
78
+ self.save_presence_coordinates_layout.addWidget(self.save_coord_network_label, 1, 2)
79
+ self.save_presence_coordinates_layout.addWidget(self.save_coord_network, 1, 3)
80
+
81
+ self.save_presence_coordinates_widget.setLayout(self.save_presence_coordinates_layout)
82
+ self.vlayout.addWidget(self.save_presence_coordinates_widget)
83
+
84
+ # II/ Second box: Save descriptors
85
+ # II/A/ Title
86
+ self.save_descriptors_label = FixedText('Save descriptors:',
87
+ tip="Saved in .csv",
88
+ night_mode=self.parent().po.all['night_mode'])
89
+ self.vlayout.addWidget(self.save_descriptors_label) #
90
+
91
+ # II/B/ Create the box
92
+ self.save_descriptors_layout = QtWidgets.QGridLayout()
93
+ self.save_descriptors_widget = QtWidgets.QWidget()
94
+ self.save_descriptors_widget.setStyleSheet(boxstylesheet)
95
+
96
+ # II/C/ Create widgets
97
+
98
+ self.descriptor_widgets_list = []
99
+
100
+ # Create the table of the main output the user can select
101
+ self.create_check_boxes_table()
102
+ # II/D/ Set the layout
103
+ self.save_descriptors_widget.setLayout(self.save_descriptors_layout)
104
+ self.vlayout.addWidget(self.save_descriptors_widget)
105
+
106
+
107
+ # Create the last row layout that will contain a few more output and the ok button.
108
+ self.last_row_layout = QtWidgets.QHBoxLayout()
109
+ self.last_row_widget = QtWidgets.QWidget()
110
+
111
+ self.cancel = PButton('Cancel', night_mode=self.parent().po.all['night_mode'])
112
+ self.cancel.clicked.connect(self.cancel_is_clicked)
113
+ self.ok = PButton('Ok', night_mode=self.parent().po.all['night_mode'])
114
+ self.ok.clicked.connect(self.ok_is_clicked)
115
+ self.last_row_layout.addItem(self.horizontal_space)
116
+ self.last_row_layout.addWidget(self.cancel)
117
+ self.last_row_layout.addWidget(self.ok)
118
+
119
+ self.vlayout.addItem(horzspaceItem)
120
+ vertspaceItem = QtWidgets.QSpacerItem(1, 1, QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Maximum)
121
+
122
+ self.last_row_widget.setLayout(self.last_row_layout)
123
+ self.vlayout.addWidget(self.last_row_widget)
124
+
125
+ self.hlayout = QtWidgets.QHBoxLayout()
126
+ self.vwidget = QtWidgets.QWidget()
127
+ self.vwidget.setLayout(self.vlayout)
128
+ self.hlayout.addItem(vertspaceItem)
129
+ self.hlayout.addWidget(self.vwidget)
130
+ self.hlayout.addItem(vertspaceItem)
131
+ self.setLayout(self.hlayout)
132
+
133
+ def create_check_boxes_table(self):
134
+ """
135
+ Loop over all main outputs. An output is a variable allowing to describe the binary image
136
+ showing the presence/absence of the cell/colony at one time frame.
137
+ This function
138
+ """
139
+ descriptor_names = self.parent().po.all['descriptors']
140
+
141
+ for i, name in enumerate(descriptor_names):
142
+ label_index = i * 2
143
+ if i > 9:
144
+ row = i - 10 + 1 + 3
145
+ col = 4
146
+ else:
147
+ row = i + 1 + 3
148
+ col = 1
149
+ self.descriptor_widgets_list.append(FixedText(descriptors_names_to_display[i], 14, night_mode=self.parent().po.all['night_mode']))
150
+ self.save_descriptors_layout.addWidget(self.descriptor_widgets_list[label_index], row, col)
151
+ self.descriptor_widgets_list.append(Checkbox(self.parent().po.all['descriptors'][name]))
152
+ cb_index = label_index + 1
153
+
154
+ if name == 'fractal_analysis':# or name == 'network_analysis':
155
+ self.descriptor_widgets_list[label_index].setVisible(False)
156
+ self.descriptor_widgets_list[cb_index].setVisible(False)
157
+
158
+ self.save_descriptors_layout.addWidget(self.descriptor_widgets_list[cb_index], row, col + 1)
159
+
160
+ def cancel_is_clicked(self):
161
+ self.save_coord_specimen.setChecked(self.parent().po.vars['save_coord_specimen'])
162
+ self.save_coord_contour.setChecked(self.parent().po.vars['save_coord_contour'])
163
+ self.save_coord_thickening_slimming.setChecked(self.parent().po.vars['save_coord_thickening_slimming'])
164
+ self.save_coord_network.setChecked(self.parent().po.vars['save_coord_network'])
165
+
166
+ descriptor_names = self.parent().po.all['descriptors']
167
+ for i, name in enumerate(descriptor_names):
168
+ k = i * 2 + 1
169
+ if name == 'iso_digi_analysis':
170
+ self.descriptor_widgets_list[k].setChecked(self.parent().po.vars['iso_digi_analysis'])
171
+ elif name == 'oscilacyto_analysis':
172
+ self.descriptor_widgets_list[k].setChecked(self.parent().po.vars['oscilacyto_analysis'])
173
+ elif name == 'fractal_analysis':
174
+ self.descriptor_widgets_list[k].setChecked(self.parent().po.vars['fractal_analysis'])
175
+ elif name == 'network_analysis':
176
+ self.descriptor_widgets_list[k].setChecked(self.parent().po.vars['network_analysis'])
177
+ elif name == 'graph_extraction':
178
+ self.descriptor_widgets_list[k].setChecked(self.parent().po.vars['graph_extraction'])
179
+ else:
180
+ self.descriptor_widgets_list[k].setChecked(self.parent().po.all['descriptors'][name])
181
+
182
+ if self.parent().last_is_first:
183
+ self.parent().change_widget(0) # FirstWidget
184
+ else:
185
+ self.parent().change_widget(3) # ThirdWidget
186
+
187
+ def ok_is_clicked(self):
188
+ self.parent().po.vars['save_coord_specimen'] = self.save_coord_specimen.isChecked()
189
+ self.parent().po.vars['save_coord_contour'] = self.save_coord_contour.isChecked()
190
+ self.parent().po.vars['save_coord_thickening_slimming'] = self.save_coord_thickening_slimming.isChecked()
191
+ self.parent().po.vars['save_coord_network'] = self.save_coord_network.isChecked()
192
+ descriptor_names = self.parent().po.all['descriptors'].keys()
193
+ for i, name in enumerate(descriptor_names):
194
+ k = i * 2 + 1
195
+ checked_status = self.descriptor_widgets_list[k].isChecked()
196
+ self.parent().po.all['descriptors'][name] = checked_status
197
+ if name == 'iso_digi_analysis':
198
+ self.parent().po.vars['iso_digi_analysis'] = checked_status
199
+ if name == 'oscilacyto_analysis':
200
+ self.parent().po.vars['oscilacyto_analysis'] = checked_status
201
+ if name == 'fractal_analysis':
202
+ self.parent().po.vars['fractal_analysis'] = checked_status
203
+ if name == 'network_analysis':
204
+ self.parent().po.vars['network_analysis'] = checked_status
205
+ if name == 'graph_extraction':
206
+ self.parent().po.vars['graph_extraction'] = checked_status
207
+
208
+ # for j in [0, 1, 2]:
209
+ # k = i * 4 + j + 1
210
+ # self.parent().po.all['descriptors'][name][j] = self.descriptor_widgets_list[k].isChecked()
211
+ if not self.parent().thread['SaveAllVars'].isRunning():
212
+ self.parent().thread['SaveAllVars'].start()
213
+ self.parent().po.update_output_list()
214
+ if self.parent().last_is_first:
215
+ self.parent().change_widget(0) # FirstWidget
216
+ else:
217
+ self.parent().change_widget(3) # ThirdWidget
218
+
219
+ def closeEvent(self, event):
220
+ event.accept
221
+
222
+
223
+ # if __name__ == "__main__":
224
+ # from cellects.gui.cellects import CellectsMainWidget
225
+ # import sys
226
+ #
227
+ # app = QtWidgets.QApplication([])
228
+ # parent = CellectsMainWidget()
229
+ # session = RequiredOutput(parent, False)
230
+ # parent.insertWidget(0, session)
231
+ # parent.show()
232
+ # sys.exit(app.exec())