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.
- cellects/__init__.py +0 -0
- cellects/__main__.py +49 -0
- cellects/config/__init__.py +0 -0
- cellects/config/all_vars_dict.py +155 -0
- cellects/core/__init__.py +0 -0
- cellects/core/cellects_paths.py +31 -0
- cellects/core/cellects_threads.py +1451 -0
- cellects/core/motion_analysis.py +2010 -0
- cellects/core/one_image_analysis.py +1061 -0
- cellects/core/one_video_per_blob.py +540 -0
- cellects/core/program_organizer.py +1316 -0
- cellects/core/script_based_run.py +154 -0
- cellects/gui/__init__.py +0 -0
- cellects/gui/advanced_parameters.py +1258 -0
- cellects/gui/cellects.py +189 -0
- cellects/gui/custom_widgets.py +790 -0
- cellects/gui/first_window.py +449 -0
- cellects/gui/if_several_folders_window.py +239 -0
- cellects/gui/image_analysis_window.py +2066 -0
- cellects/gui/required_output.py +232 -0
- cellects/gui/video_analysis_window.py +656 -0
- cellects/icons/__init__.py +0 -0
- cellects/icons/cellects_icon.icns +0 -0
- cellects/icons/cellects_icon.ico +0 -0
- cellects/image_analysis/__init__.py +0 -0
- cellects/image_analysis/cell_leaving_detection.py +54 -0
- cellects/image_analysis/cluster_flux_study.py +102 -0
- cellects/image_analysis/image_segmentation.py +706 -0
- cellects/image_analysis/morphological_operations.py +1635 -0
- cellects/image_analysis/network_functions.py +1757 -0
- cellects/image_analysis/one_image_analysis_threads.py +289 -0
- cellects/image_analysis/progressively_add_distant_shapes.py +508 -0
- cellects/image_analysis/shape_descriptors.py +1016 -0
- cellects/utils/__init__.py +0 -0
- cellects/utils/decorators.py +14 -0
- cellects/utils/formulas.py +637 -0
- cellects/utils/load_display_save.py +1054 -0
- cellects/utils/utilitarian.py +490 -0
- cellects-0.1.2.dist-info/LICENSE.odt +0 -0
- cellects-0.1.2.dist-info/METADATA +132 -0
- cellects-0.1.2.dist-info/RECORD +44 -0
- cellects-0.1.2.dist-info/WHEEL +5 -0
- cellects-0.1.2.dist-info/entry_points.txt +2 -0
- cellects-0.1.2.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""ADD DETAIL OF THE MODULE"""
|
|
3
|
+
import os
|
|
4
|
+
import logging
|
|
5
|
+
from numpy import min, max, all, any, arange, repeat
|
|
6
|
+
from PySide6 import QtWidgets, QtCore
|
|
7
|
+
|
|
8
|
+
from cellects.core.cellects_threads import LoadFirstFolderIfSeveralThread
|
|
9
|
+
from cellects.gui.custom_widgets import (
|
|
10
|
+
WindowType, PButton, FixedText)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class IfSeveralFoldersWindow(WindowType):
|
|
14
|
+
def __init__(self, parent, night_mode):
|
|
15
|
+
super().__init__(parent, night_mode)
|
|
16
|
+
self.setParent(parent)
|
|
17
|
+
|
|
18
|
+
def true_init(self):
|
|
19
|
+
logging.info("Initialize IfSeveralFoldersWindow")
|
|
20
|
+
self.thread = {}
|
|
21
|
+
self.thread["LoadFirstFolderIfSeveral"] = LoadFirstFolderIfSeveralThread(self.parent())
|
|
22
|
+
self.next_clicked_once:bool = False
|
|
23
|
+
self.layout = QtWidgets.QVBoxLayout()
|
|
24
|
+
# self.layout.setAlignment(QtCore.Qt.AlignLeading)
|
|
25
|
+
# self.layout.setGeometry(QtCore.QRect(9, 9, 2 * self.parent().screen_width // 3, 2 * self.parent().screen_height // 3))
|
|
26
|
+
|
|
27
|
+
self.title_label = FixedText('Select folders to analyze', police=30, night_mode=self.parent().po.all['night_mode'])
|
|
28
|
+
self.title_label.setAlignment(QtCore.Qt.AlignHCenter)
|
|
29
|
+
# self.layout.addWidget(self.title_label, 0, 0, 1, - 1)
|
|
30
|
+
self.layout.addWidget(self.title_label)
|
|
31
|
+
self.layout.addItem(self.vertical_space)
|
|
32
|
+
|
|
33
|
+
# 1) add a check box allowing to select every folders
|
|
34
|
+
self.cb_layout = QtWidgets.QHBoxLayout()
|
|
35
|
+
self.cb_widget = QtWidgets.QWidget()
|
|
36
|
+
self.cb_label = FixedText('Check to select all folders:', tip="Otherwise, use Ctrl/Cmd to select the folders to analyze", night_mode=self.parent().po.all['night_mode'])
|
|
37
|
+
self.cb = QtWidgets.QCheckBox()
|
|
38
|
+
self.cb.setChecked(True)
|
|
39
|
+
self.cb.clicked.connect(self.checked)
|
|
40
|
+
# self.cb.stateChanged.connect(self.checked)
|
|
41
|
+
|
|
42
|
+
# self.layout.addWidget(self.cb_label, 1, 0, 1, 1)
|
|
43
|
+
# self.layout.addWidget(self.cb, 1, 1, 1, 1)
|
|
44
|
+
self.cb_layout.addWidget(self.cb_label)
|
|
45
|
+
self.cb_layout.addWidget(self.cb)
|
|
46
|
+
self.cb_layout.addItem(self.horizontal_space)
|
|
47
|
+
self.cb_widget.setLayout(self.cb_layout)
|
|
48
|
+
self.layout.addWidget(self.cb_widget)
|
|
49
|
+
# spacerItem = QtWidgets.QSpacerItem(0, 1, QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Expanding)
|
|
50
|
+
# self.layout.addItem(spacerItem, 1, 2, 1, 3)
|
|
51
|
+
|
|
52
|
+
# 2) Create a folder list and sample number per folder
|
|
53
|
+
self.tableau = QtWidgets.QTableWidget() # Scroll Area which contains the widgets, set as the centralWidget
|
|
54
|
+
self.tableau.setColumnCount(2)
|
|
55
|
+
self.tableau.setRowCount(len(self.parent().po.all['folder_list']))
|
|
56
|
+
self.tableau.setHorizontalHeaderLabels(['Folders', 'Sample size'])
|
|
57
|
+
# if len(self.parent().po.all['sample_number_per_folder']) < 2:
|
|
58
|
+
self.parent().po.all['sample_number_per_folder'] = np.repeat(int(self.parent().po.all['first_folder_sample_number']), self.parent().po.all['folder_number'])
|
|
59
|
+
|
|
60
|
+
for i, folder in enumerate(self.parent().po.all['folder_list']):
|
|
61
|
+
self.tableau.setItem(i, 0, QtWidgets.QTableWidgetItem(folder))
|
|
62
|
+
self.tableau.setItem(i, 1, QtWidgets.QTableWidgetItem(str(self.parent().po.all['sample_number_per_folder'][i])))
|
|
63
|
+
# if isinstance(self.parent().po.all['sample_number_per_folder'], int):
|
|
64
|
+
# self.tableau.setItem(i, 1, QtWidgets.QTableWidgetItem(str(self.parent().po.all['sample_number_per_folder'])))
|
|
65
|
+
# else:
|
|
66
|
+
# self.tableau.setItem(i, 1, QtWidgets.QTableWidgetItem(str(self.parent().po.all['sample_number_per_folder'][i])))
|
|
67
|
+
self.tableau.horizontalHeader().setSectionResizeMode(0, QtWidgets.QHeaderView.ResizeToContents)
|
|
68
|
+
self.tableau.horizontalHeader().setSectionResizeMode(1, QtWidgets.QHeaderView.ResizeToContents)
|
|
69
|
+
self.tableau.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
|
|
70
|
+
self.tableau.selectAll()
|
|
71
|
+
self.tableau.itemSelectionChanged.connect(self.item_selection_changed)
|
|
72
|
+
|
|
73
|
+
# self.tableau.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
|
|
74
|
+
self.tableau.setShowGrid(False)
|
|
75
|
+
self.tableau.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
|
76
|
+
self.tableau.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
|
|
77
|
+
self.tableau.horizontalHeader().hide()
|
|
78
|
+
self.tableau.verticalHeader().hide()
|
|
79
|
+
# self.layout.addWidget(self.tableau, 2, 0, 1, 1)
|
|
80
|
+
self.layout.addWidget(self.tableau)
|
|
81
|
+
|
|
82
|
+
# spaceItem = QtWidgets.QSpacerItem(1, 1, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Maximum)
|
|
83
|
+
# self.layout.addItem(spaceItem, 3, 0)
|
|
84
|
+
|
|
85
|
+
# Create the shortcuts row
|
|
86
|
+
self.shortcuts_widget = QtWidgets.QWidget()
|
|
87
|
+
self.shortcuts_layout = QtWidgets.QHBoxLayout()
|
|
88
|
+
self.Video_analysis_window = PButton("Video tracking window", night_mode=self.parent().po.all['night_mode'])
|
|
89
|
+
self.Video_analysis_window.clicked.connect(self.Video_analysis_window_is_clicked)
|
|
90
|
+
self.Run_all_directly = PButton("Run all directly", night_mode=self.parent().po.all['night_mode'])
|
|
91
|
+
self.Run_all_directly.clicked.connect(self.Run_all_directly_is_clicked)
|
|
92
|
+
self.Video_analysis_window.setVisible(False)
|
|
93
|
+
self.Run_all_directly.setVisible(False)
|
|
94
|
+
self.shortcuts_layout.addItem(self.vertical_space)
|
|
95
|
+
self.shortcuts_layout.addWidget(self.Video_analysis_window)
|
|
96
|
+
self.shortcuts_layout.addWidget(self.Run_all_directly)
|
|
97
|
+
self.shortcuts_widget.setLayout(self.shortcuts_layout)
|
|
98
|
+
self.layout.addWidget(self.shortcuts_widget)
|
|
99
|
+
|
|
100
|
+
# 3) Previous button
|
|
101
|
+
self.last_row_layout = QtWidgets.QHBoxLayout()
|
|
102
|
+
self.last_row_widget = QtWidgets.QWidget()
|
|
103
|
+
self.previous = PButton('Previous', night_mode=self.parent().po.all['night_mode'])
|
|
104
|
+
# self.layout.addWidget(self.previous, 4, 0)
|
|
105
|
+
self.previous.clicked.connect(self.previous_is_clicked)
|
|
106
|
+
|
|
107
|
+
# 4) Message
|
|
108
|
+
self.message = QtWidgets.QLabel(self)
|
|
109
|
+
self.message.setText('')
|
|
110
|
+
self.message.setStyleSheet("color: rgb(230, 145, 18)")
|
|
111
|
+
self.message.setAlignment(QtCore.Qt.AlignRight)
|
|
112
|
+
# self.layout.addWidget(self.message, 4, 1)
|
|
113
|
+
|
|
114
|
+
# 5) Next button
|
|
115
|
+
self.next = PButton('Next', night_mode=self.parent().po.all['night_mode'])
|
|
116
|
+
# self.layout.addWidget(self.next, 4, 2)
|
|
117
|
+
self.next.clicked.connect(self.next_is_clicked)
|
|
118
|
+
# self.setLayout(self.layout)
|
|
119
|
+
self.last_row_layout.addWidget(self.previous)
|
|
120
|
+
self.last_row_layout.addItem(self.horizontal_space)
|
|
121
|
+
self.last_row_layout.addWidget(self.message)
|
|
122
|
+
self.last_row_layout.addWidget(self.next)
|
|
123
|
+
self.last_row_widget.setLayout(self.last_row_layout)
|
|
124
|
+
self.layout.addItem(self.vertical_space)
|
|
125
|
+
self.layout.addWidget(self.last_row_widget)
|
|
126
|
+
self.setLayout(self.layout)
|
|
127
|
+
|
|
128
|
+
def checked(self):
|
|
129
|
+
if self.cb.isChecked():
|
|
130
|
+
self.tableau.selectAll()
|
|
131
|
+
else:
|
|
132
|
+
self.tableau.clearSelection()
|
|
133
|
+
|
|
134
|
+
def item_selection_changed(self):
|
|
135
|
+
if (len(self.tableau.selectedItems()) // 2) == len(self.parent().po.all['folder_list']):
|
|
136
|
+
self.cb.setChecked(True)
|
|
137
|
+
else:
|
|
138
|
+
self.cb.setChecked(False)
|
|
139
|
+
|
|
140
|
+
def previous_is_clicked(self):
|
|
141
|
+
self.next_clicked_once = False
|
|
142
|
+
self.parent().firstwindow.instantiate = True
|
|
143
|
+
self.parent().change_widget(0)
|
|
144
|
+
|
|
145
|
+
def next_is_clicked(self):
|
|
146
|
+
if self.next_clicked_once:
|
|
147
|
+
self.instantiates_widgets_and_do_image_analysis()
|
|
148
|
+
else:
|
|
149
|
+
self.message.setText("Loading, wait...")
|
|
150
|
+
item_number = len(self.tableau.selectedItems())
|
|
151
|
+
if item_number == 0:
|
|
152
|
+
self.message.setText("Select at least one folder")
|
|
153
|
+
else:
|
|
154
|
+
# self.tableau.selectedItems()
|
|
155
|
+
sample_number_per_folder = []
|
|
156
|
+
folder_list = []
|
|
157
|
+
# sample_number =
|
|
158
|
+
# if isinstance(self.parent().po.all['sample_number_per_folder'], int):
|
|
159
|
+
# sample_number = self.parent().po.all['sample_number_per_folder']
|
|
160
|
+
for i in np.arange(item_number):
|
|
161
|
+
if i % 2 == 0:
|
|
162
|
+
folder_list.append(self.tableau.selectedItems()[i].text())
|
|
163
|
+
else:
|
|
164
|
+
sample_number_per_folder.append(int(self.tableau.selectedItems()[i].text()))
|
|
165
|
+
self.parent().po.all['first_folder_sample_number'] = int(self.tableau.selectedItems()[1].text())
|
|
166
|
+
|
|
167
|
+
#
|
|
168
|
+
# for index in self.tableau.selectionModel().selectedRows():
|
|
169
|
+
# folder_list.append(self.parent().po.all['folder_list'][index.row()])
|
|
170
|
+
# # if not isinstance(self.parent().po.all['sample_number_per_folder'], int):
|
|
171
|
+
# sample_number = self.parent().po.all['sample_number_per_folder'][index.row()]
|
|
172
|
+
# sample_number_per_folder.append(sample_number)
|
|
173
|
+
|
|
174
|
+
self.parent().po.all['folder_list'] = folder_list
|
|
175
|
+
self.parent().po.all['sample_number_per_folder'] = sample_number_per_folder
|
|
176
|
+
self.parent().po.update_folder_id(self.parent().po.all['first_folder_sample_number'],
|
|
177
|
+
self.parent().po.all['folder_list'][0])
|
|
178
|
+
print(os.getcwd())
|
|
179
|
+
# if not isinstance(self.parent().po.all['sample_number_per_folder'], int):
|
|
180
|
+
# self.parent().po.update_folder_id(self.parent().po.all['sample_number_per_folder'][0], self.parent().po.all['folder_list'][0])
|
|
181
|
+
# else:
|
|
182
|
+
# self.parent().po.update_folder_id(self.parent().po.all['sample_number_per_folder'], self.parent().po.all['folder_list'][0])
|
|
183
|
+
|
|
184
|
+
# if self.parent.subwidgets_stack.count() == 5:
|
|
185
|
+
# self.parent.instantiate_widget(ImageAnalysisWindow(self.parent))
|
|
186
|
+
# if not self.parent().imageanalysiswindow.initialized:
|
|
187
|
+
|
|
188
|
+
self.thread["LoadFirstFolderIfSeveral"].start()
|
|
189
|
+
self.thread["LoadFirstFolderIfSeveral"].message_when_thread_finished.connect(self.first_folder_loaded)
|
|
190
|
+
|
|
191
|
+
def first_folder_loaded(self, first_exp_ready_to_run):
|
|
192
|
+
if first_exp_ready_to_run:
|
|
193
|
+
self.cb_widget.setVisible(False)
|
|
194
|
+
self.tableau.setVisible(False)
|
|
195
|
+
if len(self.parent().po.vars['analyzed_individuals']) != self.parent().po.all['first_folder_sample_number']:
|
|
196
|
+
self.parent().po.vars['analyzed_individuals'] = np.arange(
|
|
197
|
+
self.parent().po.all['first_folder_sample_number']) + 1
|
|
198
|
+
self.parent().po.sample_number = self.parent().po.all['first_folder_sample_number']
|
|
199
|
+
self.message.setText("Data found, shortcuts are available. Click Next again to redo/improve the image analysis")
|
|
200
|
+
self.next_clicked_once = True
|
|
201
|
+
self.Video_analysis_window.setVisible(True)
|
|
202
|
+
self.Run_all_directly.setVisible(True)
|
|
203
|
+
self.parent().firstwindow.Video_analysis_window.setVisible(True)
|
|
204
|
+
self.parent().firstwindow.Run_all_directly.setVisible(True)
|
|
205
|
+
else:
|
|
206
|
+
self.instantiates_widgets_and_do_image_analysis()
|
|
207
|
+
|
|
208
|
+
def instantiates_widgets_and_do_image_analysis(self):
|
|
209
|
+
print(os.getcwd())
|
|
210
|
+
self.parent().instantiate_widgets(severalfolder_included=False)
|
|
211
|
+
self.parent().imageanalysiswindow.true_init()
|
|
212
|
+
self.parent().firstwindow.instantiate = False
|
|
213
|
+
print(os.getcwd())
|
|
214
|
+
self.parent().change_widget(2)# ImageAnalysisWindow
|
|
215
|
+
# self.parent().change_widget(3) # VideoAnalysisWindow
|
|
216
|
+
|
|
217
|
+
def Video_analysis_window_is_clicked(self):
|
|
218
|
+
self.parent().last_tab = "data_specifications"
|
|
219
|
+
# self.parent().po.update_folder_id(self.parent().po.all['sample_number_per_folder'][0],
|
|
220
|
+
# self.parent().po.all['folder_list'][0])
|
|
221
|
+
self.parent().change_widget(3)
|
|
222
|
+
|
|
223
|
+
def Run_all_directly_is_clicked(self):
|
|
224
|
+
self.parent().firstwindow.Run_all_directly_is_clicked()
|
|
225
|
+
self.previous_is_clicked()
|
|
226
|
+
|
|
227
|
+
def closeEvent(self, event):
|
|
228
|
+
event.accept
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
# if __name__ == "__main__":
|
|
232
|
+
# from cellects.gui.cellects import CellectsMainWidget
|
|
233
|
+
# import sys
|
|
234
|
+
# app = QtWidgets.QApplication([])
|
|
235
|
+
# parent = CellectsMainWidget()
|
|
236
|
+
# session = IfSeveralFoldersWindow(parent, False)
|
|
237
|
+
# parent.insertWidget(0, session)
|
|
238
|
+
# parent.show()
|
|
239
|
+
# sys.exit(app.exec())
|