mlgidGUI 0.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.
- mlgidGUI/__init__.py +52 -0
- mlgidGUI/__main__.py +7 -0
- mlgidGUI/__version.py +1 -0
- mlgidGUI/app/__init__.py +8 -0
- mlgidGUI/app/actions_stack.py +1 -0
- mlgidGUI/app/app.py +67 -0
- mlgidGUI/app/cif_rois/__init__.py +0 -0
- mlgidGUI/app/cif_rois/cif_peaks_calculation.py +57 -0
- mlgidGUI/app/cif_rois/cif_simulation/__init__.py +0 -0
- mlgidGUI/app/cif_rois/cif_simulation/data/__init__.py +0 -0
- mlgidGUI/app/cif_rois/cif_simulation/data/atoms.py +15 -0
- mlgidGUI/app/cif_rois/cif_simulation/data/export_database.py +28 -0
- mlgidGUI/app/cif_rois/cif_simulation/experiment.py +57 -0
- mlgidGUI/app/cif_rois/cif_simulation/giwaxs_sim.py +286 -0
- mlgidGUI/app/cif_rois/cif_simulation/int_sim.py +105 -0
- mlgidGUI/app/cif_rois/cif_simulation/possible_directions.py +20 -0
- mlgidGUI/app/cif_rois/cif_simulation/q_sim.py +159 -0
- mlgidGUI/app/data_manager/__init__.py +4 -0
- mlgidGUI/app/data_manager/data_manager.py +164 -0
- mlgidGUI/app/data_manager/import_from_h5.py +68 -0
- mlgidGUI/app/data_manager/load_data.py +78 -0
- mlgidGUI/app/data_manager/pascal/__init__.py +2 -0
- mlgidGUI/app/data_manager/pascal/annotation_fabric.py +59 -0
- mlgidGUI/app/data_manager/pascal/draw_objects.py +119 -0
- mlgidGUI/app/data_manager/pascal/exceptions.py +6 -0
- mlgidGUI/app/data_manager/pascal/format_convertor.py +127 -0
- mlgidGUI/app/data_manager/pascal/pascal_annotation.py +85 -0
- mlgidGUI/app/data_manager/pascal/protocol_implementations.py +28 -0
- mlgidGUI/app/data_manager/pascal/protocols.py +47 -0
- mlgidGUI/app/data_manager/pascal/utils.py +64 -0
- mlgidGUI/app/data_manager/save_dataset.py +57 -0
- mlgidGUI/app/data_manager/save_h5.py +178 -0
- mlgidGUI/app/data_manager/saving_parameters.py +88 -0
- mlgidGUI/app/debug_tracker.py +129 -0
- mlgidGUI/app/edf_reader.py +135 -0
- mlgidGUI/app/file_manager/__init__.py +201 -0
- mlgidGUI/app/file_manager/config_manager.py +76 -0
- mlgidGUI/app/file_manager/keys.py +542 -0
- mlgidGUI/app/file_manager/npy_file_manager.py +17 -0
- mlgidGUI/app/file_manager/object_file_manager.py +77 -0
- mlgidGUI/app/file_manager/project_structure.py +169 -0
- mlgidGUI/app/file_manager/read_fits.py +76 -0
- mlgidGUI/app/file_manager/read_geometry.py +54 -0
- mlgidGUI/app/file_manager/read_images.py +31 -0
- mlgidGUI/app/file_manager/read_meta_roi.py +40 -0
- mlgidGUI/app/file_manager/read_polar_images.py +22 -0
- mlgidGUI/app/file_manager/read_radial_profile.py +6 -0
- mlgidGUI/app/file_manager/read_roi_data.py +39 -0
- mlgidGUI/app/fitting/__init__.py +5 -0
- mlgidGUI/app/fitting/background.py +92 -0
- mlgidGUI/app/fitting/fit.py +128 -0
- mlgidGUI/app/fitting/fit_holder.py +273 -0
- mlgidGUI/app/fitting/fit_object.py +247 -0
- mlgidGUI/app/fitting/functions.py +107 -0
- mlgidGUI/app/fitting/range_strategy.py +14 -0
- mlgidGUI/app/fitting/utils.py +17 -0
- mlgidGUI/app/geometry.py +236 -0
- mlgidGUI/app/geometry_holder.py +131 -0
- mlgidGUI/app/image_holder.py +200 -0
- mlgidGUI/app/image_processing.py +23 -0
- mlgidGUI/app/polar_image.py +96 -0
- mlgidGUI/app/profiles/__init__.py +5 -0
- mlgidGUI/app/profiles/angular_profile.py +20 -0
- mlgidGUI/app/profiles/basic_profile.py +169 -0
- mlgidGUI/app/profiles/radial_profile.py +38 -0
- mlgidGUI/app/read_image.py +21 -0
- mlgidGUI/app/rois/__init__.py +4 -0
- mlgidGUI/app/rois/new_roi_dict.py +670 -0
- mlgidGUI/app/rois/roi.py +194 -0
- mlgidGUI/app/rois/roi_colors.py +76 -0
- mlgidGUI/app/rois/roi_data.py +177 -0
- mlgidGUI/app/rois/roi_dict.py +466 -0
- mlgidGUI/app/rois/roi_meta_data.py +149 -0
- mlgidGUI/app/structures/__init__.py +6 -0
- mlgidGUI/app/structures/crystal_ring.py +19 -0
- mlgidGUI/app/structures/crystals_holders.py +144 -0
- mlgidGUI/app/structures/custom_crystal.py +45 -0
- mlgidGUI/app/structures/get_ring_list.py +89 -0
- mlgidGUI/app/transformations.py +82 -0
- mlgidGUI/app/update/__init__.py +3 -0
- mlgidGUI/app/update/check_version.py +51 -0
- mlgidGUI/app/update/launch_program.py +15 -0
- mlgidGUI/app/update/script_update.py +64 -0
- mlgidGUI/app/utils.py +124 -0
- mlgidGUI/gui/__init__.py +3 -0
- mlgidGUI/gui/background_tasks.py +41 -0
- mlgidGUI/gui/background_update.py +87 -0
- mlgidGUI/gui/basic_widgets/__init__.py +12 -0
- mlgidGUI/gui/basic_widgets/buttons.py +144 -0
- mlgidGUI/gui/basic_widgets/labels.py +51 -0
- mlgidGUI/gui/basic_widgets/mouse_events.py +119 -0
- mlgidGUI/gui/basic_widgets/path_line.py +162 -0
- mlgidGUI/gui/basic_widgets/plots_1d.py +365 -0
- mlgidGUI/gui/basic_widgets/plots_2d.py +224 -0
- mlgidGUI/gui/basic_widgets/popups.py +164 -0
- mlgidGUI/gui/basic_widgets/progress_bar.py +127 -0
- mlgidGUI/gui/basic_widgets/setup_widgets.py +138 -0
- mlgidGUI/gui/basic_widgets/sliders.py +616 -0
- mlgidGUI/gui/basic_widgets/spinner.py +65 -0
- mlgidGUI/gui/basic_widgets/toolbars.py +19 -0
- mlgidGUI/gui/debug_widgets.py +388 -0
- mlgidGUI/gui/dock_area.py +115 -0
- mlgidGUI/gui/exception_message.py +42 -0
- mlgidGUI/gui/fitting/__init__.py +2 -0
- mlgidGUI/gui/fitting/fit_widget.py +966 -0
- mlgidGUI/gui/fitting/inplace_fit.py +536 -0
- mlgidGUI/gui/fitting/selected_fit_widget.py +286 -0
- mlgidGUI/gui/gui_main.py +349 -0
- mlgidGUI/gui/image_viewer.py +323 -0
- mlgidGUI/gui/init_window.py +170 -0
- mlgidGUI/gui/load_window/__init__.py +2 -0
- mlgidGUI/gui/load_window/load_folder.py +61 -0
- mlgidGUI/gui/load_window/load_h5.py +73 -0
- mlgidGUI/gui/notifications.py +68 -0
- mlgidGUI/gui/polar_image_viewer.py +153 -0
- mlgidGUI/gui/profiles/__init__.py +1 -0
- mlgidGUI/gui/profiles/angular_profile_widget.py +62 -0
- mlgidGUI/gui/profiles/radial_profile_widget.py +164 -0
- mlgidGUI/gui/project_manager/__init__.py +17 -0
- mlgidGUI/gui/project_manager/cif_files_widget.py +196 -0
- mlgidGUI/gui/project_manager/cif_results.py +146 -0
- mlgidGUI/gui/project_manager/metadata_widget.py +15 -0
- mlgidGUI/gui/project_manager/project_viewer.py +151 -0
- mlgidGUI/gui/project_manager/roi_widget.py +171 -0
- mlgidGUI/gui/roi_widgets/__init__.py +6 -0
- mlgidGUI/gui/roi_widgets/abstract_roi_holder.py +189 -0
- mlgidGUI/gui/roi_widgets/abstract_roi_widget.py +111 -0
- mlgidGUI/gui/roi_widgets/cif_file_widget.py +16 -0
- mlgidGUI/gui/roi_widgets/cif_peak_widget.py +43 -0
- mlgidGUI/gui/roi_widgets/confidence_level_widget.py +105 -0
- mlgidGUI/gui/roi_widgets/roi_1d_widget.py +136 -0
- mlgidGUI/gui/roi_widgets/roi_2d_rect_widget.py +98 -0
- mlgidGUI/gui/roi_widgets/roi_2d_ring_widget.py +203 -0
- mlgidGUI/gui/roi_widgets/rois_context_menu.py +150 -0
- mlgidGUI/gui/roi_widgets/select_roi_color_widget.py +58 -0
- mlgidGUI/gui/save_window/__init__.py +152 -0
- mlgidGUI/gui/save_window/format_box.py +33 -0
- mlgidGUI/gui/save_window/num_selected_widget.py +45 -0
- mlgidGUI/gui/save_window/options_widgets.py +105 -0
- mlgidGUI/gui/save_window/save_mode_box.py +30 -0
- mlgidGUI/gui/save_window/select_images.py +198 -0
- mlgidGUI/gui/tools.py +179 -0
- mlgidGUI/static/__init__.py +0 -0
- mlgidGUI/static/icons/__init__.py +0 -0
- mlgidGUI/static/icons/add.png +0 -0
- mlgidGUI/static/icons/add_yellow.png +0 -0
- mlgidGUI/static/icons/angular_profile.png +0 -0
- mlgidGUI/static/icons/arrow.png +0 -0
- mlgidGUI/static/icons/baseline.png +0 -0
- mlgidGUI/static/icons/center.png +0 -0
- mlgidGUI/static/icons/confirm.png +0 -0
- mlgidGUI/static/icons/control_widget.png +0 -0
- mlgidGUI/static/icons/data.png +0 -0
- mlgidGUI/static/icons/delete.png +0 -0
- mlgidGUI/static/icons/delete_yellow.png +0 -0
- mlgidGUI/static/icons/error.png +0 -0
- mlgidGUI/static/icons/find.png +0 -0
- mlgidGUI/static/icons/fit.png +0 -0
- mlgidGUI/static/icons/fix_all.png +0 -0
- mlgidGUI/static/icons/flip_horizontal.png +0 -0
- mlgidGUI/static/icons/flip_vertical.png +0 -0
- mlgidGUI/static/icons/folder.png +0 -0
- mlgidGUI/static/icons/fromfullscreen.png +0 -0
- mlgidGUI/static/icons/h5_folder.png +0 -0
- mlgidGUI/static/icons/h5_group_folder.png +0 -0
- mlgidGUI/static/icons/info.png +0 -0
- mlgidGUI/static/icons/interpolate.png +0 -0
- mlgidGUI/static/icons/item.png +0 -0
- mlgidGUI/static/icons/properties.png +0 -0
- mlgidGUI/static/icons/radial_profile.png +0 -0
- mlgidGUI/static/icons/roi_item.png +0 -0
- mlgidGUI/static/icons/rotate.png +0 -0
- mlgidGUI/static/icons/rotate_image.png +0 -0
- mlgidGUI/static/icons/rotate_right.png +0 -0
- mlgidGUI/static/icons/setup.png +0 -0
- mlgidGUI/static/icons/setup_white.png +0 -0
- mlgidGUI/static/icons/tofullscreen.png +0 -0
- mlgidGUI/static/icons/unfix_all.png +0 -0
- mlgidGUI/static/icons/update.png +0 -0
- mlgidGUI/static/icons/update_suggested.png +0 -0
- mlgidGUI/static/icons/window_icon.png +0 -0
- mlgidGUI/static/icons/window_icon_256.png +0 -0
- mlgidGUI/utils/__init__.py +1 -0
- mlgidGUI/utils/project2h5.py +11 -0
- mlgidgui-0.4.1.dist-info/METADATA +119 -0
- mlgidgui-0.4.1.dist-info/RECORD +202 -0
- mlgidgui-0.4.1.dist-info/WHEEL +5 -0
- mlgidgui-0.4.1.dist-info/entry_points.txt +5 -0
- mlgidgui-0.4.1.dist-info/licenses/LICENSE +674 -0
- mlgidgui-0.4.1.dist-info/top_level.txt +4 -0
- tests/__init__.py +0 -0
- tests/conftest.py +1 -0
- tests/fixures/__init__.py +2 -0
- tests/fixures/projects.py +102 -0
- tests/func/__init__.py +1 -0
- tests/func/test_loading_state.py +21 -0
- tests/func/test_parse_project_data.py +23 -0
- tests/func/test_save.py +62 -0
- tests/unit/__init__.py +0 -0
- tests/unit/rois/__init__.py +0 -0
- tests/unit/rois/test_basic_operations.py +18 -0
- tests/unit/test_add_data.py +33 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from .basic_profile import BasicProfile
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class AngularProfile(BasicProfile):
|
|
7
|
+
|
|
8
|
+
def __init__(self, image_holder, parent=None):
|
|
9
|
+
self.image_holder = image_holder
|
|
10
|
+
super().__init__(parent)
|
|
11
|
+
|
|
12
|
+
def update_data_from_source(self, key: int = None):
|
|
13
|
+
|
|
14
|
+
image_holder = self.image_holder
|
|
15
|
+
profile = image_holder.get_angular_profile(key)
|
|
16
|
+
if profile is None:
|
|
17
|
+
return
|
|
18
|
+
phi_axis = image_holder.geometry.phi_axis
|
|
19
|
+
if phi_axis is not None and phi_axis.size == profile.size:
|
|
20
|
+
self.set_data(profile, phi_axis)
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
import logging
|
|
3
|
+
from typing import Tuple
|
|
4
|
+
from dataclasses import dataclass, asdict
|
|
5
|
+
from abc import abstractmethod
|
|
6
|
+
|
|
7
|
+
import numpy as np
|
|
8
|
+
|
|
9
|
+
from PyQt5.QtCore import pyqtSignal, pyqtSlot, QObject
|
|
10
|
+
|
|
11
|
+
from ..utils import baseline_correction, smooth_curve
|
|
12
|
+
|
|
13
|
+
logger = logging.getLogger(__name__)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@dataclass
|
|
17
|
+
class BaselineParams:
|
|
18
|
+
smoothness: float = 100
|
|
19
|
+
asymmetry: float = 0.01
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@dataclass
|
|
23
|
+
class SavedProfile:
|
|
24
|
+
raw_data: np.ndarray
|
|
25
|
+
x: np.ndarray
|
|
26
|
+
x_range: tuple
|
|
27
|
+
sigma: float
|
|
28
|
+
baseline_params: BaselineParams
|
|
29
|
+
baseline: np.ndarray = None
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class SmoothedProfile(QObject):
|
|
33
|
+
sigSigmaChanged = pyqtSignal()
|
|
34
|
+
|
|
35
|
+
def __init__(self, parent=None):
|
|
36
|
+
super().__init__(parent)
|
|
37
|
+
self._sigma = 0
|
|
38
|
+
self.baseline_params = BaselineParams()
|
|
39
|
+
self.x_range: Tuple[float, float] or None = None
|
|
40
|
+
self._x = self._y = self._raw_y = self._baseline = None
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
def x(self) -> np.ndarray or None:
|
|
44
|
+
return self._x
|
|
45
|
+
|
|
46
|
+
@x.setter
|
|
47
|
+
def x(self, value):
|
|
48
|
+
if value is None:
|
|
49
|
+
return
|
|
50
|
+
if self.y is not None and value.size != self.y.size:
|
|
51
|
+
return
|
|
52
|
+
self._x = value
|
|
53
|
+
|
|
54
|
+
@property
|
|
55
|
+
def y(self) -> np.ndarray or None:
|
|
56
|
+
return self._y
|
|
57
|
+
|
|
58
|
+
@property
|
|
59
|
+
def raw_y(self) -> np.ndarray or None:
|
|
60
|
+
return self._raw_y
|
|
61
|
+
|
|
62
|
+
@property
|
|
63
|
+
def baseline(self) -> np.ndarray or None:
|
|
64
|
+
return self._baseline
|
|
65
|
+
|
|
66
|
+
@property
|
|
67
|
+
def sigma(self) -> float:
|
|
68
|
+
return self._sigma
|
|
69
|
+
|
|
70
|
+
@pyqtSlot(float, name='setSigma')
|
|
71
|
+
def set_sigma(self, sigma: float):
|
|
72
|
+
if sigma <= 0:
|
|
73
|
+
return
|
|
74
|
+
self._sigma = sigma
|
|
75
|
+
self._y = smooth_curve(self._raw_y, self.sigma)
|
|
76
|
+
|
|
77
|
+
def to_save(self) -> SavedProfile:
|
|
78
|
+
return SavedProfile(self.raw_y, self.x, self.x_range, self.sigma, self.baseline_params, self.baseline)
|
|
79
|
+
|
|
80
|
+
def from_save(self, saved_profile: SavedProfile) -> None:
|
|
81
|
+
self.x_range = saved_profile.x_range
|
|
82
|
+
self.set_data(saved_profile.raw_data, saved_profile.x)
|
|
83
|
+
self._baseline = saved_profile.baseline
|
|
84
|
+
self.baseline_params = saved_profile.baseline_params
|
|
85
|
+
self.set_sigma(saved_profile.sigma)
|
|
86
|
+
|
|
87
|
+
def set_parameters(self, smoothness: float, asymmetry: float):
|
|
88
|
+
self.baseline_params.smoothness = smoothness
|
|
89
|
+
self.baseline_params.asymmetry = asymmetry
|
|
90
|
+
|
|
91
|
+
def get_parameters(self) -> dict:
|
|
92
|
+
return asdict(self.baseline_params)
|
|
93
|
+
|
|
94
|
+
def set_data(self, y: np.ndarray, x: np.ndarray):
|
|
95
|
+
self._raw_y = y
|
|
96
|
+
self._y = smooth_curve(self._raw_y, self.sigma)
|
|
97
|
+
self._x = x
|
|
98
|
+
|
|
99
|
+
def update_baseline(self):
|
|
100
|
+
if any(v is None for v in (self.x_range, self.y, self.x)):
|
|
101
|
+
return
|
|
102
|
+
if self.y.size != self.x.size:
|
|
103
|
+
return
|
|
104
|
+
|
|
105
|
+
x1, x2 = self._get_coords()
|
|
106
|
+
|
|
107
|
+
baseline = baseline_correction(
|
|
108
|
+
self._y[x1:x2], self.baseline_params.smoothness, self.baseline_params.asymmetry)
|
|
109
|
+
self._baseline = np.zeros_like(self._y)
|
|
110
|
+
self._baseline[x1:x2] = baseline
|
|
111
|
+
|
|
112
|
+
def clear_baseline(self, clear_range: bool = True):
|
|
113
|
+
self._baseline = None
|
|
114
|
+
if clear_range:
|
|
115
|
+
self.x_range = None
|
|
116
|
+
|
|
117
|
+
def _get_coords(self):
|
|
118
|
+
scale_factor = self.x.size / (np.nanmax(self.x) - np.nanmin(self.x))
|
|
119
|
+
x_min = np.nanmin(self.x)
|
|
120
|
+
min_ind, max_ind = 0, self.x.size
|
|
121
|
+
x1 = int((self.x_range[0] - x_min) * scale_factor)
|
|
122
|
+
x2 = int((self.x_range[1] - x_min) * scale_factor)
|
|
123
|
+
x1 = min((max((x1, min_ind)), max_ind))
|
|
124
|
+
x2 = min((max((x2, min_ind)), max_ind))
|
|
125
|
+
xs = (x1, x2)
|
|
126
|
+
return min(xs), max(xs)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
class BasicProfile(SmoothedProfile):
|
|
130
|
+
sigDataToBeUpdated = pyqtSignal()
|
|
131
|
+
sigDataUpdated = pyqtSignal()
|
|
132
|
+
|
|
133
|
+
def __init__(self, parent=None):
|
|
134
|
+
super().__init__(parent)
|
|
135
|
+
self._is_shown: bool = True
|
|
136
|
+
self._should_update: bool = False
|
|
137
|
+
|
|
138
|
+
@property
|
|
139
|
+
def is_shown(self) -> bool:
|
|
140
|
+
return self._is_shown
|
|
141
|
+
|
|
142
|
+
@is_shown.setter
|
|
143
|
+
def is_shown(self, value: bool):
|
|
144
|
+
if value == self.is_shown:
|
|
145
|
+
return
|
|
146
|
+
self._is_shown = value
|
|
147
|
+
if value and self._should_update:
|
|
148
|
+
self.update_data()
|
|
149
|
+
|
|
150
|
+
def set_show_status(self, value: bool):
|
|
151
|
+
self.is_shown = value
|
|
152
|
+
|
|
153
|
+
def update_data(self, *args, **kwargs):
|
|
154
|
+
self.sigDataToBeUpdated.emit()
|
|
155
|
+
self.clear_baseline()
|
|
156
|
+
self.update_data_from_source(*args, **kwargs)
|
|
157
|
+
self.sigDataUpdated.emit()
|
|
158
|
+
self._should_update = False
|
|
159
|
+
|
|
160
|
+
@abstractmethod
|
|
161
|
+
def update_data_from_source(self, *args, **kwargs):
|
|
162
|
+
pass
|
|
163
|
+
|
|
164
|
+
@pyqtSlot(name='update')
|
|
165
|
+
def update(self):
|
|
166
|
+
if self.is_shown:
|
|
167
|
+
self.update_data()
|
|
168
|
+
else:
|
|
169
|
+
self._should_update = True
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
|
|
4
|
+
import numpy as np
|
|
5
|
+
|
|
6
|
+
from ..file_manager import FileManager, ImageKey
|
|
7
|
+
from .basic_profile import BasicProfile, BaselineParams
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclass
|
|
11
|
+
class SavedProfile:
|
|
12
|
+
data: np.ndarray
|
|
13
|
+
sigma: float
|
|
14
|
+
baseline_params: BaselineParams
|
|
15
|
+
baseline: np.ndarray = None
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class RadialProfile(BasicProfile):
|
|
19
|
+
def __init__(self, image_holder, fm: FileManager, parent=None):
|
|
20
|
+
self.image_holder = image_holder
|
|
21
|
+
self.fm = fm
|
|
22
|
+
self._current_key: ImageKey = None
|
|
23
|
+
super().__init__(parent)
|
|
24
|
+
|
|
25
|
+
def save_state(self):
|
|
26
|
+
if self._current_key and self._raw_y is not None:
|
|
27
|
+
self.fm.profiles[self._current_key] = self.to_save()
|
|
28
|
+
|
|
29
|
+
def update_data_from_source(self):
|
|
30
|
+
# self.save_state()
|
|
31
|
+
|
|
32
|
+
self._current_key = self.image_holder.current_key
|
|
33
|
+
r_axis = self.image_holder.geometry.r_axis
|
|
34
|
+
|
|
35
|
+
if r_axis is None:
|
|
36
|
+
return
|
|
37
|
+
|
|
38
|
+
self.set_data(self.image_holder.get_radial_profile(), r_axis)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from typing import Union
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
import numpy as np
|
|
6
|
+
from PIL import Image
|
|
7
|
+
from .edf_reader import read_edf
|
|
8
|
+
import tifffile
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def read_image(filepath: Union[Path, str]) -> np.array:
|
|
12
|
+
if isinstance(filepath, Path):
|
|
13
|
+
filepath = str(filepath.resolve())
|
|
14
|
+
|
|
15
|
+
if filepath.endswith('.edf') or filepath.endswith('.edf.gz'):
|
|
16
|
+
image = read_edf(filepath)
|
|
17
|
+
else:
|
|
18
|
+
image = tifffile.imread(filepath)
|
|
19
|
+
if len(image.shape) > 2:
|
|
20
|
+
image = np.array(Image.open(filepath).convert('L'))
|
|
21
|
+
return image
|