forked from imcf/python-imcflibs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_define_dataset_auto.py
More file actions
182 lines (148 loc) Β· 4.82 KB
/
test_define_dataset_auto.py
File metadata and controls
182 lines (148 loc) Β· 4.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
"""Tests for the automatic dataset definition functionality in the BDV module."""
import logging
from imcflibs import pathtools
from imcflibs.imagej import bdv
def set_default_values(
project_filename, file_path, series_type="Tiles"
):
"""Set the default values for dataset definitions.
Parameters
----------
project_filename : str
Name of the project
file_path : pathlib.Path
Path to a temporary folder
series_type : str, optional
Type of Bioformats series (default is "Tiles")
Returns
-------
str
Start of the options for dataset definitions.
"""
# Additional settings
file_info = pathtools.parse_path(file_path)
options = (
"define_dataset=[Automatic Loader (Bioformats based)] "
+ "project_filename=["
+ project_filename
+ ".xml"
+ "] "
+ "path=["
+ file_info["path"]
+ "] "
+ "exclude=10 "
+ "bioformats_series_are?="
+ series_type
+ " "
+ "move_tiles_to_grid_(per_angle)?=[Do not move Tiles to Grid (use Metadata if available)] "
)
return options
def test_define_dataset_auto_tile(tmp_path, caplog):
"""Test automatic dataset definition method for tile series.
Parameters
----------
tmp_path : pytest.fixture
Temporary path for the test.
caplog : pytest.fixture
Log capturing fixture.
"""
# Set the logging level to capture warnings
caplog.set_level(logging.WARNING)
# Clear the log
caplog.clear()
# Define the project and file names
project_filename = "proj_name"
file_path = tmp_path
file_info = pathtools.parse_path(file_path)
# Define the result and dataset save paths
result_folder = pathtools.join2(file_info["path"], project_filename)
# Default settings
# Define the type of Bio-Formats series
bf_series_type = "Tiles"
# Define the ImageJ command
cmd = "Define Multi-View Dataset"
# Set the default values for dataset definitions
options = set_default_values(project_filename, file_path)
# Construct the options for dataset definitions
options = (
options
+ "how_to_store_input_images=["
+ "Re-save as multiresolution HDF5"
+ "] "
+ "load_raw_data_virtually "
+ "metadata_save_path=["
+ result_folder
+ "] "
+ "image_data_save_path=["
+ result_folder
+ "] "
+ "check_stack_sizes "
+ "split_hdf5 "
+ "timepoints_per_partition=1 "
+ "setups_per_partition=0 "
+ "use_deflate_compression "
)
# Construct the final call to ImageJ
final_call = "IJ.run(cmd=[%s], params=[%s])" % (cmd, options)
# Define the dataset using the "Auto-Loader" option
bdv.define_dataset_auto(
project_filename, file_info["path"], bf_series_type
)
# Check if the final call is in the log
assert final_call == caplog.messages[0]
def test_define_dataset_auto_angle(tmp_path, caplog):
"""Test automatic dataset definition method for angle series.
Parameters
----------
tmp_path : pytest.fixture
Temporary path for the test.
caplog : pytest.fixture
Log capturing fixture.
"""
# Set the logging level to capture warnings
caplog.set_level(logging.WARNING)
# Clear the log
caplog.clear()
# Define the project and file names
project_filename = "proj_name"
file_path = tmp_path
file_info = pathtools.parse_path(file_path)
# Define the result and dataset save paths
result_folder = pathtools.join2(file_info["path"], project_filename)
# Default settings
# Define the type of Bio-Formats series
bf_series_type = "Angles"
# Define the ImageJ command
cmd = "Define Multi-View Dataset"
# Set the default values for dataset definitions
options = set_default_values(
project_filename, file_path, bf_series_type
)
# Construct the options for dataset definitions
options = (
options
+ "how_to_store_input_images=["
+ "Re-save as multiresolution HDF5"
+ "] "
+ "load_raw_data_virtually "
+ "metadata_save_path=["
+ result_folder
+ "] "
+ "image_data_save_path=["
+ result_folder
+ "] "
+ "check_stack_sizes "
+ "apply_angle_rotation "
+ "split_hdf5 "
+ "timepoints_per_partition=1 "
+ "setups_per_partition=0 "
+ "use_deflate_compression "
)
# Construct the final call to ImageJ
final_call = "IJ.run(cmd=[%s], params=[%s])" % (cmd, options)
# Define the dataset using the "Auto-Loader" option
bdv.define_dataset_auto(
project_filename, file_info["path"], bf_series_type
)
# Check if the final call is in the log
assert final_call == caplog.messages[0]