cellects 0.1.0.dev1__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 (46) hide show
  1. cellects/__init__.py +0 -0
  2. cellects/__main__.py +49 -0
  3. cellects/config/__init__.py +0 -0
  4. cellects/config/all_vars_dict.py +154 -0
  5. cellects/core/__init__.py +0 -0
  6. cellects/core/cellects_paths.py +30 -0
  7. cellects/core/cellects_threads.py +1464 -0
  8. cellects/core/motion_analysis.py +1931 -0
  9. cellects/core/one_image_analysis.py +1065 -0
  10. cellects/core/one_video_per_blob.py +679 -0
  11. cellects/core/program_organizer.py +1347 -0
  12. cellects/core/script_based_run.py +154 -0
  13. cellects/gui/__init__.py +0 -0
  14. cellects/gui/advanced_parameters.py +1258 -0
  15. cellects/gui/cellects.py +189 -0
  16. cellects/gui/custom_widgets.py +789 -0
  17. cellects/gui/first_window.py +449 -0
  18. cellects/gui/if_several_folders_window.py +239 -0
  19. cellects/gui/image_analysis_window.py +1909 -0
  20. cellects/gui/required_output.py +232 -0
  21. cellects/gui/video_analysis_window.py +656 -0
  22. cellects/icons/__init__.py +0 -0
  23. cellects/icons/cellects_icon.icns +0 -0
  24. cellects/icons/cellects_icon.ico +0 -0
  25. cellects/image_analysis/__init__.py +0 -0
  26. cellects/image_analysis/cell_leaving_detection.py +54 -0
  27. cellects/image_analysis/cluster_flux_study.py +102 -0
  28. cellects/image_analysis/extract_exif.py +61 -0
  29. cellects/image_analysis/fractal_analysis.py +184 -0
  30. cellects/image_analysis/fractal_functions.py +108 -0
  31. cellects/image_analysis/image_segmentation.py +272 -0
  32. cellects/image_analysis/morphological_operations.py +867 -0
  33. cellects/image_analysis/network_functions.py +1244 -0
  34. cellects/image_analysis/one_image_analysis_threads.py +289 -0
  35. cellects/image_analysis/progressively_add_distant_shapes.py +246 -0
  36. cellects/image_analysis/shape_descriptors.py +981 -0
  37. cellects/utils/__init__.py +0 -0
  38. cellects/utils/formulas.py +881 -0
  39. cellects/utils/load_display_save.py +1016 -0
  40. cellects/utils/utilitarian.py +516 -0
  41. cellects-0.1.0.dev1.dist-info/LICENSE.odt +0 -0
  42. cellects-0.1.0.dev1.dist-info/METADATA +131 -0
  43. cellects-0.1.0.dev1.dist-info/RECORD +46 -0
  44. cellects-0.1.0.dev1.dist-info/WHEEL +5 -0
  45. cellects-0.1.0.dev1.dist-info/entry_points.txt +2 -0
  46. cellects-0.1.0.dev1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,154 @@
1
+ #!/usr/bin/env python3
2
+ """This file contains lines to run Cellects without user interface"""
3
+
4
+ import logging
5
+ import os
6
+ from pathlib import Path
7
+ import numpy as np
8
+ import pandas as pd
9
+ import cv2
10
+ from cellects.core.program_organizer import ProgramOrganizer
11
+ from cellects.utils.utilitarian import insensitive_glob
12
+ from cellects.core.one_video_per_blob import OneVideoPerBlob
13
+ from cellects.core.motion_analysis import MotionAnalysis
14
+ from cellects.config.all_vars_dict import DefaultDicts
15
+ from cellects.utils.load_display_save import show
16
+
17
+
18
+ def load_one_folder(pathway, sample_number):
19
+ po = ProgramOrganizer()
20
+ po.load_variable_dict()
21
+ # dd = DefaultDicts()
22
+ # po.all = dd.all
23
+ # po.vars = dd.vars
24
+ po.all['global_pathway'] = pathway
25
+ po.all['first_folder_sample_number'] = sample_number
26
+ # po.all['first_folder_sample_number'] = 6
27
+ # po.all['radical'] = "IMG"
28
+ # po.all['extension'] = ".jpg"
29
+ # po.all['im_or_vid'] = 0
30
+ po.look_for_data()
31
+ po.load_data_to_run_cellects_quickly()
32
+ return po
33
+
34
+ def run_image_analysis(po):
35
+ if not po.first_exp_ready_to_run:
36
+ po.get_first_image()
37
+ po.fast_image_segmentation(True)
38
+ # po.first_image.find_first_im_csc(sample_number=po.sample_number,
39
+ # several_blob_per_arena=None,
40
+ # spot_shape=None, spot_size=None,
41
+ # kmeans_clust_nb=2,
42
+ # biomask=None, backmask=None,
43
+ # color_space_dictionaries=None,
44
+ # carefully=True)
45
+ po.cropping(is_first_image=True)
46
+ po.get_average_pixel_size()
47
+ po.delineate_each_arena()
48
+ po.get_background_to_subtract()
49
+ po.get_origins_and_backgrounds_lists()
50
+ po.get_last_image()
51
+ po.fast_image_segmentation(is_first_image=False)
52
+ po.find_if_lighter_background()
53
+ po.extract_exif()
54
+ else:
55
+ print('Image analysis already done, run video analysis')
56
+ return po
57
+
58
+
59
+ def write_videos(po):
60
+ po.update_output_list()
61
+ look_for_existing_videos = insensitive_glob('ind_' + '*' + '.npy')
62
+ there_already_are_videos = len(look_for_existing_videos) == len(po.vars['analyzed_individuals'])
63
+ logging.info(
64
+ f"{len(look_for_existing_videos)} .npy video files found for {len(po.vars['analyzed_individuals'])} arenas to analyze")
65
+ do_write_videos = not there_already_are_videos or (
66
+ there_already_are_videos and po.all['overwrite_unaltered_videos'])
67
+ if do_write_videos:
68
+ po.videos = OneVideoPerBlob(po.first_image, po.starting_blob_hsize_in_pixels, po.all['raw_images'])
69
+ po.videos.left = po.left
70
+ po.videos.right = po.right
71
+ po.videos.top = po.top
72
+ po.videos.bot = po.bot
73
+ po.videos.first_image.shape_number = po.sample_number
74
+ po.videos.write_videos_as_np_arrays(
75
+ po.data_list, po.vars['min_ram_free'], not po.vars['already_greyscale'], po.reduce_image_dim)
76
+ po.instantiate_tables()
77
+ return po
78
+
79
+
80
+ def run_one_video_analysis(po):
81
+ i=0
82
+ show_seg= False
83
+ # if os.path.isfile(f"coord_specimen{i + 1}_t720_y1475_x1477.npy"):
84
+ # binary_coord = np.load(f"coord_specimen{i + 1}_t720_y1475_x1477.npy")
85
+ # l = [i, i + 1, po.vars, False, False, show_seg, None]
86
+ # MA = MotionAnalysis(l)
87
+ # MA.binary = np.zeros((720, 1475, 1477), dtype=np.uint8)
88
+ # MA.binary[binary_coord[0, :], binary_coord[1, :], binary_coord[2, :]] = 1
89
+ # else:
90
+ l = [i, i + 1, po.vars, True, False, show_seg, None]
91
+ MA = MotionAnalysis(l)
92
+ MA.get_descriptors_from_binary()
93
+ MA.detect_growth_transitions()
94
+ MA.networks_detection(show_seg)
95
+ MA.study_cytoscillations(show_seg)
96
+ return MA
97
+
98
+
99
+ def run_all_arenas(po):
100
+ po.instantiate_tables()
101
+ for i, arena in enumerate(po.vars['analyzed_individuals']):
102
+ l = [i, arena, po.vars, True, True, False, None]
103
+ analysis_i = MotionAnalysis(l)
104
+ po.add_analysis_visualization_to_first_and_last_images(i, analysis_i.efficiency_test_1,
105
+ analysis_i.efficiency_test_2)
106
+ if not po.vars['several_blob_per_arena']:
107
+ # Save basic statistics
108
+ po.update_one_row_per_arena(i, analysis_i.one_descriptor_per_arena)
109
+
110
+ # Save descriptors in long_format
111
+ po.update_one_row_per_frame(i * po.vars['img_number'],
112
+ arena * po.vars['img_number'],
113
+ analysis_i.one_row_per_frame)
114
+ # Save cytosol_oscillations
115
+ if not pd.isna(analysis_i.one_descriptor_per_arena["first_move"]):
116
+ if po.vars['oscilacyto_analysis']:
117
+ oscil_i = pd.DataFrame(
118
+ np.c_[np.repeat(arena,
119
+ analysis_i.clusters_final_data.shape[0]), analysis_i.clusters_final_data],
120
+ columns=['arena', 'mean_pixel_period', 'phase', 'cluster_size', 'edge_distance', 'coord_y',
121
+ 'coord_x'])
122
+ if po.one_row_per_oscillating_cluster is None:
123
+ po.one_row_per_oscillating_cluster = oscil_i
124
+ else:
125
+ po.one_row_per_oscillating_cluster = pd.concat((po.one_row_per_oscillating_cluster, oscil_i))
126
+ po.save_tables()
127
+ cv2.imwrite(f"Analysis efficiency, last image.jpg", po.last_image.bgr)
128
+ cv2.imwrite(f"Analysis efficiency, {np.ceil(po.vars['img_number'] / 10).astype(np.uint64)}th image.jpg",
129
+ po.first_image.bgr)
130
+
131
+
132
+
133
+ if __name__ == "__main__":
134
+ po = load_one_folder(Path("/data/experiment"), 1)
135
+ po = run_image_analysis(po)
136
+ po = write_videos(po)
137
+ # MA = run_one_video_analysis(po)
138
+ run_all_arenas(po)
139
+
140
+ # MA.one_row_per_frame.to_csv(
141
+ # "/Users/Directory/Scripts/python/Cellects/tests/data/experiment/motion_analysis_thresh.csv")
142
+
143
+ # path = Path("/Users/Directory/Scripts/python/Cellects/tests/data/experiment")
144
+ # po.load_variable_dict()
145
+ # run_image_analysis(po)
146
+ # os.chdir(path)
147
+ # from glob import glob
148
+ # from cellects.utils.load_display_save import readim
149
+ # im_names = np.sort(glob("*.JPG"))
150
+ # for i, im_name in enumerate(im_names): # im_name = im_names[-1]
151
+ # im = readim(im_name)
152
+ # cv2.imwrite(f"image{i + 1}.tif", im[2925:3170, 1200:1500, :])
153
+ #
154
+ # show(im[2925:3170,1200:1500, :])
File without changes