batoolset 0.1.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.
Files changed (162) hide show
  1. batoolset/GUI/__init__.py +0 -0
  2. batoolset/GUI/list_gui.py +513 -0
  3. batoolset/GUI/multi_image_display.py +989 -0
  4. batoolset/GUI/open.py +325 -0
  5. batoolset/GUI/overlay_hints.py +45 -0
  6. batoolset/GUI/paint2.py +1345 -0
  7. batoolset/GUI/scrollablepaint.py +1152 -0
  8. batoolset/IJ_ROIs/__init__.py +0 -0
  9. batoolset/IJ_ROIs/tools.py +40 -0
  10. batoolset/PATH/__init__.py +0 -0
  11. batoolset/PATH/tools.py +79 -0
  12. batoolset/SQLite_tools/__init__.py +0 -0
  13. batoolset/SQLite_tools/tools.py +840 -0
  14. batoolset/__init__.py +0 -0
  15. batoolset/binary/__init__.py +0 -0
  16. batoolset/binary/tools.py +123 -0
  17. batoolset/binarytools/__init__.py +0 -0
  18. batoolset/binarytools/cell_center_detector.py +290 -0
  19. batoolset/clipboard_tools/__init__.py +0 -0
  20. batoolset/clipboard_tools/tools.py +7 -0
  21. batoolset/colors/__init__.py +0 -0
  22. batoolset/colors/colorgen.py +193 -0
  23. batoolset/colors/tools.py +22 -0
  24. batoolset/command_line/__init__.py +0 -0
  25. batoolset/command_line/tools.py +18 -0
  26. batoolset/dialogs/__init__.py +0 -0
  27. batoolset/dialogs/opensave.py +228 -0
  28. batoolset/dicts/__init__.py +0 -0
  29. batoolset/dicts/tools.py +299 -0
  30. batoolset/dims/__init__.py +0 -0
  31. batoolset/dims/tools.py +83 -0
  32. batoolset/draw/__init__.py +0 -0
  33. batoolset/draw/shapes/Position.py +183 -0
  34. batoolset/draw/shapes/__init__.py +0 -0
  35. batoolset/draw/shapes/automated_alignment_drawing_refactored.py +346 -0
  36. batoolset/draw/shapes/circle2d.py +99 -0
  37. batoolset/draw/shapes/compute_optimal_size_all_merged.py +317 -0
  38. batoolset/draw/shapes/ellipse2d.py +336 -0
  39. batoolset/draw/shapes/freehand2d.py +235 -0
  40. batoolset/draw/shapes/group.py +1830 -0
  41. batoolset/draw/shapes/image2d.py +2469 -0
  42. batoolset/draw/shapes/line2d.py +575 -0
  43. batoolset/draw/shapes/point2d.py +257 -0
  44. batoolset/draw/shapes/polygon2d.py +357 -0
  45. batoolset/draw/shapes/polyline2d.py +235 -0
  46. batoolset/draw/shapes/rect2d.py +388 -0
  47. batoolset/draw/shapes/rectangle2d.py +601 -0
  48. batoolset/draw/shapes/scalebar.py +304 -0
  49. batoolset/draw/shapes/serializablefont.py +126 -0
  50. batoolset/draw/shapes/serializableguiparams.py +10 -0
  51. batoolset/draw/shapes/square2d.py +103 -0
  52. batoolset/draw/shapes/textorientation.py +45 -0
  53. batoolset/draw/shapes/tools.py +467 -0
  54. batoolset/draw/shapes/transform2D.py +350 -0
  55. batoolset/draw/shapes/txt2d.py +550 -0
  56. batoolset/draw/widgets/__init__.py +0 -0
  57. batoolset/draw/widgets/col.py +343 -0
  58. batoolset/draw/widgets/image_group.py +248 -0
  59. batoolset/draw/widgets/image_organizer.py +96 -0
  60. batoolset/draw/widgets/paint.py +184 -0
  61. batoolset/draw/widgets/vectorial.py +257 -0
  62. batoolset/figure/__init__.py +0 -0
  63. batoolset/figure/alignment.py +814 -0
  64. batoolset/figure/column.py +1117 -0
  65. batoolset/figure/fig_tools.py +285 -0
  66. batoolset/figure/minimal_debugger_scale_etc.py +139 -0
  67. batoolset/figure/panel.py +697 -0
  68. batoolset/figure/row.py +852 -0
  69. batoolset/figure/user_selection.py +287 -0
  70. batoolset/files/__init__.py +0 -0
  71. batoolset/files/tools.py +1321 -0
  72. batoolset/images/__init__.py +0 -0
  73. batoolset/images/tools.py +81 -0
  74. batoolset/img.py +5216 -0
  75. batoolset/linux/__init__.py +0 -0
  76. batoolset/linux/tools.py +72 -0
  77. batoolset/lists/__init__.py +0 -0
  78. batoolset/lists/tools.py +436 -0
  79. batoolset/luts/__init__.py +0 -0
  80. batoolset/luts/lut_minimal_test.py +1207 -0
  81. batoolset/matplolib/__init__.py +0 -0
  82. batoolset/matplolib/tools.py +44 -0
  83. batoolset/np_tools/__init__.py +0 -0
  84. batoolset/np_tools/tools.py +252 -0
  85. batoolset/np_tools/trash.py +15 -0
  86. batoolset/pandas_tools/__init__.py +0 -0
  87. batoolset/pandas_tools/tools.py +880 -0
  88. batoolset/partials/__init__.py +0 -0
  89. batoolset/partials/tools.py +83 -0
  90. batoolset/plot_tools/__init__.py +0 -0
  91. batoolset/plot_tools/tools.py +70 -0
  92. batoolset/pyqt/__init__.py +0 -0
  93. batoolset/pyqt/tools.py +691 -0
  94. batoolset/re_tools/__init__.py +0 -0
  95. batoolset/re_tools/tools.py +35 -0
  96. batoolset/serialization/__init__.py +0 -0
  97. batoolset/serialization/tools.py +1192 -0
  98. batoolset/sets/__init__.py +0 -0
  99. batoolset/sets/tools.py +109 -0
  100. batoolset/settings/__init__.py +0 -0
  101. batoolset/settings/global_settings.py +134 -0
  102. batoolset/strings/__init__.py +0 -0
  103. batoolset/strings/tools.py +225 -0
  104. batoolset/ta/__init__.py +0 -0
  105. batoolset/ta/database/__init__.py +0 -0
  106. batoolset/ta/database/advanced_sql_plotter.py +1170 -0
  107. batoolset/ta/database/my_qt_table.py +79 -0
  108. batoolset/ta/database/preview_and_edit_sqlite_db.py +405 -0
  109. batoolset/ta/database/sql.py +2141 -0
  110. batoolset/ta/database/sql_column_name_dialog.py +122 -0
  111. batoolset/ta/measurements/TAmeasures.py +2226 -0
  112. batoolset/ta/measurements/__init__.py +0 -0
  113. batoolset/ta/measurements/measurements3D/__init__.py +0 -0
  114. batoolset/ta/measurements/measurements3D/get_point_on_surface_if_centroid_is_bad.py +175 -0
  115. batoolset/ta/measurements/measurements3D/height_map_to_projection.py +82 -0
  116. batoolset/ta/measurements/measurements3D/measures3D.py +208 -0
  117. batoolset/ta/measurements/measurements3D/triangulate.py +331 -0
  118. batoolset/ta/measurements/nematic.py +562 -0
  119. batoolset/ta/measurements/nematic_measurements.py +107 -0
  120. batoolset/ta/segmentation/__init__.py +0 -0
  121. batoolset/ta/segmentation/neo_wshed.py +314 -0
  122. batoolset/ta/selections/__init__.py +0 -0
  123. batoolset/ta/selections/selection.py +329 -0
  124. batoolset/ta/tracking/__init__.py +0 -0
  125. batoolset/ta/tracking/last_tracking_based_on_matching_or_on_translation_from_mermaid_warp.py +653 -0
  126. batoolset/ta/tracking/local_to_track_correspondance.py +138 -0
  127. batoolset/ta/tracking/rapid_detection_of_vertices.py +517 -0
  128. batoolset/ta/tracking/registration.py +108 -0
  129. batoolset/ta/tracking/swap_detector_and_fixer.py +296 -0
  130. batoolset/ta/tracking/track_correction.py +238 -0
  131. batoolset/ta/tracking/tracking_error_detector_and_fixer.py +3099 -0
  132. batoolset/ta/tracking/tracking_yet_another_approach_pyramidal_registration_n_neo_swapping_correction.py +725 -0
  133. batoolset/ta/utils/TA_tools.py +43 -0
  134. batoolset/ta/utils/__init__.py +0 -0
  135. batoolset/ta/utils/rps_tools.py +1783 -0
  136. batoolset/tests/__init__.py +0 -0
  137. batoolset/tests/rps_tools.py +51 -0
  138. batoolset/tests/tools.py +10 -0
  139. batoolset/tools/__init__.py +0 -0
  140. batoolset/tools/early_stopper_class.py +9 -0
  141. batoolset/tools/guided_data_recoverer.py +110 -0
  142. batoolset/tools/logger.py +100 -0
  143. batoolset/tools/mytimer.py +31 -0
  144. batoolset/tools/prompt_color.py +160 -0
  145. batoolset/tools/qthandler.py +118 -0
  146. batoolset/uitools/__init__.py +0 -0
  147. batoolset/uitools/blinker.py +56 -0
  148. batoolset/unsafe/__init__.py +0 -0
  149. batoolset/unsafe/tools.py +115 -0
  150. batoolset/utils/__init__.py +0 -0
  151. batoolset/utils/commontools.py +158 -0
  152. batoolset/utils/loadlist.py +728 -0
  153. batoolset/version.py +10 -0
  154. batoolset/xml/__init__.py +0 -0
  155. batoolset/xml/tools.py +65 -0
  156. batoolset/zip_tools/__init__.py +0 -0
  157. batoolset/zip_tools/tools.py +76 -0
  158. batoolset-0.1.0.dist-info/LICENSE +24 -0
  159. batoolset-0.1.0.dist-info/METADATA +45 -0
  160. batoolset-0.1.0.dist-info/RECORD +162 -0
  161. batoolset-0.1.0.dist-info/WHEEL +5 -0
  162. batoolset-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,115 @@
1
+ from batoolset.settings.global_settings import set_UI # set the UI to qtpy
2
+ set_UI()
3
+ import sys
4
+ from qtpy.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget, QPushButton, QTextEdit, QLabel, QMessageBox
5
+ from batoolset.img import Img
6
+
7
+ def execute_code(code, parent=None):
8
+ # code = self.code_editor.toPlainText()
9
+
10
+ # Display a warning dialog before executing the code
11
+ warning_dialog = QMessageBox(parent=parent)
12
+ warning_dialog.setWindowTitle("Warning")
13
+ warning_dialog.setText("Executing arbitrary code can be dangerous.\nAre you sure you want to proceed?")
14
+ warning_dialog.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
15
+ warning_dialog.setDefaultButton(QMessageBox.No)
16
+ warning_dialog.setIcon(QMessageBox.Warning)
17
+
18
+ # Execute the code if the user clicks "Yes"
19
+ if warning_dialog.exec_() == QMessageBox.Yes:
20
+ param = 10
21
+ text = 'this is a test of your system'
22
+ # print('before', locals())
23
+
24
+ # local_namespace = {"param": param, "text": text, "img": img}
25
+ local_namespace = {}
26
+
27
+ # current_locals = locals()
28
+ try:
29
+ exec(code, locals(), local_namespace)
30
+ # exec(code, current_locals, local_namespace)
31
+ # img = local_namespace["img"]
32
+
33
+ """
34
+ example of calling the stuff
35
+
36
+ # img=img[...,0]
37
+ # text='tutu'
38
+ # param+=6
39
+ self.img=self.img[...,0]
40
+ text='tutu'
41
+ param+=6
42
+ """
43
+
44
+ # only allow very few number of variables to be edited -−> TODO
45
+ if False:
46
+ if False: # below it gets all the variables that may cause trouble
47
+ # Update the local variables from the local namespace from the code (there are advantages to that but it may also cause problems)
48
+ for var_name, var_value in local_namespace.items():
49
+ if var_name in locals() and locals()[var_name] != var_value:
50
+ locals()[var_name] = var_value
51
+ else:
52
+ # a slightly better version that excludes local variables with _
53
+ for var_name, var_value in local_namespace.items():
54
+ if not var_name.startswith("_") and var_name in locals() and locals()[var_name] != var_value:
55
+ locals()[var_name] = var_value
56
+ # globals()[var_name] = var_value
57
+
58
+ # print('after', locals())
59
+ #
60
+ # if 'text' in local_namespace:
61
+ # text = local_namespace['text']
62
+ # if 'param' in local_namespace:
63
+ # param = local_namespace['param']
64
+ # if 'self.img' in local_namespace: # that works also with self --> do this specifically for the image stuff
65
+ # self.img = local_namespace['self.img']
66
+ #
67
+ # # print("Result:", img.shape) # Print the result in console for demonstration
68
+ # print("Result: text", text) # Print the result in console for demonstration
69
+ # print("Result: param", param)
70
+ # print("Result: self.img", self.img.shape)
71
+ # print("Result:", param)
72
+
73
+ # print("Result:", img.shape) # Print the result in console for demonstration
74
+ except Exception as e:
75
+ print("Error:", e)
76
+
77
+
78
+ class CodeExecutorWindow(QMainWindow):
79
+ def __init__(self):
80
+ super().__init__()
81
+ self.setWindowTitle("Code Executor")
82
+ self.setGeometry(100, 100, 600, 400)
83
+
84
+ central_widget = QWidget()
85
+ self.setCentralWidget(central_widget)
86
+
87
+ layout = QVBoxLayout(central_widget)
88
+
89
+ self.code_editor = QTextEdit()
90
+ layout.addWidget(self.code_editor)
91
+
92
+ execute_button = QPushButton("Execute")
93
+ execute_button.clicked.connect(lambda: execute_code(self.code_editor.toPlainText(), self))
94
+ layout.addWidget(execute_button)
95
+
96
+ self.warning_label = QLabel("Warning: Executing arbitrary code can be dangerous. Only rely on trusted sources.")
97
+ self.warning_label.setStyleSheet("color: red")
98
+ layout.addWidget(self.warning_label)
99
+
100
+ self.img = Img('/E/Sample_images/sample_images_PA/mini_vide/focused_Series012.png') # that works and it is really cool
101
+ # shall I take a user edited result instead and keep the original --> in a way yes be cause this is the only way to preseve the integrity of the images --> think of that --> I really need to think
102
+ # but then I cannot share the images between all objects --> anyway this is not smart if they can be edited -->
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+ if __name__ == "__main__":
112
+ app = QApplication(sys.argv)
113
+ window = CodeExecutorWindow()
114
+ window.show()
115
+ sys.exit(app.exec_())
File without changes
@@ -0,0 +1,158 @@
1
+ import functools
2
+ import sys
3
+
4
+ def get_python_version():
5
+ """
6
+ Returns the Python version.
7
+
8
+ Returns:
9
+ str: The Python version.
10
+
11
+ # Examples:
12
+ # >>> get_python_version()
13
+ # '3.7.6'
14
+ """
15
+ return sys.version
16
+
17
+ def get_version_infos():
18
+ """
19
+ Returns the version information of the Python interpreter.
20
+
21
+ Returns:
22
+ sys.version_info: Version information as a named tuple.
23
+
24
+ # Examples:
25
+ # >>> get_version_infos()
26
+ # sys.version_info(major=3, minor=7, micro=6, releaselevel='final', serial=0)
27
+ """
28
+ return sys.version_info
29
+
30
+ def get_path_to_python_executable():
31
+ """
32
+ Returns the path to the Python executable.
33
+
34
+ Returns:
35
+ str: Path to the Python executable.
36
+
37
+ # Examples:
38
+ # >>> get_path_to_python_executable()
39
+ # '/usr/local/bin/python3.7'
40
+ """
41
+ return sys.executable
42
+
43
+
44
+ # the cost to keep this is too high as it forces the import of tf which is not good
45
+ # def get_tensorflow_version():
46
+ # """
47
+ # Returns the version of TensorFlow installed.
48
+ #
49
+ # Returns:
50
+ # str: TensorFlow version.
51
+ #
52
+ # # Examples:
53
+ # # >>> get_tensorflow_version()
54
+ # # '2.6.5'
55
+ # """
56
+ # import tensorflow as tf
57
+ # return tf.__version__
58
+
59
+ def execute_chained_functions(function_to_chain_iterable, parameter, reverse=False):
60
+ """
61
+ Executes a chain of functions on a parameter.
62
+
63
+ Args:
64
+ function_to_chain_iterable (iterable): Iterable containing the functions to chain.
65
+ parameter: The parameter to be processed by the chained functions.
66
+ reverse (bool, optional): Specifies whether to reverse the order of the functions in the chain. Defaults to False.
67
+
68
+ Returns:
69
+ The result of applying the chained functions on the parameter.
70
+
71
+ Examples:
72
+ >>> def add_two(x):
73
+ ... return x + 2
74
+ ...
75
+ >>> def multiply_by_three(x):
76
+ ... return x * 3
77
+ ...
78
+ >>> def subtract_one(x):
79
+ ... return x - 1
80
+ ...
81
+ >>> functions = [add_two, multiply_by_three, subtract_one]
82
+ >>> execute_chained_functions(functions, 5)
83
+ 20
84
+ >>> execute_chained_functions(functions, 5, reverse=True)
85
+ 14
86
+ """
87
+ result = functools.reduce(lambda fn, f: f(fn), reversed(function_to_chain_iterable) if reverse else function_to_chain_iterable, parameter)
88
+ return result
89
+
90
+ def execute_chained_functions_and_save_as_tiff(parameter, function_to_chain_iterable=None, output_file_name=None, reverse=False):
91
+ """
92
+ Executes a chain of functions on a parameter and saves the result as a TIFF image.
93
+
94
+ Args:
95
+ parameter: The parameter to be processed by the chained functions.
96
+ function_to_chain_iterable (iterable, optional): Iterable containing the functions to chain. Defaults to None.
97
+ output_file_name (callable, optional): A callable that returns the output file name based on the parameter. Defaults to None.
98
+ reverse (bool, optional): Specifies whether to reverse the order of the functions in the chain. Defaults to False.
99
+
100
+ """
101
+ result = execute_chained_functions(function_to_chain_iterable=function_to_chain_iterable, parameter=parameter, reverse=False)
102
+ save_as_tiff(result, output_name=output_file_name(parameter))
103
+
104
+
105
+ if __name__ == '__main__':
106
+ if True:
107
+ print("Python version")
108
+ print(get_python_version())
109
+ print("Version info")
110
+ print(get_version_infos())
111
+ print("Executable")
112
+ print(get_path_to_python_executable())
113
+ # print('tf')
114
+ # print(get_tensorflow_version())
115
+
116
+
117
+ # --> cool so all will be easy with this stuff
118
+ if True:
119
+ '''SINGLE IMAGE VERSION BELOW'''
120
+ # quick and rapid code to chain output of fucntions --> really useful --> I really love it
121
+
122
+ from functools import partial
123
+ from batoolset.img import save_as_tiff, Img, elastic_deform, invert
124
+ from batoolset.files.tools import smart_name_parser
125
+ from batoolset.utils.loadlist import list_processor, loadlist
126
+
127
+ img_path = '/E/Sample_images/wings/adult_wings/N01_YwrGal4_males_wing0_projected.png'
128
+ save = partial(save_as_tiff, output_name=smart_name_parser(
129
+ '/E/Sample_images/wings/adult_wings/N01_YwrGal4_males_wing0_projected_inverted.tif', 'full_no_ext') + '.tif')
130
+
131
+ chained_functions = [Img, invert, elastic_deform, save]
132
+ print('chained functions', chained_functions)
133
+ execute_chained_functions(chained_functions, img_path) # load image invert it and save it
134
+
135
+ if True:
136
+ ''' MT VERSION BELOW '''
137
+ from functools import partial
138
+ from batoolset.img import save_as_tiff, Img
139
+ from batoolset.files.tools import smart_name_parser
140
+ from batoolset.utils.loadlist import list_processor, loadlist
141
+
142
+
143
+ # see if I can MT that
144
+ lst = loadlist('/E/Sample_images/sample_images_PA/mini_empty/list.lst')
145
+ def output_file_name(input_file_name):
146
+ return smart_name_parser(
147
+ input_file_name, 'full_no_ext') + 'inverted2.tif'
148
+
149
+
150
+ chained_functions = [Img, invert, elastic_deform]
151
+
152
+ list_processor(lst=lst, processing_fn=chained_functions, multithreading=True, use_save_execution_if_chained=True,progress_callback=None, name_processor_function_for_saving=output_file_name)
153
+
154
+ import sys
155
+ sys.exit(0)
156
+
157
+ # very good for all
158
+ # all is ok