celldetective 1.3.7.post1__py3-none-any.whl → 1.3.8__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/_version.py +1 -1
- celldetective/gui/btrack_options.py +8 -8
- celldetective/gui/classifier_widget.py +8 -0
- celldetective/gui/configure_new_exp.py +1 -1
- celldetective/gui/json_readers.py +2 -4
- celldetective/gui/plot_signals_ui.py +38 -29
- celldetective/gui/process_block.py +1 -0
- celldetective/gui/processes/downloader.py +108 -0
- celldetective/gui/processes/measure_cells.py +346 -0
- celldetective/gui/processes/segment_cells.py +354 -0
- celldetective/gui/processes/track_cells.py +298 -0
- celldetective/gui/processes/train_segmentation_model.py +270 -0
- celldetective/gui/processes/train_signal_model.py +108 -0
- celldetective/gui/seg_model_loader.py +71 -25
- celldetective/gui/signal_annotator2.py +10 -7
- celldetective/gui/signal_annotator_options.py +1 -1
- celldetective/gui/tableUI.py +252 -20
- celldetective/gui/viewers.py +1 -1
- celldetective/io.py +53 -20
- celldetective/measure.py +12 -144
- celldetective/relative_measurements.py +40 -43
- celldetective/segmentation.py +48 -1
- celldetective/signals.py +84 -305
- celldetective/tracking.py +23 -24
- celldetective/utils.py +1 -1
- {celldetective-1.3.7.post1.dist-info → celldetective-1.3.8.dist-info}/METADATA +11 -2
- {celldetective-1.3.7.post1.dist-info → celldetective-1.3.8.dist-info}/RECORD +31 -25
- {celldetective-1.3.7.post1.dist-info → celldetective-1.3.8.dist-info}/WHEEL +1 -1
- {celldetective-1.3.7.post1.dist-info → celldetective-1.3.8.dist-info}/LICENSE +0 -0
- {celldetective-1.3.7.post1.dist-info → celldetective-1.3.8.dist-info}/entry_points.txt +0 -0
- {celldetective-1.3.7.post1.dist-info → celldetective-1.3.8.dist-info}/top_level.txt +0 -0
celldetective/_version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "1.3.
|
|
1
|
+
__version__ = "1.3.8"
|
|
@@ -379,15 +379,15 @@ class ConfigTracking(QMainWindow, Styles):
|
|
|
379
379
|
clean_traj_sublayout.addWidget(self.extrapolate_post_checkbox)
|
|
380
380
|
clean_traj_sublayout.addWidget(self.extrapolate_pre_checkbox)
|
|
381
381
|
|
|
382
|
-
self.interpolate_na_features_checkbox = QCheckBox('Interpolate features of missed detections')
|
|
383
|
-
self.interpolate_na_features_checkbox.setIcon(icon(MDI6.format_color_fill,color="k"))
|
|
382
|
+
# self.interpolate_na_features_checkbox = QCheckBox('Interpolate features of missed detections')
|
|
383
|
+
# self.interpolate_na_features_checkbox.setIcon(icon(MDI6.format_color_fill,color="k"))
|
|
384
384
|
|
|
385
|
-
clean_traj_sublayout.addWidget(self.interpolate_na_features_checkbox)
|
|
385
|
+
# clean_traj_sublayout.addWidget(self.interpolate_na_features_checkbox)
|
|
386
386
|
clean_traj_sublayout.addStretch()
|
|
387
387
|
|
|
388
388
|
self.post_proc_options_to_disable = [self.post_proc_lbl, self.min_tracklength_slider, self.remove_not_in_first_checkbox,
|
|
389
389
|
self.remove_not_in_last_checkbox, self.interpolate_gaps_checkbox, self.extrapolate_post_checkbox,
|
|
390
|
-
self.extrapolate_pre_checkbox
|
|
390
|
+
self.extrapolate_pre_checkbox] #, self.interpolate_na_features_checkbox
|
|
391
391
|
|
|
392
392
|
layout.addLayout(clean_traj_sublayout)
|
|
393
393
|
|
|
@@ -898,7 +898,7 @@ class ConfigTracking(QMainWindow, Styles):
|
|
|
898
898
|
"interpolate_position_gaps": self.interpolate_gaps_checkbox.isChecked(),
|
|
899
899
|
"extrapolate_tracks_pre": self.extrapolate_pre_checkbox.isChecked(),
|
|
900
900
|
"extrapolate_tracks_post": self.extrapolate_post_checkbox.isChecked(),
|
|
901
|
-
'interpolate_na': self.interpolate_na_features_checkbox.isChecked()
|
|
901
|
+
'interpolate_na': False, #self.interpolate_na_features_checkbox.isChecked()
|
|
902
902
|
}
|
|
903
903
|
else:
|
|
904
904
|
|
|
@@ -1044,7 +1044,7 @@ class ConfigTracking(QMainWindow, Styles):
|
|
|
1044
1044
|
self.uncheck_post_proc()
|
|
1045
1045
|
self.ContentsPostProc.hide()
|
|
1046
1046
|
for element in [self.remove_not_in_last_checkbox, self.remove_not_in_first_checkbox, self.interpolate_gaps_checkbox,
|
|
1047
|
-
self.extrapolate_post_checkbox, self.extrapolate_pre_checkbox
|
|
1047
|
+
self.extrapolate_post_checkbox, self.extrapolate_pre_checkbox]: #self.interpolate_na_features_checkbox
|
|
1048
1048
|
element.setChecked(False)
|
|
1049
1049
|
self.min_tracklength_slider.setValue(0)
|
|
1050
1050
|
|
|
@@ -1063,8 +1063,8 @@ class ConfigTracking(QMainWindow, Styles):
|
|
|
1063
1063
|
self.extrapolate_pre_checkbox.setChecked(post_processing_options["extrapolate_tracks_pre"])
|
|
1064
1064
|
if "extrapolate_tracks_post" in post_processing_options:
|
|
1065
1065
|
self.extrapolate_post_checkbox.setChecked(post_processing_options["extrapolate_tracks_post"])
|
|
1066
|
-
if "interpolate_na" in post_processing_options:
|
|
1067
|
-
|
|
1066
|
+
# if "interpolate_na" in post_processing_options:
|
|
1067
|
+
# self.interpolate_na_features_checkbox.setChecked(post_processing_options["interpolate_na"])
|
|
1068
1068
|
|
|
1069
1069
|
def locate_image(self):
|
|
1070
1070
|
|
|
@@ -212,6 +212,8 @@ class ClassifierWidget(QWidget, Styles):
|
|
|
212
212
|
self.frame_slider.valueChanged.connect(self.set_frame)
|
|
213
213
|
self.alpha_slider.valueChanged.connect(self.set_transparency)
|
|
214
214
|
|
|
215
|
+
self.setAttribute(Qt.WA_DeleteOnClose)
|
|
216
|
+
|
|
215
217
|
def activate_prereq_cb(self):
|
|
216
218
|
if self.prereq_event_check.isChecked():
|
|
217
219
|
self.prereq_event_cb.setEnabled(True)
|
|
@@ -276,6 +278,12 @@ class ClassifierWidget(QWidget, Styles):
|
|
|
276
278
|
self.propscanvas.canvas.draw_idle()
|
|
277
279
|
self.propscanvas.canvas.setMinimumHeight(self.screen_height//5)
|
|
278
280
|
|
|
281
|
+
def closeEvent(self, event):
|
|
282
|
+
self.ax_props.cla()
|
|
283
|
+
self.fig_props.clf()
|
|
284
|
+
plt.close(self.fig_props)
|
|
285
|
+
super().closeEvent(event)
|
|
286
|
+
|
|
279
287
|
def update_props_scatter(self, feature_changed=True):
|
|
280
288
|
|
|
281
289
|
try:
|
|
@@ -429,7 +429,7 @@ class ConfigNewExperiment(QMainWindow, Styles):
|
|
|
429
429
|
Write all user input parameters to a configuration file associated to an experiment.
|
|
430
430
|
"""
|
|
431
431
|
|
|
432
|
-
config = ConfigParser()
|
|
432
|
+
config = ConfigParser(interpolation=None)
|
|
433
433
|
|
|
434
434
|
# add a new section and some values
|
|
435
435
|
config.add_section('MovieSettings')
|
|
@@ -49,7 +49,7 @@ class ConfigEditor(QWidget, Styles):
|
|
|
49
49
|
file_name = self.config_path
|
|
50
50
|
#self.file_edit.setText(file_name)
|
|
51
51
|
|
|
52
|
-
config = configparser.ConfigParser()
|
|
52
|
+
config = configparser.ConfigParser(interpolation=None)
|
|
53
53
|
config.read(file_name)
|
|
54
54
|
|
|
55
55
|
# Create a layout for each section of the config file
|
|
@@ -93,12 +93,10 @@ class ConfigEditor(QWidget, Styles):
|
|
|
93
93
|
# Save the configuration to the file
|
|
94
94
|
file_name = self.config_path
|
|
95
95
|
|
|
96
|
-
config = configparser.ConfigParser()
|
|
96
|
+
config = configparser.ConfigParser(interpolation=None)
|
|
97
97
|
|
|
98
98
|
# Update the values in the config object
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
|
|
102
100
|
for key, (section, edit_box) in self.sections.items():
|
|
103
101
|
if not config.has_section(section):
|
|
104
102
|
config.add_section(section)
|
|
@@ -117,7 +117,10 @@ class ConfigSignalPlot(QWidget, Styles):
|
|
|
117
117
|
all_cms = list(colormaps)
|
|
118
118
|
for cm in all_cms:
|
|
119
119
|
if hasattr(matplotlib.cm, str(cm).lower()):
|
|
120
|
-
|
|
120
|
+
try:
|
|
121
|
+
self.cbs[-1].addColormap(cm.lower())
|
|
122
|
+
except:
|
|
123
|
+
pass
|
|
121
124
|
|
|
122
125
|
self.cbs[0].setCurrentIndex(1)
|
|
123
126
|
self.cbs[0].setCurrentIndex(0)
|
|
@@ -138,13 +141,14 @@ class ConfigSignalPlot(QWidget, Styles):
|
|
|
138
141
|
self.abs_time_checkbox.stateChanged.connect(self.switch_ref_time_mode)
|
|
139
142
|
|
|
140
143
|
select_layout = QHBoxLayout()
|
|
144
|
+
select_layout.setContentsMargins(20,3,20,3)
|
|
141
145
|
select_layout.addWidget(QLabel('select cells\nwith query: '), 33)
|
|
142
146
|
self.query_le = QLineEdit()
|
|
143
147
|
select_layout.addWidget(self.query_le, 66)
|
|
144
148
|
main_layout.addLayout(select_layout)
|
|
145
149
|
|
|
146
150
|
time_calib_layout = QHBoxLayout()
|
|
147
|
-
time_calib_layout.setContentsMargins(20,
|
|
151
|
+
time_calib_layout.setContentsMargins(20,3,20,3)
|
|
148
152
|
time_calib_layout.addWidget(QLabel('time calibration\n(frame to min)'), 33)
|
|
149
153
|
self.time_calibration_le = QLineEdit(str(self.FrameToMin).replace('.',','))
|
|
150
154
|
self.time_calibration_le.setValidator(self.float_validator)
|
|
@@ -152,6 +156,14 @@ class ConfigSignalPlot(QWidget, Styles):
|
|
|
152
156
|
#time_calib_layout.addWidget(QLabel(' min'))
|
|
153
157
|
main_layout.addLayout(time_calib_layout)
|
|
154
158
|
|
|
159
|
+
pool_layout = QHBoxLayout()
|
|
160
|
+
pool_layout.setContentsMargins(20,3,20,3)
|
|
161
|
+
self.pool_option_cb = QComboBox()
|
|
162
|
+
self.pool_option_cb.addItems(['mean','median'])
|
|
163
|
+
pool_layout.addWidget(QLabel('pool\nprojection:'), 33)
|
|
164
|
+
pool_layout.addWidget(self.pool_option_cb, 66)
|
|
165
|
+
main_layout.addLayout(pool_layout)
|
|
166
|
+
|
|
155
167
|
self.submit_btn = QPushButton('Submit')
|
|
156
168
|
self.submit_btn.setStyleSheet(self.button_style_sheet)
|
|
157
169
|
self.submit_btn.clicked.connect(self.process_signal)
|
|
@@ -271,9 +283,10 @@ class ConfigSignalPlot(QWidget, Styles):
|
|
|
271
283
|
self.feature_selected = self.feature_cb.currentText()
|
|
272
284
|
self.feature_choice_widget.close()
|
|
273
285
|
self.compute_signal_functions()
|
|
274
|
-
self.
|
|
275
|
-
|
|
276
|
-
|
|
286
|
+
if self.open_widget:
|
|
287
|
+
self.interpret_pos_location()
|
|
288
|
+
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')
|
|
289
|
+
self.plot_window.show()
|
|
277
290
|
|
|
278
291
|
def process_signal(self):
|
|
279
292
|
|
|
@@ -335,7 +348,19 @@ class ConfigSignalPlot(QWidget, Styles):
|
|
|
335
348
|
|
|
336
349
|
def compute_signal_functions(self):
|
|
337
350
|
|
|
338
|
-
#
|
|
351
|
+
# Check to move at the beginning
|
|
352
|
+
self.open_widget = True
|
|
353
|
+
if len(self.time_columns)==0:
|
|
354
|
+
msgBox = QMessageBox()
|
|
355
|
+
msgBox.setIcon(QMessageBox.Warning)
|
|
356
|
+
msgBox.setText("No synchronizing time is available...")
|
|
357
|
+
msgBox.setWindowTitle("Warning")
|
|
358
|
+
msgBox.setStandardButtons(QMessageBox.Ok)
|
|
359
|
+
returnValue = msgBox.exec()
|
|
360
|
+
if returnValue == QMessageBox.Ok:
|
|
361
|
+
pass
|
|
362
|
+
self.open_widget = False
|
|
363
|
+
return None
|
|
339
364
|
|
|
340
365
|
# Per position signal
|
|
341
366
|
max_time = int(self.df.FRAME.max()) + 1
|
|
@@ -346,9 +371,9 @@ class ConfigSignalPlot(QWidget, Styles):
|
|
|
346
371
|
|
|
347
372
|
for block,movie_group in self.df.groupby(['well','position']):
|
|
348
373
|
|
|
349
|
-
well_signal_mean, well_std_mean, timeline_all, matrix_all = mean_signal(movie_group, self.feature_selected, class_col, time_col=time_col, class_value=None, return_matrix=True, forced_max_duration=max_time)
|
|
350
|
-
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)
|
|
351
|
-
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)
|
|
374
|
+
well_signal_mean, well_std_mean, timeline_all, matrix_all = mean_signal(movie_group, self.feature_selected, class_col, time_col=time_col, class_value=None, return_matrix=True, forced_max_duration=max_time, projection=self.pool_option_cb.currentText())
|
|
375
|
+
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, projection=self.pool_option_cb.currentText())
|
|
376
|
+
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, projection=self.pool_option_cb.currentText())
|
|
352
377
|
self.mean_plots_timeline = timeline_all
|
|
353
378
|
|
|
354
379
|
self.df_pos_info.loc[self.df_pos_info['pos_path'] == block[1], 'signal'] = [
|
|
@@ -361,9 +386,9 @@ class ConfigSignalPlot(QWidget, Styles):
|
|
|
361
386
|
# Per well
|
|
362
387
|
for well,well_group in self.df.groupby('well'):
|
|
363
388
|
|
|
364
|
-
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=None, return_matrix=True, forced_max_duration=max_time)
|
|
365
|
-
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)
|
|
366
|
-
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)
|
|
389
|
+
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=None, return_matrix=True, forced_max_duration=max_time, projection=self.pool_option_cb.currentText())
|
|
390
|
+
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, projection=self.pool_option_cb.currentText())
|
|
391
|
+
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, projection=self.pool_option_cb.currentText())
|
|
367
392
|
|
|
368
393
|
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,
|
|
369
394
|
'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}]
|
|
@@ -418,23 +443,7 @@ class ConfigSignalPlot(QWidget, Styles):
|
|
|
418
443
|
cid+=1
|
|
419
444
|
except:
|
|
420
445
|
pass
|
|
421
|
-
return matrix
|
|
422
|
-
|
|
423
|
-
def col_mean(self, matrix):
|
|
424
|
-
|
|
425
|
-
mean_line = np.zeros(matrix.shape[1])
|
|
426
|
-
mean_line[:] = np.nan
|
|
427
|
-
std_line = np.copy(mean_line)
|
|
428
|
-
|
|
429
|
-
for k in range(matrix.shape[1]):
|
|
430
|
-
values = matrix[:,k]
|
|
431
|
-
#values = values[values!=0]
|
|
432
|
-
if len(values[values==values])>2:
|
|
433
|
-
mean_line[k] = np.nanmean(values)
|
|
434
|
-
std_line[k] = np.nanstd(values)
|
|
435
|
-
|
|
436
|
-
return mean_line, std_line
|
|
437
|
-
|
|
446
|
+
return matrix
|
|
438
447
|
|
|
439
448
|
def switch_ref_time_mode(self):
|
|
440
449
|
if self.abs_time_checkbox.isChecked():
|
|
@@ -1362,6 +1362,7 @@ class NeighPanel(QFrame, Styles):
|
|
|
1362
1362
|
self.pair_signal_models_list.addItems(signal_models)
|
|
1363
1363
|
|
|
1364
1364
|
def open_signal_annotator_configuration_ui(self):
|
|
1365
|
+
self.mode = 'pairs'
|
|
1365
1366
|
self.ConfigSignalAnnotator = ConfigSignalAnnotator(self)
|
|
1366
1367
|
self.ConfigSignalAnnotator.show()
|
|
1367
1368
|
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import ssl
|
|
3
|
+
from tqdm import tqdm
|
|
4
|
+
from multiprocessing import Process
|
|
5
|
+
from glob import glob
|
|
6
|
+
import shutil
|
|
7
|
+
from urllib.request import urlopen
|
|
8
|
+
import zipfile
|
|
9
|
+
import tempfile
|
|
10
|
+
import time
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
import json
|
|
13
|
+
|
|
14
|
+
class DownloadProcess(Process):
|
|
15
|
+
|
|
16
|
+
def __init__(self, queue=None, process_args=None, *args, **kwargs):
|
|
17
|
+
|
|
18
|
+
super().__init__(*args, **kwargs)
|
|
19
|
+
|
|
20
|
+
if process_args is not None:
|
|
21
|
+
for key, value in process_args.items():
|
|
22
|
+
setattr(self, key, value)
|
|
23
|
+
|
|
24
|
+
self.queue = queue
|
|
25
|
+
self.progress = True
|
|
26
|
+
|
|
27
|
+
file_path = Path(os.path.dirname(os.path.realpath(__file__)))
|
|
28
|
+
zenodo_json = os.sep.join([str(file_path.parents[2]),"celldetective", "links", "zenodo.json"])
|
|
29
|
+
print(f"{zenodo_json=}")
|
|
30
|
+
|
|
31
|
+
with open(zenodo_json,"r") as f:
|
|
32
|
+
zenodo_json = json.load(f)
|
|
33
|
+
all_files = list(zenodo_json['files']['entries'].keys())
|
|
34
|
+
all_files_short = [f.replace(".zip","") for f in all_files]
|
|
35
|
+
zenodo_url = zenodo_json['links']['files'].replace('api/','')
|
|
36
|
+
full_links = ["/".join([zenodo_url, f]) for f in all_files]
|
|
37
|
+
index = all_files_short.index(self.file)
|
|
38
|
+
|
|
39
|
+
self.zip_url = full_links[index]
|
|
40
|
+
self.path_to_zip_file = os.sep.join([self.output_dir, 'temp.zip'])
|
|
41
|
+
|
|
42
|
+
self.sum_done = 0
|
|
43
|
+
self.t0 = time.time()
|
|
44
|
+
|
|
45
|
+
def download_url_to_file(self, url, dst):
|
|
46
|
+
|
|
47
|
+
file_size = None
|
|
48
|
+
ssl._create_default_https_context = ssl._create_unverified_context
|
|
49
|
+
u = urlopen(url)
|
|
50
|
+
meta = u.info()
|
|
51
|
+
if hasattr(meta, 'getheaders'):
|
|
52
|
+
content_length = meta.getheaders("Content-Length")
|
|
53
|
+
else:
|
|
54
|
+
content_length = meta.get_all("Content-Length")
|
|
55
|
+
if content_length is not None and len(content_length) > 0:
|
|
56
|
+
file_size = int(content_length[0])
|
|
57
|
+
# We deliberately save it in a temp file and move it after
|
|
58
|
+
dst = os.path.expanduser(dst)
|
|
59
|
+
dst_dir = os.path.dirname(dst)
|
|
60
|
+
f = tempfile.NamedTemporaryFile(delete=False, dir=dst_dir)
|
|
61
|
+
|
|
62
|
+
try:
|
|
63
|
+
with tqdm(total=file_size, disable=not self.progress,
|
|
64
|
+
unit='B', unit_scale=True, unit_divisor=1024) as pbar:
|
|
65
|
+
while True:
|
|
66
|
+
buffer = u.read(8192) #8192
|
|
67
|
+
if len(buffer) == 0:
|
|
68
|
+
break
|
|
69
|
+
f.write(buffer)
|
|
70
|
+
pbar.update(len(buffer))
|
|
71
|
+
self.sum_done+=len(buffer) / file_size * 100
|
|
72
|
+
mean_exec_per_step = (time.time() - self.t0) / (self.sum_done*file_size / 100 + 1)
|
|
73
|
+
pred_time = (file_size - (self.sum_done*file_size / 100 + 1)) * mean_exec_per_step
|
|
74
|
+
self.queue.put([self.sum_done, pred_time])
|
|
75
|
+
f.close()
|
|
76
|
+
shutil.move(f.name, dst)
|
|
77
|
+
finally:
|
|
78
|
+
f.close()
|
|
79
|
+
if os.path.exists(f.name):
|
|
80
|
+
os.remove(f.name)
|
|
81
|
+
|
|
82
|
+
def run(self):
|
|
83
|
+
|
|
84
|
+
self.download_url_to_file(fr"{self.zip_url}",self.path_to_zip_file)
|
|
85
|
+
with zipfile.ZipFile(self.path_to_zip_file, 'r') as zip_ref:
|
|
86
|
+
zip_ref.extractall(self.output_dir)
|
|
87
|
+
|
|
88
|
+
file_to_rename = glob(os.sep.join([self.output_dir,self.file,"*[!.json][!.png][!.h5][!.csv][!.npy][!.tif][!.ini]"]))
|
|
89
|
+
if len(file_to_rename)>0 and not file_to_rename[0].endswith(os.sep) and not self.file.startswith('demo'):
|
|
90
|
+
os.rename(file_to_rename[0], os.sep.join([self.output_dir,self.file,self.file]))
|
|
91
|
+
|
|
92
|
+
os.remove(self.path_to_zip_file)
|
|
93
|
+
self.queue.put([100,0])
|
|
94
|
+
time.sleep(0.5)
|
|
95
|
+
|
|
96
|
+
# Send end signal
|
|
97
|
+
self.queue.put("finished")
|
|
98
|
+
self.queue.close()
|
|
99
|
+
|
|
100
|
+
def end_process(self):
|
|
101
|
+
|
|
102
|
+
self.terminate()
|
|
103
|
+
self.queue.put("finished")
|
|
104
|
+
|
|
105
|
+
def abort_process(self):
|
|
106
|
+
|
|
107
|
+
self.terminate()
|
|
108
|
+
self.queue.put("error")
|