celldetective 1.4.0__py3-none-any.whl → 1.4.1__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/exceptions.py +11 -0
- celldetective/filters.py +7 -1
- celldetective/gui/InitWindow.py +4 -1
- celldetective/gui/__init__.py +2 -9
- celldetective/gui/about.py +2 -2
- celldetective/gui/base_annotator.py +786 -0
- celldetective/gui/classifier_widget.py +18 -13
- celldetective/gui/configure_new_exp.py +51 -30
- celldetective/gui/control_panel.py +10 -7
- celldetective/gui/{signal_annotator.py → event_annotator.py} +473 -1437
- celldetective/gui/generic_signal_plot.py +2 -1
- celldetective/gui/gui_utils.py +5 -2
- celldetective/gui/help/neighborhood.json +2 -2
- celldetective/gui/layouts.py +21 -11
- celldetective/gui/{signal_annotator2.py → pair_event_annotator.py} +3 -1
- celldetective/gui/process_block.py +129 -91
- celldetective/gui/processes/downloader.py +37 -34
- celldetective/gui/processes/measure_cells.py +14 -8
- celldetective/gui/processes/segment_cells.py +21 -6
- celldetective/gui/processes/track_cells.py +12 -13
- celldetective/gui/settings/__init__.py +7 -0
- celldetective/gui/settings/_settings_base.py +70 -0
- celldetective/gui/{retrain_signal_model_options.py → settings/_settings_event_model_training.py} +35 -91
- celldetective/gui/{measurement_options.py → settings/_settings_measurements.py} +28 -81
- celldetective/gui/{neighborhood_options.py → settings/_settings_neighborhood.py} +1 -1
- celldetective/gui/settings/_settings_segmentation.py +49 -0
- celldetective/gui/{retrain_segmentation_model_options.py → settings/_settings_segmentation_model_training.py} +33 -79
- celldetective/gui/{signal_annotator_options.py → settings/_settings_signal_annotator.py} +73 -95
- celldetective/gui/{btrack_options.py → settings/_settings_tracking.py} +64 -87
- celldetective/gui/styles.py +2 -1
- celldetective/gui/survival_ui.py +1 -1
- celldetective/gui/tableUI.py +25 -0
- celldetective/gui/table_ops/__init__.py +0 -0
- celldetective/gui/table_ops/merge_groups.py +118 -0
- celldetective/gui/viewers.py +3 -5
- celldetective/gui/workers.py +0 -2
- celldetective/io.py +98 -55
- celldetective/links/zenodo.json +145 -144
- celldetective/measure.py +31 -26
- celldetective/preprocessing.py +34 -21
- celldetective/regionprops/_regionprops.py +16 -5
- celldetective/scripts/measure_cells.py +5 -5
- celldetective/scripts/measure_relative.py +16 -11
- celldetective/scripts/segment_cells.py +4 -4
- celldetective/scripts/segment_cells_thresholds.py +3 -3
- celldetective/scripts/track_cells.py +7 -7
- celldetective/scripts/train_segmentation_model.py +10 -1
- celldetective/tracking.py +10 -4
- celldetective/utils.py +59 -58
- {celldetective-1.4.0.dist-info → celldetective-1.4.1.dist-info}/METADATA +1 -1
- celldetective-1.4.1.dist-info/RECORD +123 -0
- tests/gui/__init__.py +0 -0
- tests/gui/test_new_project.py +228 -0
- tests/{test_qt.py → gui/test_project.py} +22 -26
- tests/test_preprocessing.py +2 -2
- celldetective/models/segmentation_effectors/ricm_bf_all_last/config_input.json +0 -79
- celldetective/models/segmentation_effectors/ricm_bf_all_last/ricm_bf_all_last +0 -0
- celldetective/models/segmentation_effectors/ricm_bf_all_last/training_instructions.json +0 -37
- celldetective/models/segmentation_effectors/test-transfer/config_input.json +0 -39
- celldetective/models/segmentation_effectors/test-transfer/test-transfer +0 -0
- celldetective/models/signal_detection/NucCond/classification_loss.png +0 -0
- celldetective/models/signal_detection/NucCond/classifier.h5 +0 -0
- celldetective/models/signal_detection/NucCond/config_input.json +0 -1
- celldetective/models/signal_detection/NucCond/log_classifier.csv +0 -126
- celldetective/models/signal_detection/NucCond/log_regressor.csv +0 -282
- celldetective/models/signal_detection/NucCond/regression_loss.png +0 -0
- celldetective/models/signal_detection/NucCond/regressor.h5 +0 -0
- celldetective/models/signal_detection/NucCond/scores.npy +0 -0
- celldetective/models/signal_detection/NucCond/test_confusion_matrix.png +0 -0
- celldetective/models/signal_detection/NucCond/test_regression.png +0 -0
- celldetective/models/signal_detection/NucCond/validation_confusion_matrix.png +0 -0
- celldetective/models/signal_detection/NucCond/validation_regression.png +0 -0
- celldetective-1.4.0.dist-info/RECORD +0 -131
- {celldetective-1.4.0.dist-info → celldetective-1.4.1.dist-info}/WHEEL +0 -0
- {celldetective-1.4.0.dist-info → celldetective-1.4.1.dist-info}/entry_points.txt +0 -0
- {celldetective-1.4.0.dist-info → celldetective-1.4.1.dist-info}/licenses/LICENSE +0 -0
- {celldetective-1.4.0.dist-info → celldetective-1.4.1.dist-info}/top_level.txt +0 -0
|
@@ -6,7 +6,7 @@ import json
|
|
|
6
6
|
from pathlib import Path, PurePath
|
|
7
7
|
|
|
8
8
|
from celldetective.io import auto_load_number_of_frames, load_frames, locate_labels
|
|
9
|
-
from celldetective.utils import extract_experiment_channels,
|
|
9
|
+
from celldetective.utils import extract_experiment_channels, config_section_to_dict, _get_img_num_per_channel
|
|
10
10
|
from celldetective.utils import remove_trajectory_measurements, _extract_coordinates_from_features, _remove_invalid_cols
|
|
11
11
|
from celldetective.measure import drop_tonal_features, measure_features, measure_isotropic_intensity, measure_radial_distance_to_center, center_of_mass_to_abs_coordinates
|
|
12
12
|
|
|
@@ -17,9 +17,14 @@ import concurrent.futures
|
|
|
17
17
|
import pandas as pd
|
|
18
18
|
from natsort import natsorted
|
|
19
19
|
from art import tprint
|
|
20
|
+
from typing import Optional, Union
|
|
20
21
|
|
|
21
22
|
|
|
22
23
|
class MeasurementProcess(Process):
|
|
24
|
+
|
|
25
|
+
pos: Optional[Union[str,Path]] = None
|
|
26
|
+
mode: Optional[str] = None
|
|
27
|
+
n_threads: int = 1
|
|
23
28
|
|
|
24
29
|
def __init__(self, queue=None, process_args=None):
|
|
25
30
|
|
|
@@ -173,12 +178,12 @@ class MeasurementProcess(Process):
|
|
|
173
178
|
|
|
174
179
|
def extract_experiment_parameters(self):
|
|
175
180
|
|
|
176
|
-
self.movie_prefix =
|
|
177
|
-
self.spatial_calibration = float(
|
|
178
|
-
self.time_calibration = float(
|
|
179
|
-
self.len_movie = float(
|
|
180
|
-
self.shape_x = int(
|
|
181
|
-
self.shape_y = int(
|
|
181
|
+
self.movie_prefix = config_section_to_dict(self.config, "MovieSettings")["movie_prefix"]
|
|
182
|
+
self.spatial_calibration = float(config_section_to_dict(self.config, "MovieSettings")["pxtoum"])
|
|
183
|
+
self.time_calibration = float(config_section_to_dict(self.config, "MovieSettings")["frametomin"])
|
|
184
|
+
self.len_movie = float(config_section_to_dict(self.config, "MovieSettings")["len_movie"])
|
|
185
|
+
self.shape_x = int(config_section_to_dict(self.config, "MovieSettings")["shape_x"])
|
|
186
|
+
self.shape_y = int(config_section_to_dict(self.config, "MovieSettings")["shape_y"])
|
|
182
187
|
|
|
183
188
|
self.channel_names, self.channel_indices = extract_experiment_channels(self.exp_dir)
|
|
184
189
|
self.nbr_channels = len(self.channel_names)
|
|
@@ -331,7 +336,8 @@ class MeasurementProcess(Process):
|
|
|
331
336
|
|
|
332
337
|
df = df.reset_index(drop=True)
|
|
333
338
|
df = _remove_invalid_cols(df)
|
|
334
|
-
|
|
339
|
+
df = df.replace([np.inf, -np.inf], np.nan)
|
|
340
|
+
|
|
335
341
|
df.to_csv(self.pos+os.sep.join(["output", "tables", self.table_name]), index=False)
|
|
336
342
|
print(f'Measurement table successfully exported in {os.sep.join(["output", "tables"])}...')
|
|
337
343
|
print('Done.')
|
|
@@ -5,7 +5,7 @@ import os
|
|
|
5
5
|
import json
|
|
6
6
|
import numpy as np
|
|
7
7
|
from celldetective.io import extract_position_name, locate_segmentation_model, auto_load_number_of_frames, load_frames, _check_label_dims, _load_frames_to_segment
|
|
8
|
-
from celldetective.utils import _rescale_labels, _segment_image_with_stardist_model, _segment_image_with_cellpose_model, _prep_stardist_model, _prep_cellpose_model, _get_normalize_kwargs_from_config, extract_experiment_channels, _estimate_scale_factor, _extract_channel_indices_from_config,
|
|
8
|
+
from celldetective.utils import _rescale_labels, _segment_image_with_stardist_model, _segment_image_with_cellpose_model, _prep_stardist_model, _prep_cellpose_model, _get_normalize_kwargs_from_config, extract_experiment_channels, _estimate_scale_factor, _extract_channel_indices_from_config, config_section_to_dict, _extract_nbr_channels_from_config, _get_img_num_per_channel
|
|
9
9
|
|
|
10
10
|
from pathlib import Path, PurePath
|
|
11
11
|
from glob import glob
|
|
@@ -39,10 +39,25 @@ class BaseSegmentProcess(Process):
|
|
|
39
39
|
print(f"Position: {extract_position_name(self.pos)}...")
|
|
40
40
|
print("Configuration file: ",self.config)
|
|
41
41
|
print(f"Population: {self.mode}...")
|
|
42
|
-
|
|
42
|
+
self.instruction_file = os.sep.join(["configs", f"segmentation_instructions_{self.mode}.json"])
|
|
43
|
+
|
|
44
|
+
self.read_instructions()
|
|
43
45
|
self.extract_experiment_parameters()
|
|
44
46
|
self.detect_movie_length()
|
|
45
47
|
self.write_folders()
|
|
48
|
+
|
|
49
|
+
def read_instructions(self):
|
|
50
|
+
print('Looking for instruction file...')
|
|
51
|
+
instr_path = PurePath(self.exp_dir,Path(f"{self.instruction_file}"))
|
|
52
|
+
if os.path.exists(instr_path):
|
|
53
|
+
with open(instr_path, 'r') as f:
|
|
54
|
+
_instructions = json.load(f)
|
|
55
|
+
print(f"Measurement instruction file successfully loaded...")
|
|
56
|
+
print(f"Instructions: {_instructions}...")
|
|
57
|
+
self.flip = _instructions.get("flip", False)
|
|
58
|
+
else:
|
|
59
|
+
self.flip = False
|
|
60
|
+
|
|
46
61
|
|
|
47
62
|
def write_folders(self):
|
|
48
63
|
|
|
@@ -58,9 +73,9 @@ class BaseSegmentProcess(Process):
|
|
|
58
73
|
|
|
59
74
|
def extract_experiment_parameters(self):
|
|
60
75
|
|
|
61
|
-
self.spatial_calibration = float(
|
|
62
|
-
self.len_movie = float(
|
|
63
|
-
self.movie_prefix =
|
|
76
|
+
self.spatial_calibration = float(config_section_to_dict(self.config, "MovieSettings")["pxtoum"])
|
|
77
|
+
self.len_movie = float(config_section_to_dict(self.config, "MovieSettings")["len_movie"])
|
|
78
|
+
self.movie_prefix = config_section_to_dict(self.config, "MovieSettings")["movie_prefix"]
|
|
64
79
|
self.nbr_channels = _extract_nbr_channels_from_config(self.config)
|
|
65
80
|
self.channel_names, self.channel_indices = extract_experiment_channels(self.exp_dir)
|
|
66
81
|
|
|
@@ -357,7 +372,7 @@ class SegmentCellThresholdProcess(BaseSegmentProcess):
|
|
|
357
372
|
|
|
358
373
|
self.indices = list(range(self.img_num_channels.shape[1]))
|
|
359
374
|
if self.flip:
|
|
360
|
-
self.indices = reversed(self.indices)
|
|
375
|
+
self.indices = np.array(list(reversed(self.indices)))
|
|
361
376
|
|
|
362
377
|
chunks = np.array_split(self.indices, self.n_threads)
|
|
363
378
|
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
from multiprocessing import Process
|
|
2
2
|
import time
|
|
3
|
-
import datetime
|
|
4
|
-
import os
|
|
5
|
-
import json
|
|
6
3
|
from celldetective.io import auto_load_number_of_frames, _load_frames_to_measure, locate_labels
|
|
7
|
-
from celldetective.utils import
|
|
4
|
+
from celldetective.utils import config_section_to_dict, _get_img_num_per_channel, \
|
|
5
|
+
_mask_intensity_measurements, remove_file_if_exists
|
|
8
6
|
from pathlib import Path, PurePath
|
|
9
7
|
from glob import glob
|
|
10
8
|
from tqdm import tqdm
|
|
@@ -155,12 +153,12 @@ class TrackingProcess(Process):
|
|
|
155
153
|
|
|
156
154
|
def extract_experiment_parameters(self):
|
|
157
155
|
|
|
158
|
-
self.movie_prefix =
|
|
159
|
-
self.spatial_calibration = float(
|
|
160
|
-
self.time_calibration = float(
|
|
161
|
-
self.len_movie = float(
|
|
162
|
-
self.shape_x = int(
|
|
163
|
-
self.shape_y = int(
|
|
156
|
+
self.movie_prefix = config_section_to_dict(self.config, "MovieSettings")["movie_prefix"]
|
|
157
|
+
self.spatial_calibration = float(config_section_to_dict(self.config, "MovieSettings")["pxtoum"])
|
|
158
|
+
self.time_calibration = float(config_section_to_dict(self.config, "MovieSettings")["frametomin"])
|
|
159
|
+
self.len_movie = float(config_section_to_dict(self.config, "MovieSettings")["len_movie"])
|
|
160
|
+
self.shape_x = int(config_section_to_dict(self.config, "MovieSettings")["shape_x"])
|
|
161
|
+
self.shape_y = int(config_section_to_dict(self.config, "MovieSettings")["shape_y"])
|
|
164
162
|
|
|
165
163
|
self.channel_names, self.channel_indices = extract_experiment_channels(self.exp_dir)
|
|
166
164
|
self.nbr_channels = len(self.channel_names)
|
|
@@ -246,7 +244,9 @@ class TrackingProcess(Process):
|
|
|
246
244
|
|
|
247
245
|
print('Features successfully measured...')
|
|
248
246
|
|
|
249
|
-
df = pd.concat(self.timestep_dataframes)
|
|
247
|
+
df = pd.concat(self.timestep_dataframes)
|
|
248
|
+
df = df.replace([np.inf, -np.inf], np.nan)
|
|
249
|
+
|
|
250
250
|
df.reset_index(inplace=True, drop=True)
|
|
251
251
|
df = _mask_intensity_measurements(df, self.mask_channels)
|
|
252
252
|
|
|
@@ -280,8 +280,7 @@ class TrackingProcess(Process):
|
|
|
280
280
|
trajectories.to_csv(self.pos+os.sep.join(['output', 'tables', self.table_name]), index=False)
|
|
281
281
|
print(f"Trajectory table successfully exported in {os.sep.join(['output', 'tables'])}...")
|
|
282
282
|
|
|
283
|
-
|
|
284
|
-
os.remove(self.pos+os.sep.join(['output', 'tables', self.table_name.replace('.csv','.pkl')]))
|
|
283
|
+
remove_file_if_exists(self.pos+os.sep.join(['output', 'tables', self.table_name.replace('.csv','.pkl')]))
|
|
285
284
|
|
|
286
285
|
del trajectories; del napari_data;
|
|
287
286
|
gc.collect()
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
from ._settings_measurements import SettingsMeasurements
|
|
2
|
+
from ._settings_segmentation import SettingsSegmentation
|
|
3
|
+
from ._settings_tracking import SettingsTracking
|
|
4
|
+
from ._settings_segmentation_model_training import SettingsSegmentationModelTraining
|
|
5
|
+
from ._settings_event_model_training import SettingsEventDetectionModelTraining
|
|
6
|
+
from ._settings_signal_annotator import SettingsSignalAnnotator
|
|
7
|
+
from ._settings_neighborhood import SettingsNeighborhood
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
from abc import abstractmethod
|
|
2
|
+
from PyQt5.QtWidgets import QApplication, QScrollArea, QSizePolicy, QVBoxLayout, QPushButton
|
|
3
|
+
from PyQt5.QtCore import Qt
|
|
4
|
+
from celldetective.utils import get_software_location
|
|
5
|
+
from celldetective.gui.gui_utils import center_window
|
|
6
|
+
from celldetective.gui import CelldetectiveMainWindow, CelldetectiveWidget
|
|
7
|
+
from PyQt5.QtGui import QDoubleValidator, QIntValidator
|
|
8
|
+
|
|
9
|
+
class CelldetectiveSettingsPanel(CelldetectiveMainWindow):
|
|
10
|
+
|
|
11
|
+
def __init__(self, title=""):
|
|
12
|
+
|
|
13
|
+
super().__init__()
|
|
14
|
+
self.setWindowTitle(title)
|
|
15
|
+
|
|
16
|
+
self._get_screen_height()
|
|
17
|
+
#self.setMinimumWidth(500)
|
|
18
|
+
self.setMaximumHeight(int(0.8 * self._screen_height))
|
|
19
|
+
self._scroll_area = QScrollArea(self)
|
|
20
|
+
self._floatValidator = QDoubleValidator()
|
|
21
|
+
self._intValidator = QIntValidator()
|
|
22
|
+
self._software_path = get_software_location()
|
|
23
|
+
|
|
24
|
+
self._create_widgets()
|
|
25
|
+
self._build_layouts()
|
|
26
|
+
self.center_window()
|
|
27
|
+
|
|
28
|
+
def _create_widgets(self):
|
|
29
|
+
self.submit_btn: QPushButton = QPushButton("Save")
|
|
30
|
+
self.submit_btn.setStyleSheet(self.button_style_sheet)
|
|
31
|
+
self.submit_btn.clicked.connect(self._write_instructions)
|
|
32
|
+
|
|
33
|
+
def center_window(self):
|
|
34
|
+
return center_window(self)
|
|
35
|
+
|
|
36
|
+
def _get_screen_height(self):
|
|
37
|
+
app = QApplication.instance()
|
|
38
|
+
screen = app.primaryScreen()
|
|
39
|
+
geometry = screen.availableGeometry()
|
|
40
|
+
self._screen_width, self._screen_height = geometry.getRect()[-2:]
|
|
41
|
+
|
|
42
|
+
def _adjustSize(self):
|
|
43
|
+
self._widget.adjustSize()
|
|
44
|
+
self._scroll_area.adjustSize()
|
|
45
|
+
self.adjustSize()
|
|
46
|
+
|
|
47
|
+
def _build_layouts(self):
|
|
48
|
+
|
|
49
|
+
self._layout: QVBoxLayout = QVBoxLayout()
|
|
50
|
+
self._widget: CelldetectiveWidget = CelldetectiveWidget()
|
|
51
|
+
self._widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
|
52
|
+
|
|
53
|
+
# Create button widget and layout
|
|
54
|
+
self._widget.setLayout(self._layout)
|
|
55
|
+
self._layout.setContentsMargins(30, 30, 30, 30)
|
|
56
|
+
|
|
57
|
+
self._scroll_area.setAlignment(Qt.AlignCenter)
|
|
58
|
+
self._scroll_area.setWidget(self._widget)
|
|
59
|
+
self._scroll_area.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
|
60
|
+
self._scroll_area.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
|
61
|
+
self._scroll_area.setWidgetResizable(True)
|
|
62
|
+
self.setCentralWidget(self._scroll_area)
|
|
63
|
+
|
|
64
|
+
QApplication.processEvents()
|
|
65
|
+
|
|
66
|
+
@abstractmethod
|
|
67
|
+
def _load_previous_instructions(self): pass
|
|
68
|
+
|
|
69
|
+
@abstractmethod
|
|
70
|
+
def _write_instructions(self): pass
|
celldetective/gui/{retrain_signal_model_options.py → settings/_settings_event_model_training.py}
RENAMED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
from PyQt5.QtWidgets import
|
|
1
|
+
from PyQt5.QtWidgets import QMessageBox, QComboBox, QFrame, QCheckBox, QFileDialog, QGridLayout, QLineEdit, QVBoxLayout, QLabel, QHBoxLayout, QPushButton
|
|
2
2
|
from PyQt5.QtCore import Qt, QSize
|
|
3
|
-
from PyQt5.QtGui import QDoubleValidator, QIntValidator, QIcon
|
|
4
|
-
from celldetective.gui.gui_utils import center_window
|
|
5
3
|
from celldetective.gui.layouts import ChannelNormGenerator
|
|
6
4
|
from superqt import QLabeledDoubleSlider, QLabeledSlider, QSearchableComboBox
|
|
7
5
|
from superqt.fonticon import icon
|
|
8
6
|
from fonticon_mdi6 import MDI6
|
|
9
|
-
from celldetective.utils import get_software_location
|
|
10
7
|
from celldetective.io import locate_signal_dataset, get_signal_datasets_list, load_experiment_tables
|
|
11
8
|
from celldetective.signals import train_signal_model
|
|
12
9
|
import numpy as np
|
|
@@ -14,12 +11,12 @@ import json
|
|
|
14
11
|
import os
|
|
15
12
|
from glob import glob
|
|
16
13
|
from datetime import datetime
|
|
17
|
-
from celldetective.gui import CelldetectiveMainWindow, CelldetectiveWidget
|
|
18
14
|
from pandas.api.types import is_numeric_dtype
|
|
19
15
|
from celldetective.gui.processes.train_signal_model import TrainSignalModelProcess
|
|
20
16
|
from celldetective.gui.workers import ProgressWindow
|
|
17
|
+
from celldetective.gui.settings._settings_base import CelldetectiveSettingsPanel
|
|
21
18
|
|
|
22
|
-
class
|
|
19
|
+
class SettingsEventDetectionModelTraining(CelldetectiveSettingsPanel):
|
|
23
20
|
|
|
24
21
|
"""
|
|
25
22
|
UI to set measurement instructions.
|
|
@@ -28,87 +25,62 @@ class ConfigSignalModelTraining(CelldetectiveMainWindow):
|
|
|
28
25
|
|
|
29
26
|
def __init__(self, parent_window=None, signal_mode='single-cells'):
|
|
30
27
|
|
|
31
|
-
super().__init__()
|
|
32
28
|
self.parent_window = parent_window
|
|
33
|
-
self.setWindowTitle("Train signal model")
|
|
34
29
|
self.mode = self.parent_window.mode
|
|
35
30
|
self.exp_dir = self.parent_window.exp_dir
|
|
36
|
-
self.
|
|
37
|
-
self.pretrained_model = None
|
|
31
|
+
self.pretrained_model = None
|
|
38
32
|
self.dataset_folder = None
|
|
39
33
|
self.current_neighborhood = None
|
|
40
34
|
self.reference_population = None
|
|
41
35
|
self.neighbor_population = None
|
|
42
36
|
self.signal_mode = signal_mode
|
|
37
|
+
|
|
38
|
+
super().__init__(title="Train event detection model")
|
|
43
39
|
|
|
44
40
|
if self.signal_mode=='single-cells':
|
|
45
|
-
self.signal_models_dir = self.
|
|
41
|
+
self.signal_models_dir = self._software_path+os.sep+os.sep.join(['celldetective','models','signal_detection'])
|
|
46
42
|
elif self.signal_mode=='pairs':
|
|
47
|
-
self.signal_models_dir = self.
|
|
43
|
+
self.signal_models_dir = self._software_path+os.sep+os.sep.join(['celldetective','models','pair_signal_detection'])
|
|
48
44
|
self.mode = 'pairs'
|
|
45
|
+
|
|
46
|
+
self._add_to_layout()
|
|
47
|
+
self._load_previous_instructions()
|
|
48
|
+
|
|
49
|
+
self._adjustSize()
|
|
50
|
+
new_width = int(self.width()*1.2)
|
|
51
|
+
self.resize(new_width, int(self._screen_height * 0.8))
|
|
52
|
+
self.setMinimumWidth(new_width)
|
|
53
|
+
|
|
54
|
+
def _add_to_layout(self):
|
|
55
|
+
self._layout.addWidget(self.model_frame)
|
|
56
|
+
self._layout.addWidget(self.data_frame)
|
|
57
|
+
self._layout.addWidget(self.hyper_frame)
|
|
58
|
+
self._layout.addWidget(self.submit_btn)
|
|
49
59
|
|
|
50
|
-
|
|
51
|
-
self.onlyInt = QIntValidator()
|
|
52
|
-
|
|
53
|
-
self.screen_height = self.parent_window.parent_window.parent_window.screen_height
|
|
54
|
-
center_window(self)
|
|
55
|
-
|
|
56
|
-
self.setMinimumWidth(500)
|
|
57
|
-
self.setMinimumHeight(int(0.3*self.screen_height))
|
|
58
|
-
self.setMaximumHeight(int(0.8*self.screen_height))
|
|
59
|
-
self.populate_widget()
|
|
60
|
-
#self.load_previous_measurement_instructions()
|
|
61
|
-
|
|
62
|
-
def populate_widget(self):
|
|
60
|
+
def _create_widgets(self):
|
|
63
61
|
|
|
64
62
|
"""
|
|
65
63
|
Create the multibox design.
|
|
66
64
|
|
|
67
65
|
"""
|
|
66
|
+
super()._create_widgets()
|
|
68
67
|
|
|
69
|
-
# Create button widget and layout
|
|
70
|
-
self.scroll_area = QScrollArea(self)
|
|
71
|
-
self.button_widget = CelldetectiveWidget()
|
|
72
|
-
self.main_layout = QVBoxLayout()
|
|
73
|
-
self.button_widget.setLayout(self.main_layout)
|
|
74
|
-
self.main_layout.setContentsMargins(30,30,30,30)
|
|
75
|
-
|
|
76
68
|
# first frame for FEATURES
|
|
77
69
|
self.model_frame = QFrame()
|
|
78
70
|
self.model_frame.setFrameStyle(QFrame.StyledPanel | QFrame.Raised)
|
|
79
71
|
self.populate_model_frame()
|
|
80
|
-
self.main_layout.addWidget(self.model_frame)
|
|
81
72
|
|
|
82
73
|
self.data_frame = QFrame()
|
|
83
74
|
self.data_frame.setFrameStyle(QFrame.StyledPanel | QFrame.Raised)
|
|
84
75
|
self.populate_data_frame()
|
|
85
|
-
self.main_layout.addWidget(self.data_frame)
|
|
86
76
|
|
|
87
77
|
self.hyper_frame = QFrame()
|
|
88
78
|
self.hyper_frame.setFrameStyle(QFrame.StyledPanel | QFrame.Raised)
|
|
89
79
|
self.populate_hyper_frame()
|
|
90
|
-
self.main_layout.addWidget(self.hyper_frame)
|
|
91
80
|
|
|
92
|
-
self.submit_btn = QPushButton('Train')
|
|
93
|
-
self.submit_btn.setStyleSheet(self.button_style_sheet)
|
|
94
|
-
self.submit_btn.clicked.connect(self.prep_model)
|
|
95
|
-
self.main_layout.addWidget(self.submit_btn)
|
|
96
81
|
self.submit_btn.setEnabled(False)
|
|
82
|
+
self.submit_btn.setText("Train")
|
|
97
83
|
|
|
98
|
-
#self.populate_left_panel()
|
|
99
|
-
#grid.addLayout(self.left_side, 0, 0, 1, 1)
|
|
100
|
-
self.button_widget.adjustSize()
|
|
101
|
-
|
|
102
|
-
self.scroll_area.setAlignment(Qt.AlignCenter)
|
|
103
|
-
self.scroll_area.setWidget(self.button_widget)
|
|
104
|
-
self.scroll_area.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
|
105
|
-
self.scroll_area.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
|
106
|
-
self.scroll_area.setWidgetResizable(True)
|
|
107
|
-
self.setCentralWidget(self.scroll_area)
|
|
108
|
-
self.show()
|
|
109
|
-
|
|
110
|
-
QApplication.processEvents()
|
|
111
|
-
self.adjustScrollArea()
|
|
112
84
|
|
|
113
85
|
def populate_hyper_frame(self):
|
|
114
86
|
|
|
@@ -138,14 +110,14 @@ class ConfigSignalModelTraining(CelldetectiveMainWindow):
|
|
|
138
110
|
lr_layout = QHBoxLayout()
|
|
139
111
|
lr_layout.addWidget(QLabel('learning rate: '),30)
|
|
140
112
|
self.lr_le = QLineEdit('0,01')
|
|
141
|
-
self.lr_le.setValidator(self.
|
|
113
|
+
self.lr_le.setValidator(self._floatValidator)
|
|
142
114
|
lr_layout.addWidget(self.lr_le, 70)
|
|
143
115
|
layout.addLayout(lr_layout)
|
|
144
116
|
|
|
145
117
|
bs_layout = QHBoxLayout()
|
|
146
118
|
bs_layout.addWidget(QLabel('batch size: '),30)
|
|
147
119
|
self.bs_le = QLineEdit('64')
|
|
148
|
-
self.bs_le.setValidator(self.
|
|
120
|
+
self.bs_le.setValidator(self._intValidator)
|
|
149
121
|
bs_layout.addWidget(self.bs_le, 70)
|
|
150
122
|
layout.addLayout(bs_layout)
|
|
151
123
|
|
|
@@ -378,42 +350,11 @@ class ConfigSignalModelTraining(CelldetectiveMainWindow):
|
|
|
378
350
|
self.dataframes = {}
|
|
379
351
|
self.neighborhood_cols = []
|
|
380
352
|
for population in self.parent_window.parent_window.populations:
|
|
381
|
-
df_pop = load_experiment_tables(self.parent_window.exp_dir, population=
|
|
382
|
-
self.dataframes.update({
|
|
353
|
+
df_pop = load_experiment_tables(self.parent_window.exp_dir, population=population, load_pickle=True)
|
|
354
|
+
self.dataframes.update({population: df_pop})
|
|
383
355
|
if df_pop is not None:
|
|
384
356
|
self.neighborhood_cols.extend(
|
|
385
|
-
[f'{
|
|
386
|
-
|
|
387
|
-
# df_targets = load_experiment_tables(self.parent_window.exp_dir, population='targets', load_pickle=True)
|
|
388
|
-
# df_effectors = load_experiment_tables(self.parent_window.exp_dir, population='effectors', load_pickle=True)
|
|
389
|
-
#
|
|
390
|
-
# self.dataframes = {
|
|
391
|
-
# 'targets': df_targets,
|
|
392
|
-
# 'effectors': df_effectors,
|
|
393
|
-
# }
|
|
394
|
-
#
|
|
395
|
-
# self.neighborhood_cols = []
|
|
396
|
-
# self.reference_populations = []
|
|
397
|
-
# self.neighbor_populations = []
|
|
398
|
-
# if df_targets is not None:
|
|
399
|
-
# self.neighborhood_cols.extend(['target_ref_'+c for c in list(df_targets.columns) if c.startswith('neighborhood')])
|
|
400
|
-
# self.reference_populations.extend(['targets' for c in list(df_targets.columns) if c.startswith('neighborhood')])
|
|
401
|
-
# for c in list(df_targets.columns):
|
|
402
|
-
# if c.startswith('neighborhood') and '_2_' in c:
|
|
403
|
-
# self.neighbor_populations.append('effectors')
|
|
404
|
-
# elif c.startswith('neighborhood') and 'self' in c:
|
|
405
|
-
# self.neighbor_populations.append('targets')
|
|
406
|
-
#
|
|
407
|
-
# if df_effectors is not None:
|
|
408
|
-
# self.neighborhood_cols.extend(['effector_ref_'+c for c in list(df_effectors.columns) if c.startswith('neighborhood')])
|
|
409
|
-
# self.reference_populations.extend(['effectors' for c in list(df_effectors.columns) if c.startswith('neighborhood')])
|
|
410
|
-
# for c in list(df_effectors.columns):
|
|
411
|
-
# if c.startswith('neighborhood') and '_2_' in c:
|
|
412
|
-
# self.neighbor_populations.append('targets')
|
|
413
|
-
# elif c.startswith('neighborhood') and 'self' in c:
|
|
414
|
-
# self.neighbor_populations.append('effectors')
|
|
415
|
-
#
|
|
416
|
-
# print(f"The following neighborhoods were detected: {self.neighborhood_cols=} {self.reference_populations=} {self.neighbor_populations=}")
|
|
357
|
+
[f'{population}_ref_' + c for c in list(df_pop.columns) if c.startswith('neighborhood')])
|
|
417
358
|
|
|
418
359
|
self.neighborhood_choice_cb.addItems(self.neighborhood_cols)
|
|
419
360
|
|
|
@@ -519,7 +460,7 @@ class ConfigSignalModelTraining(CelldetectiveMainWindow):
|
|
|
519
460
|
while self.scroll_area.verticalScrollBar().isVisible() and self.height() < self.maximumHeight():
|
|
520
461
|
self.resize(self.width(), self.height() + step)
|
|
521
462
|
|
|
522
|
-
def
|
|
463
|
+
def _write_instructions(self):
|
|
523
464
|
|
|
524
465
|
model_name = self.modelname_le.text()
|
|
525
466
|
pretrained_model = self.pretrained_model
|
|
@@ -597,4 +538,7 @@ class ConfigSignalModelTraining(CelldetectiveMainWindow):
|
|
|
597
538
|
# return None
|
|
598
539
|
|
|
599
540
|
train_signal_model(model_folder+"training_instructions.json")
|
|
600
|
-
self.parent_window.refresh_signal_models()
|
|
541
|
+
self.parent_window.refresh_signal_models()
|
|
542
|
+
|
|
543
|
+
def _load_previous_instructions(self):
|
|
544
|
+
pass
|