small-fish-gui 2.0.1__py3-none-any.whl → 2.0.3__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 (51) hide show
  1. small_fish_gui/__init__.py +9 -3
  2. small_fish_gui/batch/integrity.py +2 -2
  3. small_fish_gui/batch/pipeline.py +46 -11
  4. small_fish_gui/batch/prompt.py +102 -41
  5. small_fish_gui/batch/update.py +26 -13
  6. small_fish_gui/batch/utils.py +1 -1
  7. small_fish_gui/gui/__init__.py +1 -0
  8. small_fish_gui/gui/_napari_widgets.py +418 -6
  9. small_fish_gui/gui/layout.py +332 -112
  10. small_fish_gui/gui/napari_visualiser.py +107 -22
  11. small_fish_gui/gui/prompts.py +161 -48
  12. small_fish_gui/gui/testing.ipynb +231 -24
  13. small_fish_gui/gui/tooltips.py +7 -1
  14. small_fish_gui/hints.py +23 -7
  15. small_fish_gui/interface/__init__.py +7 -1
  16. small_fish_gui/interface/default_settings.py +118 -0
  17. small_fish_gui/interface/image.py +43 -11
  18. small_fish_gui/interface/settings.json +50 -0
  19. small_fish_gui/interface/testing.ipynb +4354 -0
  20. small_fish_gui/interface/user_settings.py +96 -0
  21. small_fish_gui/main_menu.py +13 -1
  22. small_fish_gui/pipeline/{_signaltonoise.py → _bigfish_wrapers.py} +59 -7
  23. small_fish_gui/pipeline/_colocalisation.py +23 -24
  24. small_fish_gui/pipeline/_preprocess.py +46 -32
  25. small_fish_gui/pipeline/actions.py +48 -5
  26. small_fish_gui/pipeline/detection.py +71 -141
  27. small_fish_gui/pipeline/segmentation.py +360 -268
  28. small_fish_gui/pipeline/spots.py +3 -3
  29. small_fish_gui/pipeline/utils.py +5 -1
  30. small_fish_gui/README.md → small_fish_gui-2.0.3.dist-info/METADATA +50 -2
  31. small_fish_gui-2.0.3.dist-info/RECORD +46 -0
  32. {small_fish_gui-2.0.1.dist-info → small_fish_gui-2.0.3.dist-info}/WHEEL +1 -1
  33. small_fish_gui/.github/workflows/python-publish.yml +0 -39
  34. small_fish_gui/LICENSE +0 -24
  35. small_fish_gui/batch/values.txt +0 -65
  36. small_fish_gui/default_values.py +0 -51
  37. small_fish_gui/gui/screenshot/general_help_screenshot.png +0 -0
  38. small_fish_gui/gui/screenshot/mapping_help_screenshot.png +0 -0
  39. small_fish_gui/gui/screenshot/segmentation_help_screenshot.png +0 -0
  40. small_fish_gui/illustrations/DetectionVitrine_filtre.png +0 -0
  41. small_fish_gui/illustrations/DetectionVitrine_signal.png +0 -0
  42. small_fish_gui/illustrations/FocciVitrine.png +0 -0
  43. small_fish_gui/illustrations/FocciVitrine_no_spots.png +0 -0
  44. small_fish_gui/illustrations/Segmentation2D.png +0 -0
  45. small_fish_gui/illustrations/Segmentation2D_with_labels.png +0 -0
  46. small_fish_gui/logo.png +0 -0
  47. small_fish_gui/pipeline/testing.ipynb +0 -3636
  48. small_fish_gui/requirements.txt +0 -19
  49. small_fish_gui-2.0.1.dist-info/METADATA +0 -75
  50. small_fish_gui-2.0.1.dist-info/RECORD +0 -59
  51. {small_fish_gui-2.0.1.dist-info → small_fish_gui-2.0.3.dist-info}/licenses/LICENSE +0 -0
@@ -37,8 +37,14 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37
37
  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
38
38
  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39
39
  """
40
- __version__ = "2.0.1"
40
+ __version__ = "2.0.3"
41
41
  __wiki__ = "https://github.com/2Echoes/small_fish_gui/wiki"
42
42
 
43
- import os
44
- os.environ["QT_QPA_PLATFORM"] = "xcb"
43
+ import os, platform
44
+ system_type = platform.system()
45
+
46
+ if system_type == "Linux" :
47
+ try :
48
+ os.environ["QT_QPA_PLATFORM"] = "xcb"
49
+ except Exception :
50
+ pass
@@ -124,7 +124,7 @@ def check_detection_parameters(
124
124
  values=values,
125
125
  do_dense_region_deconvolution=do_dense_region_deconvolution,
126
126
  do_clustering=do_clustering,
127
- multichannel=is_multichannel,
127
+ is_multichannel=is_multichannel,
128
128
  segmentation_done= values['do_segmentation'],
129
129
  map_=map_,
130
130
  shape=shape
@@ -156,7 +156,7 @@ def check_output_parameters(values) :
156
156
  if len(values['batch_name']) == 0 : is_output_ok = False
157
157
 
158
158
  #extension
159
- if values['csv'] or values['xlsx'] or values['feather'] :
159
+ if values['csv'] or values['xlsx'] :
160
160
  pass
161
161
  else :
162
162
  sg.popup("Select at least one data format for output.")
@@ -6,6 +6,7 @@ import os, traceback
6
6
  import pandas as pd
7
7
  import FreeSimpleGUI as sg
8
8
  import numpy as np
9
+ from AF_eraser import remove_autofluorescence_RANSACfit
9
10
 
10
11
  from ..hints import pipeline_parameters
11
12
 
@@ -101,8 +102,8 @@ def batch_pipeline(
101
102
  parameters = _cast_segmentation_parameters(parameters)
102
103
  cytoplasm_label, nucleus_label = cell_segmentation(
103
104
  im_seg,
104
- cyto_model_name= parameters['cyto_model_name'],
105
- cyto_diameter= parameters['cytoplasm_diameter'],
105
+ cytoplasm_model_name= parameters['cytoplasm_model_name'],
106
+ cytoplasm_diameter= parameters['cytoplasm_diameter'],
106
107
  nucleus_model_name= parameters['nucleus_model_name'],
107
108
  nucleus_diameter= parameters['nucleus_diameter'],
108
109
  channels=[parameters['cytoplasm_channel'], parameters['nucleus_channel']],
@@ -110,10 +111,11 @@ def batch_pipeline(
110
111
  nucleus_3D_segmentation=parameters['nucleus_segmentation_3D'],
111
112
  cyto_3D_segmentation= parameters['cytoplasm_segmentation_3D'],
112
113
  do_only_nuc=parameters['segment_only_nuclei'],
113
- flow_threshold_cyto=parameters['flow_threshold_cyto'],
114
- flow_threshold_nuc=parameters['flow_threshold_cyto'],
115
- cellprob_threshold_cyto=parameters['cellprob_threshold_cyto'],
116
- cellprob_threshold_nuc=parameters['cellprob_threshold_nuc'],
114
+ cytoplasm_flow_threshold=parameters['cytoplasm_flow_threshold'],
115
+ nucleus_flow_threshold=parameters['cytoplasm_flow_threshold'],
116
+ cytoplasm_cellprob_threshold=parameters['cytoplasm_cellprob_threshold'],
117
+ nucleus_cellprob_threshold=parameters['nucleus_cellprob_threshold'],
118
+ **parameters
117
119
  )
118
120
 
119
121
  parameters['segmentation_done'] = True
@@ -146,13 +148,38 @@ def batch_pipeline(
146
148
  cytoplasm_label, nucleus_label = None,None
147
149
  parameters['segmentation_done'] = False
148
150
 
151
+ #2.5 Background removal (opt)
152
+ print("do_background_removal : ", parameters['do_background_removal'])
153
+ print("is_multichannel : ", parameters['is_multichannel'])
154
+ if parameters["do_background_removal"] and parameters["is_multichannel"] :
155
+ window_print(batch_window, "Removing background....")
156
+
157
+ _, other_image = prepare_image_detection(map_, parameters)
158
+ image_stack = reorder_image_stack(map_, image)
159
+ signal_channel = int(parameters['channel_to_compute'])
160
+ background_channel = int(parameters["background_channel"])
161
+
162
+ image= image_stack[signal_channel]
163
+ background = image_stack[background_channel]
164
+
165
+ result, score = remove_autofluorescence_RANSACfit(
166
+ signal=image,
167
+ background=background,
168
+ max_trials=100
169
+ )
170
+
171
+
172
+ print("\rBackground substraction done.")
173
+ else :
174
+ image, other_image = prepare_image_detection(map_, parameters)
175
+
176
+
149
177
  #3. Detection, deconvolution, clusterisation
150
178
  window_print(batch_window,"Detecting spots...")
151
179
  parameters = convert_parameters_types(parameters)
152
- image, other_image = prepare_image_detection(map_, parameters)
153
180
  nucleus_signal = get_nucleus_signal(image, other_image, parameters)
154
181
  try : # Catch error raised if user enter a spot size too small compare to voxel size
155
- parameters, frame_result, spots, clusters, spot_cluster_id = launch_detection(
182
+ parameters, frame_result, spots, clusters, spot_cluster_id,_ = launch_detection(
156
183
  image,
157
184
  other_image,
158
185
  parameters,
@@ -204,15 +231,23 @@ def batch_pipeline(
204
231
 
205
232
  #5. Features computation
206
233
  window_print(batch_window,"computing features...")
234
+
235
+ if do_segmentation :
236
+ nucleus_label = nucleus_label if nucleus_label.ndim == 2 else np.max(nucleus_label,axis=0),
237
+ cytoplasm_label= cytoplasm_label if cytoplasm_label.ndim == 2 else np.max(cytoplasm_label, axis=0),
238
+ else :
239
+ nucleus_label = None
240
+ cell_label = None
241
+
207
242
  new_results_df, new_cell_results_df = launch_features_computation(
208
243
  acquisition_id=acquisition_id + last_acquisition_id,
209
244
  image=image,
210
245
  nucleus_signal = nucleus_signal,
211
246
  spots=spots,
212
247
  clusters=clusters,
213
- spots_cluster_id=spot_cluster_id,
214
- nucleus_label = nucleus_label if nucleus_label.ndim == 2 else np.max(nucleus_label,axis=0),
215
- cell_label= cytoplasm_label if cytoplasm_label.ndim == 2 else np.max(cytoplasm_label, axis=0),
248
+ spots_cluster_id=spot_cluster_id,
249
+ nucleus_label=nucleus_label,
250
+ cell_label=cytoplasm_label,
216
251
  user_parameters=parameters,
217
252
  frame_results=frame_result,
218
253
  )
@@ -4,25 +4,34 @@ Submodule with main function to call to launch batch mode.
4
4
 
5
5
  import os
6
6
  import FreeSimpleGUI as sg
7
- import small_fish_gui.default_values as default
7
+
8
8
 
9
9
  from .utils import get_elmt_from_key, create_map, call_auto_map
10
10
  from .pipeline import batch_pipeline
11
- from .update import update_detection_tab, update_map_tab, update_master_parameters, update_segmentation_tab, update_output_tab
11
+ from .update import (
12
+ update_detection_tab,
13
+ update_map_tab,
14
+ update_master_parameters,
15
+ update_segmentation_tab,
16
+ update_output_tab,
17
+ update_background_removing_tab,
18
+ )
12
19
  from .input import load, extract_files
13
20
  from .integrity import sanity_check, check_channel_map_integrity, check_detection_parameters, check_segmentation_parameters, check_output_parameters
14
21
  from ..gui.layout import _segmentation_layout, _detection_layout, _input_parameters_layout, _ask_channel_map_layout
15
-
22
+ from ..gui.tooltips import REMOVE_BACKGROUND_TOOLTIP
23
+ from ..interface import get_settings
24
+ from ..hints import pipeline_parameters
16
25
 
17
26
  def batch_promp(
18
27
  results_df,
19
28
  cell_results_df,
20
29
  acquisition_id,
21
- preset: dict={},
22
- ) :
30
+ preset: pipeline_parameters,
31
+ ) :
23
32
 
24
33
  files_values = [[]]
25
-
34
+ default = get_settings()
26
35
 
27
36
  #LOAD FILES
28
37
  files_table = sg.Table(
@@ -46,21 +55,21 @@ def batch_promp(
46
55
  sanity_header = sg.Text("Dimension sanity", font=('bold',15), pad=(0,10))
47
56
  dimension_number_text = sg.Text("Dimension number : unknown")
48
57
 
49
- #LAYOUT INIT
50
- #########################################
51
- ##### COLUMNS
52
- #########################################
53
-
54
- ##### Tabs
58
+ #LAYOUT INIT
59
+ #########################################
60
+ ##### COLUMNS
61
+ #########################################
62
+
63
+ ##### Tabs
55
64
 
56
65
  #Input tab
57
66
  input_layout = _input_parameters_layout(
58
67
  ask_for_segmentation=True,
59
- is_3D_stack_preset= preset.setdefault("is_3D_stack" ,default.IS_3D_STACK),
68
+ is_3D_stack_preset= preset.setdefault("is_3D_stack" ,default.stack_3D),
60
69
  time_stack_preset=False,
61
- multichannel_preset=preset.setdefault("is_multichannel" ,default.IS_MULTICHANNEL),
62
- do_dense_regions_deconvolution_preset=preset.setdefault("do_dense_regions_deconvolution", default.DO_DENSE_REGIONS_DECONVOLUTION),
63
- do_clustering_preset= preset.setdefault("do_cluster_computation", default.DO_CLUSTER_COMPUTATION),
70
+ multichannel_preset=preset.setdefault("is_multichannel" ,default.multichannel_stack),
71
+ do_dense_regions_deconvolution_preset=preset.setdefault("do_dense_regions_deconvolution", default.do_dense_regions_deconvolution),
72
+ do_clustering_preset= preset.setdefault("do_cluster_computation", default.do_cluster),
64
73
  do_Napari_correction=False,
65
74
  do_segmentation_preset= preset.setdefault("segmentation_done", False),
66
75
  )
@@ -74,7 +83,7 @@ def batch_promp(
74
83
  shape=(0,1,2,3,4),
75
84
  is_3D_stack=True,
76
85
  is_time_stack=True,
77
- multichannel=True,
86
+ is_multichannel=True,
78
87
  )
79
88
  last_shape_read = sg.Text("Last shape read : None")
80
89
  auto_map = sg.Button("auto-map", disabled=True, pad=(10,0))
@@ -83,22 +92,30 @@ def batch_promp(
83
92
  map_layout += [[auto_map, apply_map_button]]
84
93
  map_tab = sg.Tab("Map", map_layout)
85
94
 
95
+
96
+ preset["is_3D_stack"] = True
97
+ preset["is_multichannel"] = True
98
+ preset.setdefault("cytoplasm_channel", preset["detection_channel"])
99
+ preset.setdefault("cytoplasm_segmentation_3D", preset["do_3D_segmentation"])
100
+ preset.setdefault("nucleus_segmentation_3D", preset["do_3D_segmentation"])
101
+ preset["filename"] = ""
102
+ preset["other_nucleus_image"] = ""
103
+ preset["saving_path"] = ""
104
+ preset["reordered_shape"] = None
105
+ preset.setdefault("filename", "")
86
106
  #Segmentation tab
87
- segmentation_layout = _segmentation_layout(
88
- multichannel=True,
89
- is_3D_stack=True,
90
- cytoplasm_model_preset=preset.setdefault("cyto_model_name",default.CYTO_MODEL),
91
- cytoplasm_channel_preset=preset.setdefault("cytoplasm_channel",default.CHANNEL),
92
- cyto_diameter_preset=preset.setdefault("cytoplasm_diameter",default.CYTO_DIAMETER),
93
- nucleus_model_preset=preset.setdefault("nucleus_model_name",default.NUC_MODEL),
94
- nucleus_channel_preset=preset.setdefault("nucleus channel",default.CHANNEL),
95
- nucleus_diameter_preset=preset.setdefault("nucleus_diameter",default.NUC_DIAMETER),
96
- segment_only_nuclei_preset=preset.setdefault("segment_only_nuclei",default.SEGMENT_ONLY_NUCLEI),
107
+ preset.setdefault("other_nucleus_image", default.working_directory)
108
+ preset.setdefault("cytoplasm_channel", default.detection_channel)
109
+ preset.setdefault("cytoplasm_segmentation_3D", default.do_3D_segmentation)
110
+ preset.setdefault("nucleus_segmentation_3D", default.do_3D_segmentation)
111
+
112
+ segmentation_layout, segmentation_event_dict = _segmentation_layout(
113
+ **preset
97
114
  )
98
115
 
99
116
  apply_segmentation_button = sg.Button('apply', key='apply-segmentation')
100
117
  segmentation_layout += [[apply_segmentation_button]]
101
- seg_keys_to_hide = ['show_segmentation', 'saving path', 'filename', 'other_nucleus_image', 'save_segmentation_visual', 'saving path_browse']
118
+ seg_keys_to_hide = ['show_segmentation', 'seg_control_saving_path', 'filename', 'other_nucleus_image', 'save_segmentation_visuals', 'seg_control_saving_path_browse']
102
119
  segmentation_tab = sg.Tab("Segmentation", segmentation_layout, visible=False)
103
120
 
104
121
  #Detection tab
@@ -115,18 +132,21 @@ def batch_promp(
115
132
  detection_keys_to_hide = ['do_spots_csv', 'do_spots_excel', 'spots_filename','spots_extraction_folder', 'spots_extraction_folder_browse']
116
133
  detection_tab = sg.Tab("Detection", detection_layout, visible=False)
117
134
 
135
+ #Remove background tab
136
+ background_removing_tab, background_removing_event_dict = create_background_removing_tab()
137
+
118
138
  #Output tab
119
139
  show_batch_folder_text = sg.Text('', key= 'batch_folder_text')
120
140
  apply_output_button = sg.Button('apply', key='apply-output')
121
141
  save_segmentation_visual_box = sg.Checkbox("save segmentation", disabled=True, key='save segmentation', tooltip= "Save png files illustrating segmentation borders.")
122
142
  save_segmentation_masks_box = sg.Check("save labels", disabled=True, key="save_masks", tooltip= "Save segmentation labels as .npy files.")
123
- save_detection_box = sg.Checkbox("create spot detection visuals", key= 'save detection', tooltip="Create multichannel tiff with raw spot signal and detected spots.\nWarning if processing a lot of files make sure you have enough free space on your hard drive.")
143
+ save_detection_box = sg.Checkbox("create spot detection visuals", key= 'save detection', tooltip="Create is_multichannel tiff with raw spot signal and detected spots.\nWarning if processing a lot of files make sure you have enough free space on your hard drive.")
124
144
  extract_spots_box = sg.Checkbox("extract spots", key='extract spots')
125
145
  batch_name_input = sg.InputText(size=25, key='batch_name')
126
146
  output_layout=[
127
147
  [sg.Text("Output folder", font=('bold',15), pad=(0,10))],
128
148
  [show_batch_folder_text],
129
- [sg.Text("Select a folder : "), sg.FolderBrowse(initial_folder=os.getcwd(), key='output_folder', target=(1,-1))],
149
+ [sg.Text("Select a folder : "), sg.FolderBrowse(initial_folder=default.working_directory, key='output_folder', target=(1,-1))],
130
150
  [sg.Text("Name for batch : "), batch_name_input],
131
151
  [save_detection_box],
132
152
  [extract_spots_box],
@@ -141,7 +161,7 @@ def batch_promp(
141
161
  output_tab = sg.Tab("Output", output_layout, visible=True)
142
162
 
143
163
  ##TAB GROUP
144
- _tab_group = sg.TabGroup([[input_tab, map_tab, segmentation_tab, detection_tab, output_tab]], enable_events=True)
164
+ _tab_group = sg.TabGroup([[input_tab, map_tab, segmentation_tab, detection_tab, background_removing_tab, output_tab]], enable_events=True)
145
165
  tab_col = sg.Column( #Allow the tab to be scrollable
146
166
  [[_tab_group]],
147
167
  scrollable=True,
@@ -156,6 +176,7 @@ def batch_promp(
156
176
  "Segmentation" : segmentation_tab,
157
177
  "Detection" : detection_tab,
158
178
  "Map" : map_tab,
179
+ "background_removing" : background_removing_tab,
159
180
  "Output" : output_tab
160
181
  }
161
182
 
@@ -192,12 +213,12 @@ def batch_promp(
192
213
  stream_output = sg.Output(size=(100,10), pad=(30,10), visible=True, expand_x=True, expand_y=True)
193
214
  layout = [
194
215
  [sg.Text("Batch Processing", font=('bold',20), pad=((300,0),(0,2)))],
195
- [sg.Text("Select a folder : "), sg.FolderBrowse(initial_folder=os.getcwd(), key='Batch_folder'), sg.Button('Load')],
216
+ [sg.Text("Select a folder : "), sg.FolderBrowse(initial_folder=preset["working_directory"], key='Batch_folder'), sg.Button('Load')],
196
217
  [files_table],
197
218
  [sanity_header, sanity_check_button, sanity_progress],
198
219
  [dimension_number_text],
199
220
  [tab_col, sg.Push(), launch_col, sg.Push()],
200
- [stream_output],
221
+ # [stream_output],
201
222
  ]
202
223
 
203
224
  window = sg.Window("small fish", layout=layout, size= (800,800), auto_size_buttons=True, auto_size_text=True, resizable=True)
@@ -217,7 +238,6 @@ def batch_promp(
217
238
  '_is_output_correct' : output_ok_text,
218
239
 
219
240
  }
220
- loop = 0
221
241
  timeout = 1
222
242
  last_shape = None
223
243
  talk=True
@@ -232,19 +252,25 @@ def batch_promp(
232
252
  get_elmt_from_key(tab_dict['Input'], key= 'image_path').update(disabled=True)
233
253
  for key in seg_keys_to_hide : get_elmt_from_key(tab_dict['Segmentation'], key=key).update(disabled=True)
234
254
  for key in detection_keys_to_hide : get_elmt_from_key(tab_dict['Detection'], key=key).update(disabled=True)
235
-
255
+ first_loop = True
256
+
236
257
  while True :
237
258
  try :
238
- loop +=1
239
259
  window = window.refresh()
240
260
  event, values = window.read(timeout=timeout)
241
261
 
262
+ if event != sg.TIMEOUT_KEY :
263
+ stream_output.restore_stderr()
264
+ stream_output.restore_stdout()
265
+
266
+
242
267
  #Welcome message
243
- if loop == 1 :
268
+ if first_loop :
244
269
  timeout = 500
245
270
  print("Welcome to small fish batch analysis. Please start by loading some files and setting parameters.")
271
+ first_loop = False
246
272
 
247
- if values is None : return results_df, cell_results_df, acquisition_id, preset, False, None,None
273
+ if values is None : return results_df, cell_results_df, acquisition_id, preset, bool(preset.get("segmentation_done")), None,None
248
274
 
249
275
  batch_folder = values.get('Batch_folder')
250
276
  is_multichanel = values.get('is_multichannel')
@@ -379,7 +405,8 @@ def batch_promp(
379
405
  stream_output.restore_stdout()
380
406
 
381
407
  window.close()
382
- return results_df, cell_results_df, acquisition_id, values, False, None,None #Segmentation done : False, cell label : None, Nucleus label : None
408
+ preset.update(values)
409
+ return results_df, cell_results_df, acquisition_id, preset, False, None,None #Segmentation done : False, cell label : None, Nucleus label : None
383
410
 
384
411
 
385
412
  #End of loop
@@ -406,7 +433,8 @@ def batch_promp(
406
433
  do_segmentation=do_segmentation,
407
434
  is_multichannel=is_multichanel,
408
435
  is_3D=is_3D,
409
- is_mapping_ok=Master_parameters_dict['_is_mapping_correct']
436
+ is_mapping_ok=Master_parameters_dict['_is_mapping_correct'],
437
+ segmentation_event_dict=segmentation_event_dict,
410
438
  )
411
439
 
412
440
  update_detection_tab(
@@ -419,6 +447,13 @@ def batch_promp(
419
447
  do_segmentation=do_segmentation,
420
448
  )
421
449
 
450
+ update_background_removing_tab(
451
+ is_multichanel=is_multichanel,
452
+ background_removing_tab=background_removing_tab,
453
+ event_dict=background_removing_event_dict,
454
+ channel_number= None if not is_multichanel else 100
455
+ )
456
+
422
457
  update_output_tab(
423
458
  tab_elmt=tab_dict['Output'],
424
459
  do_segmentation=do_segmentation,
@@ -443,4 +478,30 @@ def batch_promp(
443
478
  stream_output.restore_stderr()
444
479
  stream_output.restore_stdout()
445
480
  window.close()
446
- raise e
481
+ raise e
482
+
483
+
484
+
485
+ def create_background_removing_tab() :
486
+ settings = get_settings()
487
+
488
+ remove_background_bool = sg.Checkbox("Remove background", default=settings.do_background_removal, key="do_background_removal", tooltip=REMOVE_BACKGROUND_TOOLTIP)
489
+ channel_select = sg.Spin(initial_value=settings.background_channel, values=list(range(1000)), key= "background_channel")
490
+ max_trial_select = sg.Spin(initial_value=100, values=list(range(1000)), key= "background_max_trial")
491
+ apply_button = sg.Button("Apply", key = "apply-background_removing")
492
+
493
+ layout = [
494
+ [remove_background_bool],
495
+ [sg.Text("background channel"), channel_select],
496
+ [sg.Text("Max trial"), max_trial_select],
497
+ [apply_button]
498
+ ]
499
+
500
+ tab_layout = sg.Tab("Background removing", layout=layout, disabled=True)
501
+
502
+ event_dict = {
503
+ 'remove_background_bool' : remove_background_bool,
504
+ 'background_channel' : channel_select,
505
+ }
506
+
507
+ return tab_layout, event_dict
@@ -54,7 +54,7 @@ def update_detection_tab(
54
54
  cluster_size = get_elmt_from_key(tab_elmt, key= 'cluster_size')
55
55
  min_number_of_spot = get_elmt_from_key(tab_elmt, key= 'min_number_of_spots')
56
56
 
57
- #segmentation and multichannel
57
+ #segmentation and is_multichannel
58
58
  nucleus_channel_signal = get_elmt_from_key(tab_elmt, key= 'nucleus channel signal')
59
59
 
60
60
  #disable
@@ -93,20 +93,25 @@ def update_segmentation_tab(
93
93
  do_segmentation : bool,
94
94
  is_multichannel : bool,
95
95
  is_3D : bool,
96
- is_mapping_ok: bool
96
+ is_mapping_ok: bool,
97
+ segmentation_event_dict : dict,
97
98
  ) :
98
-
99
- #Access elements
100
- cytoplasm_channel_elmt = get_elmt_from_key(tab_elmt, key= 'cytoplasm_channel')
101
- nucleus_channel_elmt = get_elmt_from_key(tab_elmt, key= 'nucleus_channel')
102
- do_nucleus_3D_elmt = get_elmt_from_key(tab_elmt, key= "nucleus_segmentation_3D")
103
- do_cytoplasm_3D_elmt = get_elmt_from_key(tab_elmt, key= "cytoplasm_segmentation_3D")
104
-
99
+
105
100
  #Update values
106
- cytoplasm_channel_elmt.update(disabled = not is_multichannel)
107
- nucleus_channel_elmt.update(disabled = not is_multichannel)
108
- do_nucleus_3D_elmt.update(disabled = not is_3D)
109
- do_cytoplasm_3D_elmt.update(disabled = not is_3D)
101
+ for object_key in ["cytoplasm", "nucleus"] :
102
+ segmentation_event_dict[object_key + "_channel"].update(disabled = not is_multichannel)
103
+ if segmentation_event_dict[object_key + "_radio_2D_seg"].get() :
104
+ for elmnt in segmentation_event_dict[object_key + "_radio_2D"] : elmnt.update(disabled= False)
105
+ for elmnt in segmentation_event_dict[object_key + "_radio_3D"] : elmnt.update(disabled= True)
106
+ else :
107
+ for elmnt in segmentation_event_dict[object_key + "_radio_2D"] : elmnt.update(disabled= True)
108
+ for elmnt in segmentation_event_dict[object_key + "_radio_3D"] : elmnt.update(disabled= False)
109
+
110
+ if segmentation_event_dict["segment_only_nuclei"].get() :
111
+ segmentation_event_dict["cytoplasm_column"].update(visible=False)
112
+ else :
113
+ segmentation_event_dict["cytoplasm_column"].update(visible=True)
114
+
110
115
  segmentation_correct_text.update(visible= do_segmentation)
111
116
 
112
117
  tab_elmt.update(visible=is_mapping_ok and do_segmentation)
@@ -132,6 +137,14 @@ def update_map_tab(
132
137
  automap_element.update(disabled=type(last_shape) == type(None))
133
138
  apply_element.update(disabled=type(last_shape) == type(None))
134
139
 
140
+ def update_background_removing_tab(
141
+ background_removing_tab : sg.Tab,
142
+ event_dict : dict,
143
+ is_multichanel : bool,
144
+ channel_number : None | int
145
+ ) :
146
+ background_removing_tab.update(visible= is_multichanel, disabled= not is_multichanel)
147
+
135
148
  def update_output_tab(
136
149
  tab_elmt : sg.Tab,
137
150
  do_segmentation,
@@ -24,7 +24,7 @@ def call_auto_map(
24
24
  map_ = _auto_map_channels(
25
25
  is_3D_stack=is_3D,
26
26
  is_time_stack=False,
27
- multichannel=is_multichannel,
27
+ is_multichannel=is_multichannel,
28
28
  image=None,
29
29
  shape=shape
30
30
  )
@@ -14,6 +14,7 @@ from .prompts import ask_cancel_detection
14
14
  from .prompts import ask_cancel_segmentation
15
15
  from .prompts import ask_detection_confirmation
16
16
  from .prompts import prompt_restore_main_menu
17
+ from .prompts import segmentation_prompt
17
18
 
18
19
  #Helpers to build windows
19
20
  from .layout import parameters_layout