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
tests/conftest.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from tests.fixures import *
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from typing import List, Dict, Generator
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from dataclasses import dataclass
|
|
5
|
+
import shutil
|
|
6
|
+
from mlgidGUI.app.file_manager import ImageKey, FolderKey, ImagePathKey, FolderPathKey
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
__all__ = ['empty_project', 'project_1', 'ProjectInfo']
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def lazy_property(func):
|
|
14
|
+
name = f'__lazy_property_{func.__name__}'
|
|
15
|
+
|
|
16
|
+
@property
|
|
17
|
+
def wrapper(self):
|
|
18
|
+
if not hasattr(self, name):
|
|
19
|
+
setattr(self, name, func(self))
|
|
20
|
+
return getattr(self, name)
|
|
21
|
+
|
|
22
|
+
return wrapper
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@dataclass
|
|
26
|
+
class ProjectInfo:
|
|
27
|
+
name: str
|
|
28
|
+
root_path: Path
|
|
29
|
+
path_tree: dict
|
|
30
|
+
|
|
31
|
+
def root_key(self) -> FolderPathKey:
|
|
32
|
+
root_key = FolderPathKey(None, path=self.root_path, parent=None)
|
|
33
|
+
root_key.update()
|
|
34
|
+
return root_key
|
|
35
|
+
|
|
36
|
+
def all_image_keys(self) -> Generator[ImagePathKey, None, None]:
|
|
37
|
+
paths_dict = self.paths_dict()
|
|
38
|
+
for image_key_list in paths_dict.values():
|
|
39
|
+
yield from image_key_list
|
|
40
|
+
|
|
41
|
+
def paths_dict(self) -> Dict[FolderKey, List[ImageKey]]:
|
|
42
|
+
root_folder_key = self.root_key()
|
|
43
|
+
paths_dict: Dict[FolderKey, List[ImageKey]] = {}
|
|
44
|
+
self._fill_dict(paths_dict, root_folder_key)
|
|
45
|
+
return paths_dict
|
|
46
|
+
|
|
47
|
+
def _fill_dict(self, paths_dict: Dict[FolderKey, List[ImageKey]], folder_key: FolderPathKey):
|
|
48
|
+
child_images = list(self.get_image_keys_by_folder_key(folder_key))
|
|
49
|
+
if child_images:
|
|
50
|
+
paths_dict[folder_key] = child_images
|
|
51
|
+
|
|
52
|
+
for p in folder_key.path.iterdir():
|
|
53
|
+
if p.is_dir():
|
|
54
|
+
child_folder_key = FolderPathKey(folder_key, path=p, parent=folder_key)
|
|
55
|
+
self._fill_dict(paths_dict, child_folder_key)
|
|
56
|
+
|
|
57
|
+
@staticmethod
|
|
58
|
+
def get_image_keys_by_folder_key(folder_key: FolderPathKey) -> Generator[ImagePathKey, None, None]:
|
|
59
|
+
yield from (ImagePathKey(folder_key.project_path, path=p, parent = folder_key) for p in folder_key.path.iterdir() if p.suffix == '.tiff')
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def _get_project_info(project_path, project_name: str):
|
|
63
|
+
root_path = project_path
|
|
64
|
+
path_tree = _get_path_tree(root_path)
|
|
65
|
+
return ProjectInfo(project_name, root_path, path_tree)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def _get_path_tree(root_path: Path, *, _d: dict = None) -> dict:
|
|
69
|
+
if not _d:
|
|
70
|
+
_d = {}
|
|
71
|
+
|
|
72
|
+
_d[root_path] = []
|
|
73
|
+
|
|
74
|
+
for p in root_path.iterdir():
|
|
75
|
+
if p.is_dir():
|
|
76
|
+
_d[root_path].append(_get_path_tree(p, _d=_d))
|
|
77
|
+
for p in root_path.iterdir():
|
|
78
|
+
if p.is_file():
|
|
79
|
+
_d[root_path].append(p)
|
|
80
|
+
return _d
|
|
81
|
+
|
|
82
|
+
@pytest.fixture
|
|
83
|
+
def empty_project(tmpdir_factory):
|
|
84
|
+
|
|
85
|
+
project_path, project_dir = _start_project(tmpdir_factory, 'empty_project_data')
|
|
86
|
+
shutil.copytree((Path(__file__).parents[1] / 'data' / 'empty_project_data'), project_path, dirs_exist_ok=True)
|
|
87
|
+
yield _get_project_info(project_path, 'empty_project_data')
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
@pytest.fixture
|
|
91
|
+
def project_1(tmpdir_factory):
|
|
92
|
+
project_path, project_dir = _start_project(tmpdir_factory, 'project_1_data')
|
|
93
|
+
shutil.copytree((Path(__file__).parents[1] / 'data' / 'project_1_data'), project_path, dirs_exist_ok=True)
|
|
94
|
+
yield _get_project_info(project_path, 'project_1_data')
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def _start_project(tmpdir_factory, name: str) -> tuple:
|
|
99
|
+
|
|
100
|
+
project_dir = tmpdir_factory.mktemp(name)
|
|
101
|
+
project_path = Path(project_dir.strpath)
|
|
102
|
+
return project_path, project_dir
|
tests/func/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from ..fixures import *
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from mlgidGUI import App
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def test_loading_state(project_1):
|
|
5
|
+
App.clear()
|
|
6
|
+
App.__new__(App)
|
|
7
|
+
app = App(project_1.root_path)
|
|
8
|
+
app.fm.open_project(project_1.root_path)
|
|
9
|
+
app.fm.add_root_path_to_project(project_1.root_path)
|
|
10
|
+
image_keys = list(project_1.all_image_keys())
|
|
11
|
+
image_key_with_segments = image_keys[0]
|
|
12
|
+
app.fm.change_image(image_key_with_segments)
|
|
13
|
+
|
|
14
|
+
app.roi_dict.create_roi(radius=1, width=2)
|
|
15
|
+
app.roi_dict.create_roi(radius=3, width=3)
|
|
16
|
+
app.save_state()
|
|
17
|
+
assert len(app.roi_dict) == 2
|
|
18
|
+
|
|
19
|
+
app.close()
|
|
20
|
+
app = App(project_1.root_path)
|
|
21
|
+
assert len(app.roi_dict) == 2
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from mlgidGUI import App
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def test_project_1_images(project_1):
|
|
5
|
+
"""Project 1 should have a certain data"""
|
|
6
|
+
App.clear()
|
|
7
|
+
App.__new__(App)
|
|
8
|
+
app = App(project_1.root_path)
|
|
9
|
+
app.fm.open_project(project_1.root_path)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
assert app.fm.root.images_num == 0
|
|
13
|
+
assert app.fm.root.folders_num == 0
|
|
14
|
+
|
|
15
|
+
for image in project_1.all_image_keys():
|
|
16
|
+
app.fm.add_root_path_to_project(image.path)
|
|
17
|
+
|
|
18
|
+
assert app.fm.root.images_num == 3
|
|
19
|
+
|
|
20
|
+
for folder in project_1.root_key().folder_children:
|
|
21
|
+
app.fm.add_root_path_to_project(folder.path)
|
|
22
|
+
assert app.fm.root.images_num == 3
|
|
23
|
+
assert app.fm.root.folders_num == 6
|
tests/func/test_save.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
from h5py import File
|
|
2
|
+
import numpy as np
|
|
3
|
+
|
|
4
|
+
from mlgidGUI import App
|
|
5
|
+
from mlgidGUI.app.data_manager import SavingParameters
|
|
6
|
+
from mlgidGUI.app.geometry import Geometry
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def test_save(project_1, tmp_path):
|
|
10
|
+
h5path = tmp_path / 'data.h5'
|
|
11
|
+
paths_dict = project_1.paths_dict()
|
|
12
|
+
params = SavingParameters(paths_dict, h5path,
|
|
13
|
+
save_image=True,
|
|
14
|
+
save_polar_image=True)
|
|
15
|
+
app = App(project_1.root_path)
|
|
16
|
+
app.fm.open_project(project_1.root_path)
|
|
17
|
+
image_keys = list(project_1.all_image_keys())
|
|
18
|
+
assert len(image_keys) > 0
|
|
19
|
+
|
|
20
|
+
image_key_with_segments = image_keys[0]
|
|
21
|
+
app.fm.change_image(image_key_with_segments)
|
|
22
|
+
app.geometry_holder.set_beam_center((10, 10))
|
|
23
|
+
app.geometry_holder.save_as_default()
|
|
24
|
+
roi1 = app.roi_dict.create_roi(radius=2, width=5)
|
|
25
|
+
roi2 = app.roi_dict.create_roi(radius=3, width=6)
|
|
26
|
+
app.save_state()
|
|
27
|
+
|
|
28
|
+
app.data_manager.save(params)
|
|
29
|
+
|
|
30
|
+
compare_params_to_h5(params, str(h5path.resolve()))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def compare_params_to_h5(params: SavingParameters, h5path: str):
|
|
34
|
+
app = App()
|
|
35
|
+
paths_dict = params.selected_images
|
|
36
|
+
|
|
37
|
+
with File(h5path, 'r') as f:
|
|
38
|
+
assert len(list(f.keys())) == len(paths_dict)
|
|
39
|
+
for folder_key, image_keys in paths_dict.items():
|
|
40
|
+
if image_keys:
|
|
41
|
+
assert folder_key.name in f.keys()
|
|
42
|
+
|
|
43
|
+
folder_group = f[folder_key.name]
|
|
44
|
+
folder_attrs = dict(folder_group.attrs)
|
|
45
|
+
|
|
46
|
+
if params.save_geometries:
|
|
47
|
+
default_geometry = app.fm.geometries.default[folder_key]
|
|
48
|
+
if default_geometry:
|
|
49
|
+
assert default_geometry == Geometry.fromdict(folder_attrs)
|
|
50
|
+
|
|
51
|
+
for image_key in image_keys:
|
|
52
|
+
assert image_key.name in folder_group.keys()
|
|
53
|
+
image_group = folder_group[image_key.name]
|
|
54
|
+
if params.save_image:
|
|
55
|
+
assert 'image' in image_group
|
|
56
|
+
assert np.all(image_key.get_image() == image_group['image'][()])
|
|
57
|
+
if params.save_polar_image:
|
|
58
|
+
assert 'polar_image' in image_group
|
|
59
|
+
if params.save_positions and app.fm.rois_data[image_key]:
|
|
60
|
+
assert 'roi_data' in image_group
|
|
61
|
+
else:
|
|
62
|
+
assert folder_key.name not in f.keys()
|
tests/unit/__init__.py
ADDED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from mlgidGUI import App
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def test_create_rois(project_1):
|
|
5
|
+
image_keys = list(project_1.all_image_keys())
|
|
6
|
+
App.clear()
|
|
7
|
+
App.__new__(App)
|
|
8
|
+
app = App(project_1.root_path)
|
|
9
|
+
app.fm.open_project(project_1.root_path)
|
|
10
|
+
assert image_keys[0] is not None
|
|
11
|
+
app.fm.change_image(image_keys[0])
|
|
12
|
+
|
|
13
|
+
assert app.roi_dict._current_key is not None
|
|
14
|
+
|
|
15
|
+
assert len(app.roi_dict) == 0
|
|
16
|
+
app.roi_dict.create_roi(radius=1, width=2)
|
|
17
|
+
app.roi_dict.create_roi(radius=3, width=3)
|
|
18
|
+
assert len(app.roi_dict) == 2
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from mlgidGUI.app.file_manager import FileManager
|
|
2
|
+
import shutil
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def test_add_data(project_1):
|
|
6
|
+
fm = FileManager()
|
|
7
|
+
assert fm.root is None
|
|
8
|
+
fm.open_project(project_1.root_path)
|
|
9
|
+
fm.add_root_path_to_project(project_1.root_path)
|
|
10
|
+
assert fm.root.folders_num == 1
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def test_update_data(empty_project, project_1):
|
|
14
|
+
|
|
15
|
+
fm = FileManager()
|
|
16
|
+
fm.open_project(empty_project.root_path)
|
|
17
|
+
fm.add_root_path_to_project(empty_project.root_path)
|
|
18
|
+
folder_keys = list(fm.root.folder_children)
|
|
19
|
+
assert len(folder_keys) == 1
|
|
20
|
+
folder_key = folder_keys[0]
|
|
21
|
+
assert folder_key.images_num == 0
|
|
22
|
+
shutil.copyfile(project_1.root_path / '0.tiff', empty_project.root_path / '0.tiff')
|
|
23
|
+
folder_key.update()
|
|
24
|
+
images_num = folder_key.images_num
|
|
25
|
+
assert images_num > 0
|
|
26
|
+
|
|
27
|
+
project_path = fm.project_path
|
|
28
|
+
fm.close_project()
|
|
29
|
+
fm.open_project(project_path)
|
|
30
|
+
folder_keys = list(fm.root.folder_children)
|
|
31
|
+
assert len(folder_keys) == 1
|
|
32
|
+
folder_key = folder_keys[0]
|
|
33
|
+
assert folder_key.images_num == images_num
|