small-fish-gui 1.3.4__py3-none-any.whl → 1.4.0__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.
- small_fish_gui/__init__.py +1 -1
- small_fish_gui/batch/__init__.py +5 -0
- small_fish_gui/batch/input.py +62 -0
- small_fish_gui/batch/integrity.py +158 -0
- small_fish_gui/batch/output.py +0 -0
- small_fish_gui/batch/pipeline.py +218 -0
- small_fish_gui/batch/prompt.py +426 -0
- small_fish_gui/batch/test.py +10 -0
- small_fish_gui/batch/update.py +132 -0
- small_fish_gui/batch/utils.py +66 -0
- small_fish_gui/batch/values.py +3 -0
- small_fish_gui/batch/values.txt +65 -0
- small_fish_gui/gui/__init__.py +1 -2
- small_fish_gui/gui/animation.py +24 -15
- small_fish_gui/gui/layout.py +147 -21
- small_fish_gui/gui/prompts.py +24 -26
- small_fish_gui/interface/output.py +8 -4
- small_fish_gui/pipeline/__init__.py +21 -0
- small_fish_gui/pipeline/_preprocess.py +72 -19
- small_fish_gui/pipeline/_segmentation.py +37 -1
- small_fish_gui/pipeline/detection.py +72 -8
- small_fish_gui/pipeline/main.py +7 -3
- small_fish_gui/utils.py +6 -1
- {small_fish_gui-1.3.4.dist-info → small_fish_gui-1.4.0.dist-info}/METADATA +1 -1
- small_fish_gui-1.4.0.dist-info/RECORD +49 -0
- small_fish_gui/gui/test.py +0 -4
- small_fish_gui-1.3.4.dist-info/RECORD +0 -38
- {small_fish_gui-1.3.4.dist-info → small_fish_gui-1.4.0.dist-info}/WHEEL +0 -0
- {small_fish_gui-1.3.4.dist-info → small_fish_gui-1.4.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
List of keys for batch 'values' dict instance :
|
|
2
|
+
|
|
3
|
+
Batch_folder
|
|
4
|
+
0
|
|
5
|
+
image path
|
|
6
|
+
3D stack
|
|
7
|
+
multichannel
|
|
8
|
+
Dense regions deconvolution
|
|
9
|
+
Cluster computation
|
|
10
|
+
Segmentation
|
|
11
|
+
Napari correction
|
|
12
|
+
x
|
|
13
|
+
y
|
|
14
|
+
z
|
|
15
|
+
c
|
|
16
|
+
t
|
|
17
|
+
cyto_model_name
|
|
18
|
+
cytoplasm channel
|
|
19
|
+
cytoplasm diameter
|
|
20
|
+
nucleus_model_name
|
|
21
|
+
nucleus channel
|
|
22
|
+
nucleus diameter
|
|
23
|
+
Segment only nuclei
|
|
24
|
+
show segmentation
|
|
25
|
+
saving path
|
|
26
|
+
filename
|
|
27
|
+
threshold
|
|
28
|
+
threshold penalty
|
|
29
|
+
channel to compute
|
|
30
|
+
voxel_size_z
|
|
31
|
+
voxel_size_y
|
|
32
|
+
voxel_size_x
|
|
33
|
+
spot_size_z
|
|
34
|
+
spot_size_y
|
|
35
|
+
spot_size_x
|
|
36
|
+
log_kernel_size_z
|
|
37
|
+
log_kernel_size_y
|
|
38
|
+
log_kernel_size_x
|
|
39
|
+
minimum_distance_z
|
|
40
|
+
minimum_distance_y
|
|
41
|
+
minimum_distance_x
|
|
42
|
+
nucleus channel signal
|
|
43
|
+
alpha
|
|
44
|
+
beta
|
|
45
|
+
gamma
|
|
46
|
+
deconvolution_kernel_z
|
|
47
|
+
deconvolution_kernel_y
|
|
48
|
+
deconvolution_kernel_x
|
|
49
|
+
cluster size
|
|
50
|
+
min number of spots
|
|
51
|
+
Interactive threshold selector
|
|
52
|
+
spots_extraction_folder
|
|
53
|
+
spots_filename
|
|
54
|
+
do_spots_csv
|
|
55
|
+
do_spots_excel
|
|
56
|
+
do_spots_feather
|
|
57
|
+
output_folder
|
|
58
|
+
batch_name
|
|
59
|
+
save segmentation
|
|
60
|
+
save detection
|
|
61
|
+
extract spots
|
|
62
|
+
csv
|
|
63
|
+
xlsx
|
|
64
|
+
feather
|
|
65
|
+
2
|
small_fish_gui/gui/__init__.py
CHANGED
|
@@ -10,7 +10,6 @@ from .prompts import input_image_prompt
|
|
|
10
10
|
from .prompts import hub_prompt
|
|
11
11
|
from .prompts import detection_parameters_promt
|
|
12
12
|
from .prompts import coloc_prompt
|
|
13
|
-
from .prompts import post_analysis_prompt
|
|
14
13
|
from .prompts import output_image_prompt
|
|
15
14
|
from .prompts import ask_cancel_detection
|
|
16
15
|
from .prompts import ask_cancel_segmentation
|
|
@@ -21,7 +20,7 @@ from .prompts import ask_detection_confirmation
|
|
|
21
20
|
from .layout import parameters_layout
|
|
22
21
|
from .layout import bool_layout
|
|
23
22
|
from .layout import path_layout
|
|
24
|
-
from .layout import
|
|
23
|
+
from .layout import combo_elmt
|
|
25
24
|
from .layout import tuple_layout
|
|
26
25
|
from .layout import radio_layout
|
|
27
26
|
from .layout import add_header
|
small_fish_gui/gui/animation.py
CHANGED
|
@@ -10,21 +10,30 @@ WAITING_TEXT = [
|
|
|
10
10
|
|
|
11
11
|
def add_default_loading(funct) :
|
|
12
12
|
def inner(*args,**kwargs) :
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
|
|
14
|
+
hide_loading = kwargs.get("hide_loading")
|
|
15
|
+
if 'hide_loading' in kwargs : del kwargs['hide_loading']
|
|
16
|
+
|
|
17
|
+
if not hide_loading :
|
|
18
|
+
random_text = np.random.randint(0,len(WAITING_TEXT))
|
|
19
|
+
waiting_layout = [
|
|
20
|
+
[sg.Text(WAITING_TEXT[random_text], font= '10')]
|
|
21
|
+
]
|
|
22
|
+
window = sg.Window(
|
|
23
|
+
title= 'small_fish',
|
|
24
|
+
layout= waiting_layout,
|
|
25
|
+
grab_anywhere= True,
|
|
26
|
+
finalize=True
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
window.read(timeout= 30, close= False)
|
|
30
|
+
try :
|
|
31
|
+
return funct(*args, **kwargs)
|
|
32
|
+
finally :
|
|
33
|
+
window.close()
|
|
34
|
+
|
|
35
|
+
else :
|
|
26
36
|
return funct(*args, **kwargs)
|
|
27
|
-
|
|
28
|
-
window.close()
|
|
37
|
+
|
|
29
38
|
return inner
|
|
30
39
|
|
small_fish_gui/gui/layout.py
CHANGED
|
@@ -7,9 +7,10 @@ from cellpose.core import use_gpu
|
|
|
7
7
|
sg.theme('DarkAmber')
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
def add_header(header_text
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
def add_header(header_text) :
|
|
11
|
+
"""Returns [elmnt] not layout"""
|
|
12
|
+
header = [sg.Text('\n{0}'.format(header_text), size= (len(header_text),3), font= 'bold 15')]
|
|
13
|
+
return header
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
def pad_right(string, length, pad_char) :
|
|
@@ -50,7 +51,7 @@ def parameters_layout(parameters:'list[str]' = [], unit=None, header= None, defa
|
|
|
50
51
|
layout[line_id] += [sg.Text('{0}'.format(unit))]
|
|
51
52
|
|
|
52
53
|
if isinstance(header, str) :
|
|
53
|
-
layout = add_header(header
|
|
54
|
+
layout = [add_header(header)] + layout
|
|
54
55
|
return layout
|
|
55
56
|
|
|
56
57
|
def tuple_layout(opt=None, default_dict={}, unit:dict={}, **tuples) :
|
|
@@ -97,7 +98,7 @@ def path_layout(keys= [],look_for_dir = False, header=None, preset=os.getcwd())
|
|
|
97
98
|
[sg.Text(pad_right(name, max_length, ' ')), Browse(key= name, initial_folder= preset)] for name in keys
|
|
98
99
|
]
|
|
99
100
|
if isinstance(header, str) :
|
|
100
|
-
layout = add_header(header
|
|
101
|
+
layout = [add_header(header)] + layout
|
|
101
102
|
return layout
|
|
102
103
|
|
|
103
104
|
def bool_layout(parameters= [], header=None, preset=None) :
|
|
@@ -118,10 +119,10 @@ def bool_layout(parameters= [], header=None, preset=None) :
|
|
|
118
119
|
[sg.Checkbox(pad_right(name, max_length, ' '), key= name, default=box_preset)] for name, box_preset in zip(parameters,preset)
|
|
119
120
|
]
|
|
120
121
|
if isinstance(header, str) :
|
|
121
|
-
layout = add_header(header
|
|
122
|
+
layout = [add_header(header)] + layout
|
|
122
123
|
return layout
|
|
123
124
|
|
|
124
|
-
def
|
|
125
|
+
def combo_elmt(values, key, header=None, read_only=True, default_value=None) :
|
|
125
126
|
"""
|
|
126
127
|
drop-down list
|
|
127
128
|
"""
|
|
@@ -135,7 +136,7 @@ def combo_layout(values, key, header=None, read_only=True, default_value=None) :
|
|
|
135
136
|
sg.Combo(values, default_value=default_value, readonly=read_only, key=key)
|
|
136
137
|
]
|
|
137
138
|
if isinstance(header, str) :
|
|
138
|
-
layout = add_header(header
|
|
139
|
+
layout = add_header(header) + layout
|
|
139
140
|
return layout
|
|
140
141
|
|
|
141
142
|
def radio_layout(values, header=None) :
|
|
@@ -148,7 +149,7 @@ def radio_layout(values, header=None) :
|
|
|
148
149
|
[sg.Radio(value, group_id= 0) for value in values]
|
|
149
150
|
]
|
|
150
151
|
if isinstance(header, str) :
|
|
151
|
-
layout = add_header(header
|
|
152
|
+
layout = [add_header(header)] + layout
|
|
152
153
|
return layout
|
|
153
154
|
|
|
154
155
|
def _segmentation_layout(multichannel, cytoplasm_model_preset= 'cyto2', nucleus_model_preset= 'nuclei', cytoplasm_channel_preset=0, nucleus_channel_preset=0, cyto_diameter_preset=30, nucleus_diameter_preset= 30, show_segmentation_preset= False, segment_only_nuclei_preset=False, saving_path_preset=os.getcwd(), filename_preset='cell_segmentation.png',) :
|
|
@@ -162,23 +163,148 @@ def _segmentation_layout(multichannel, cytoplasm_model_preset= 'cyto2', nucleus_
|
|
|
162
163
|
layout = [[sg.Text("GPU is currently "), sg.Text('ON', text_color= 'green') if USE_GPU else sg.Text('OFF', text_color= 'red')]]
|
|
163
164
|
|
|
164
165
|
#cytoplasm parameters
|
|
165
|
-
layout += [
|
|
166
|
-
|
|
166
|
+
layout += [
|
|
167
|
+
add_header("Cell Segmentation"),
|
|
168
|
+
[sg.Text("Choose cellpose model for cytoplasm: \n")],
|
|
169
|
+
combo_elmt(models_list, key='cyto_model_name', default_value= cytoplasm_model_preset)
|
|
167
170
|
]
|
|
168
|
-
|
|
169
|
-
layout +=
|
|
171
|
+
|
|
172
|
+
if multichannel : layout += parameters_layout(['cytoplasm channel'],default_values= [cytoplasm_channel_preset])
|
|
173
|
+
layout += parameters_layout(['cytoplasm diameter'], unit= "px", default_values= [cyto_diameter_preset])
|
|
170
174
|
#Nucleus parameters
|
|
171
175
|
layout += [
|
|
172
|
-
add_header("Nucleus segmentation"
|
|
173
|
-
|
|
176
|
+
add_header("Nucleus segmentation"),
|
|
177
|
+
[sg.Text("Choose cellpose model for nucleus: \n")],
|
|
178
|
+
combo_elmt(models_list, key='nucleus_model_name', default_value= nucleus_model_preset)
|
|
174
179
|
]
|
|
175
|
-
|
|
176
|
-
layout +=
|
|
177
|
-
layout +=
|
|
180
|
+
|
|
181
|
+
if multichannel : layout += parameters_layout(['nucleus channel'], default_values= [nucleus_channel_preset])
|
|
182
|
+
layout += parameters_layout([ 'nucleus diameter'],unit= "px", default_values= [nucleus_diameter_preset])
|
|
183
|
+
layout += bool_layout(["Segment only nuclei"], preset=segment_only_nuclei_preset)
|
|
178
184
|
|
|
179
185
|
#Control plots
|
|
180
|
-
layout +=
|
|
181
|
-
layout +=
|
|
182
|
-
layout +=
|
|
186
|
+
layout += bool_layout(['show segmentation'], header= 'Segmentation plots', preset= show_segmentation_preset)
|
|
187
|
+
layout += path_layout(['saving path'], look_for_dir=True, preset=saving_path_preset)
|
|
188
|
+
layout += parameters_layout(['filename'], default_values=[filename_preset], size= 25)
|
|
189
|
+
|
|
190
|
+
return layout
|
|
191
|
+
|
|
192
|
+
def _input_parameters_layout(
|
|
193
|
+
ask_for_segmentation,
|
|
194
|
+
is_3D_stack_preset,
|
|
195
|
+
time_stack_preset,
|
|
196
|
+
multichannel_preset,
|
|
197
|
+
do_dense_regions_deconvolution_preset,
|
|
198
|
+
do_clustering_preset,
|
|
199
|
+
do_segmentation_preset,
|
|
200
|
+
do_Napari_correction
|
|
201
|
+
|
|
202
|
+
) :
|
|
203
|
+
layout_image_path = path_layout(['image path'], header= "Image")
|
|
204
|
+
layout_image_path += bool_layout(['3D stack', 'multichannel'], preset= [is_3D_stack_preset, time_stack_preset, multichannel_preset])
|
|
205
|
+
|
|
206
|
+
if ask_for_segmentation :
|
|
207
|
+
layout_image_path += bool_layout(
|
|
208
|
+
['Dense regions deconvolution', 'Cluster computation', 'Segmentation', 'Napari correction'],
|
|
209
|
+
preset= [do_dense_regions_deconvolution_preset, do_clustering_preset, do_segmentation_preset, do_Napari_correction],
|
|
210
|
+
header= "Pipeline settings")
|
|
211
|
+
else :
|
|
212
|
+
layout_image_path += bool_layout(
|
|
213
|
+
['Dense regions deconvolution', 'Cluster computation', 'Napari correction'],
|
|
214
|
+
preset= [do_dense_regions_deconvolution_preset, do_clustering_preset, do_Napari_correction],
|
|
215
|
+
header= "Pipeline settings")
|
|
216
|
+
|
|
217
|
+
return layout_image_path
|
|
218
|
+
|
|
219
|
+
def _detection_layout(
|
|
220
|
+
is_3D_stack,
|
|
221
|
+
is_multichannel,
|
|
222
|
+
do_dense_region_deconvolution,
|
|
223
|
+
do_clustering,
|
|
224
|
+
do_segmentation,
|
|
225
|
+
segmentation_done=False,
|
|
226
|
+
default_dict={},
|
|
227
|
+
) :
|
|
228
|
+
if is_3D_stack : dim = 3
|
|
229
|
+
else : dim = 2
|
|
230
|
+
|
|
231
|
+
#Detection
|
|
232
|
+
detection_parameters = ['threshold', 'threshold penalty']
|
|
233
|
+
default_detection = [default_dict.setdefault('threshold',''), default_dict.setdefault('threshold penalty', '1')]
|
|
234
|
+
opt= [True, True]
|
|
235
|
+
if is_multichannel :
|
|
236
|
+
detection_parameters += ['channel to compute']
|
|
237
|
+
opt += [False]
|
|
238
|
+
default_detection += [default_dict.setdefault('channel to compute', '')]
|
|
239
|
+
|
|
240
|
+
layout = [[sg.Text("Green parameters", text_color= 'green'), sg.Text(" are optional parameters.")]]
|
|
241
|
+
layout += parameters_layout(detection_parameters, header= 'Detection', opt=opt, default_values=default_detection)
|
|
242
|
+
|
|
243
|
+
if dim == 2 : tuple_shape = ('y','x')
|
|
244
|
+
else : tuple_shape = ('z','y','x')
|
|
245
|
+
opt = {'voxel_size' : False, 'spot_size' : False, 'log_kernel_size' : True, 'minimum_distance' : True}
|
|
246
|
+
unit = {'voxel_size' : 'nm', 'minimum_distance' : 'nm', 'spot_size' : 'radius(nm)', 'log_kernel_size' : 'px'}
|
|
247
|
+
|
|
248
|
+
layout += tuple_layout(opt=opt, unit=unit, default_dict=default_dict, voxel_size= tuple_shape, spot_size= tuple_shape, log_kernel_size= tuple_shape, minimum_distance= tuple_shape)
|
|
249
|
+
|
|
250
|
+
if (do_segmentation and is_multichannel) or (is_multichannel and segmentation_done):
|
|
251
|
+
default_segmentation = [default_dict.setdefault('nucleus channel signal', default_dict.setdefault('nucleus channel',0))]
|
|
252
|
+
layout += [[sg.Text("nucleus channel signal "), sg.InputText(default_text=default_segmentation, key= "nucleus channel signal", size= 5, tooltip= "Channel from which signal will be measured for nucleus features, \nallowing you to measure signal from a different channel than the one used for segmentation.")]]
|
|
253
|
+
# layout += parameters_layout(['nucleus channel signal'], default_values=default_segmentation) + [[sg.Text("Channel from which signal will be measured for nucleus features, allowing you to measure signal from a different channel than the one used for segmentation.")]]
|
|
254
|
+
|
|
255
|
+
#Deconvolution
|
|
256
|
+
if do_dense_region_deconvolution :
|
|
257
|
+
default_dense_regions_deconvolution = [default_dict.setdefault('alpha',0.5), default_dict.setdefault('beta',1)]
|
|
258
|
+
layout += parameters_layout(['alpha', 'beta',], default_values= default_dense_regions_deconvolution, header= 'Dense regions deconvolution')
|
|
259
|
+
layout += parameters_layout(['gamma'], unit= 'px', default_values= [default_dict.setdefault('gamma',5)])
|
|
260
|
+
layout += tuple_layout(opt= {"deconvolution_kernel" : True}, unit= {"deconvolution_kernel" : 'px'}, default_dict=default_dict, deconvolution_kernel = tuple_shape)
|
|
261
|
+
|
|
262
|
+
#Clustering
|
|
263
|
+
if do_clustering :
|
|
264
|
+
layout += parameters_layout(['cluster size'], unit="radius(nm)", default_values=[default_dict.setdefault('cluster size',400)])
|
|
265
|
+
layout += parameters_layout(['min number of spots'], default_values=[default_dict.setdefault('min number of spots', 5)])
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
layout += bool_layout(['Interactive threshold selector'], preset=[False])
|
|
270
|
+
layout += path_layout(
|
|
271
|
+
keys=['spots_extraction_folder'],
|
|
272
|
+
look_for_dir=True,
|
|
273
|
+
header= "Individual spot extraction",
|
|
274
|
+
preset= default_dict.setdefault('spots_extraction_folder', '')
|
|
275
|
+
)
|
|
276
|
+
layout += parameters_layout(
|
|
277
|
+
parameters=['spots_filename'],
|
|
278
|
+
default_values=[default_dict.setdefault('spots_filename','spots_extraction')],
|
|
279
|
+
size= 13
|
|
280
|
+
)
|
|
281
|
+
layout += bool_layout(
|
|
282
|
+
parameters= ['do_spots_csv', 'do_spots_excel', 'do_spots_feather'],
|
|
283
|
+
preset= [default_dict.setdefault('do_spots_csv',False), default_dict.setdefault('do_spots_excel',False),default_dict.setdefault('do_spots_feather',False)]
|
|
284
|
+
)
|
|
285
|
+
|
|
286
|
+
return layout
|
|
287
|
+
|
|
288
|
+
def _ask_channel_map_layout(
|
|
289
|
+
shape,
|
|
290
|
+
is_3D_stack,
|
|
291
|
+
multichannel,
|
|
292
|
+
is_time_stack,
|
|
293
|
+
preset_map={},
|
|
294
|
+
) :
|
|
295
|
+
|
|
296
|
+
x = preset_map.setdefault('x',0)
|
|
297
|
+
y = preset_map.setdefault('y',0)
|
|
298
|
+
z = preset_map.setdefault('z',0)
|
|
299
|
+
c = preset_map.setdefault('c',0)
|
|
300
|
+
t = preset_map.setdefault('t',0)
|
|
301
|
+
|
|
302
|
+
layout = [
|
|
303
|
+
add_header("Dimensions mapping"), [sg.Text("Image shape : {0}".format(shape))]
|
|
304
|
+
]
|
|
305
|
+
layout += parameters_layout(['x','y'], default_values=[x,y])
|
|
306
|
+
if is_3D_stack : layout += parameters_layout(['z'], default_values=[z])
|
|
307
|
+
if multichannel : layout += parameters_layout(['c'], default_values=[c])
|
|
308
|
+
if is_time_stack : layout += parameters_layout(['t'], default_values=[t])
|
|
183
309
|
|
|
184
310
|
return layout
|
small_fish_gui/gui/prompts.py
CHANGED
|
@@ -2,18 +2,24 @@ import PySimpleGUI as sg
|
|
|
2
2
|
import pandas as pd
|
|
3
3
|
import os
|
|
4
4
|
import numpy as np
|
|
5
|
-
from .layout import path_layout, parameters_layout, bool_layout, tuple_layout,
|
|
5
|
+
from .layout import path_layout, parameters_layout, bool_layout, tuple_layout, combo_elmt, add_header, path_layout
|
|
6
6
|
from ..interface import open_image, check_format, FormatError
|
|
7
7
|
from .help_module import ask_help
|
|
8
8
|
|
|
9
|
-
def prompt(layout, add_ok_cancel=True, timeout=None, timeout_key='TIMEOUT_KEY') :
|
|
9
|
+
def prompt(layout, add_ok_cancel=True, timeout=None, timeout_key='TIMEOUT_KEY', add_scrollbar=True) :
|
|
10
10
|
"""
|
|
11
11
|
Default event : 'Ok', 'Cancel'
|
|
12
12
|
"""
|
|
13
13
|
if add_ok_cancel : layout += [[sg.Button('Ok'), sg.Button('Cancel')]]
|
|
14
14
|
|
|
15
|
+
if add_scrollbar :
|
|
16
|
+
size = (400,500)
|
|
17
|
+
col_elmt = sg.Column(layout, scrollable=True, vertical_scroll_only=True, size=size)
|
|
18
|
+
layout = [[col_elmt]]
|
|
19
|
+
else :
|
|
20
|
+
size = (None,None)
|
|
15
21
|
|
|
16
|
-
window = sg.Window('small fish', layout=layout, margins=(10,10))
|
|
22
|
+
window = sg.Window('small fish', layout=layout, margins=(10,10), size=size, resizable=True)
|
|
17
23
|
event, values = window.read(timeout=timeout, timeout_key=timeout_key)
|
|
18
24
|
if event == None :
|
|
19
25
|
window.close()
|
|
@@ -26,12 +32,19 @@ def prompt(layout, add_ok_cancel=True, timeout=None, timeout_key='TIMEOUT_KEY')
|
|
|
26
32
|
window.close()
|
|
27
33
|
return event, values
|
|
28
34
|
|
|
29
|
-
def prompt_with_help(layout, help =None) :
|
|
35
|
+
def prompt_with_help(layout, help =None, add_scrollbar=True) :
|
|
30
36
|
layout += [[]]
|
|
31
37
|
layout += [[sg.Button('Help')]]
|
|
32
38
|
layout += [[sg.Button('Ok'), sg.Button('Cancel')]]
|
|
33
39
|
|
|
34
|
-
|
|
40
|
+
if add_scrollbar :
|
|
41
|
+
size = (400,500)
|
|
42
|
+
col_elmt = sg.Column(layout, scrollable=True, vertical_scroll_only=True, size=size)
|
|
43
|
+
layout = [[col_elmt]]
|
|
44
|
+
else :
|
|
45
|
+
size = (None,None)
|
|
46
|
+
|
|
47
|
+
window = sg.Window('small fish', layout=layout, size=size, resizable=True)
|
|
35
48
|
while True :
|
|
36
49
|
event, values = window.read()
|
|
37
50
|
if event == None :
|
|
@@ -79,7 +92,7 @@ def input_image_prompt(
|
|
|
79
92
|
else :
|
|
80
93
|
layout_image_path += bool_layout(['Dense regions deconvolution', 'Cluster computation', 'Napari correction'], preset= [do_dense_regions_deconvolution_preset, do_clustering_preset, do_Napari_correction], header= "Pipeline settings")
|
|
81
94
|
|
|
82
|
-
event, values = prompt_with_help(layout_image_path, help= 'general')
|
|
95
|
+
event, values = prompt_with_help(layout_image_path, help= 'general', add_scrollbar=False)
|
|
83
96
|
|
|
84
97
|
if event == 'Cancel' :
|
|
85
98
|
return None
|
|
@@ -227,22 +240,6 @@ def detection_parameters_promt(is_3D_stack, is_multichannel, do_dense_region_dec
|
|
|
227
240
|
else : values['dim'] = 2
|
|
228
241
|
return values
|
|
229
242
|
|
|
230
|
-
def post_analysis_prompt() :
|
|
231
|
-
answer = events(['Save results','add_detection', 'colocalisation', 'open results in napari'])
|
|
232
|
-
|
|
233
|
-
return answer
|
|
234
|
-
|
|
235
|
-
def events(event_list) :
|
|
236
|
-
"""
|
|
237
|
-
Return event chose from user
|
|
238
|
-
"""
|
|
239
|
-
|
|
240
|
-
layout = [
|
|
241
|
-
[sg.Button(event) for event in event_list]
|
|
242
|
-
]
|
|
243
|
-
|
|
244
|
-
event, values = prompt(layout, add_ok_cancel= False)
|
|
245
|
-
return event
|
|
246
243
|
|
|
247
244
|
def ask_replace_file(filename:str) :
|
|
248
245
|
layout = [
|
|
@@ -303,7 +300,7 @@ def hub_prompt(fov_results, do_segmentation=False) :
|
|
|
303
300
|
layout = [
|
|
304
301
|
[sg.Text('RESULTS', font= 'bold 13')],
|
|
305
302
|
[sg.Table(values= list(sumup_df.values), headings= list(sumup_df.columns), row_height=20, num_rows= 5, vertical_scroll_only=False, key= "result_table"), segmentation_object],
|
|
306
|
-
[sg.Button('Add detection'), sg.Button('Compute colocalisation')
|
|
303
|
+
[sg.Button('Add detection'), sg.Button('Compute colocalisation'), sg.Button('Batch detection')],
|
|
307
304
|
[sg.Button('Save results', button_color= 'green'), sg.Button('Delete acquisitions',button_color= 'gray'), sg.Button('Reset segmentation',button_color= 'gray'), sg.Button('Reset results',button_color= 'gray')]
|
|
308
305
|
# [sg.Button('Save results', button_color= 'green'), sg.Button('Reset results',button_color= 'gray')]
|
|
309
306
|
]
|
|
@@ -336,7 +333,7 @@ def ask_detection_confirmation(used_threshold) :
|
|
|
336
333
|
[sg.Button("Ok"), sg.Button("Restart detection")]
|
|
337
334
|
]
|
|
338
335
|
|
|
339
|
-
event, value = prompt(layout, add_ok_cancel=False)
|
|
336
|
+
event, value = prompt(layout, add_ok_cancel=False, add_scrollbar=False)
|
|
340
337
|
|
|
341
338
|
if event == 'Restart detection' :
|
|
342
339
|
return False
|
|
@@ -349,9 +346,10 @@ def ask_cancel_detection() :
|
|
|
349
346
|
[sg.Button("Yes"), sg.Button("No")]
|
|
350
347
|
]
|
|
351
348
|
|
|
352
|
-
event, value = prompt(layout, add_ok_cancel=False)
|
|
349
|
+
event, value = prompt(layout, add_ok_cancel=False, add_scrollbar=False)
|
|
353
350
|
|
|
354
351
|
if event == 'No' :
|
|
355
352
|
return False
|
|
356
353
|
else :
|
|
357
|
-
return True
|
|
354
|
+
return True
|
|
355
|
+
|
|
@@ -10,9 +10,11 @@ def _cast_spot_to_tuple(spot) :
|
|
|
10
10
|
def _cast_spots_to_tuple(spots) :
|
|
11
11
|
return tuple(list(map(_cast_spot_to_tuple, spots)))
|
|
12
12
|
|
|
13
|
-
def write_results(dataframe: pd.DataFrame, path:str, filename:str, do_excel= True, do_feather= False, do_csv=False) :
|
|
13
|
+
def write_results(dataframe: pd.DataFrame, path:str, filename:str, do_excel= True, do_feather= False, do_csv=False, overwrite=False) :
|
|
14
14
|
check_parameter(dataframe= pd.DataFrame, path= str, filename = str, do_excel = bool, do_feather = bool)
|
|
15
15
|
|
|
16
|
+
dataframe.columns = dataframe.columns.astype(str) # assert columns header are string for feather
|
|
17
|
+
|
|
16
18
|
if len(dataframe) == 0 : return True
|
|
17
19
|
if not do_excel and not do_feather and not do_csv :
|
|
18
20
|
return False
|
|
@@ -23,9 +25,11 @@ def write_results(dataframe: pd.DataFrame, path:str, filename:str, do_excel= Tru
|
|
|
23
25
|
|
|
24
26
|
new_filename = filename
|
|
25
27
|
i= 1
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
|
|
29
|
+
if not overwrite :
|
|
30
|
+
while new_filename + '.xlsx' in os.listdir(path) or new_filename + '.feather' in os.listdir(path) or new_filename + '.csv' in os.listdir(path) :
|
|
31
|
+
new_filename = filename + '_{0}'.format(i)
|
|
32
|
+
i+=1
|
|
29
33
|
|
|
30
34
|
if 'image' in dataframe.columns :
|
|
31
35
|
dataframe = dataframe.drop(['image'], axis=1)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Module containing main pipeline for user mode as well as calls for pipeline functions.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from ._preprocess import reorder_shape
|
|
6
|
+
from ._preprocess import reorder_image_stack
|
|
7
|
+
from ._preprocess import prepare_image_detection
|
|
8
|
+
from ._preprocess import convert_parameters_types
|
|
9
|
+
|
|
10
|
+
from ._segmentation import launch_segmentation
|
|
11
|
+
from ._segmentation import _cast_segmentation_parameters
|
|
12
|
+
from ._segmentation import cell_segmentation
|
|
13
|
+
from ._segmentation import plot_segmentation
|
|
14
|
+
|
|
15
|
+
from .detection import launch_detection
|
|
16
|
+
from .detection import launch_features_computation
|
|
17
|
+
from .detection import launch_cell_extraction
|
|
18
|
+
from .detection import get_nucleus_signal
|
|
19
|
+
from .detection import output_spot_tiffvisual
|
|
20
|
+
|
|
21
|
+
from .spots import launch_spots_extraction
|