18
18
import zarr
19
19
20
20
from fractal .tasks .lib_parse_filename_metadata import parse_metadata
21
+ from fractal .tasks .metadata_parsing import parse_yokogawa_metadata
21
22
22
23
23
24
def create_zarr_structure (
@@ -26,6 +27,7 @@ def create_zarr_structure(
26
27
ext = None ,
27
28
path_dict_channels = None ,
28
29
num_levels = None ,
30
+ coarsening_xy = None ,
29
31
):
30
32
31
33
"""
@@ -41,6 +43,7 @@ def create_zarr_structure(
41
43
:type path_dict_channels: str
42
44
:param num_levels: number of coarsening levels in the pyramid
43
45
:type num_levels: int
46
+ FIXME
44
47
"""
45
48
46
49
try :
@@ -142,6 +145,24 @@ def create_zarr_structure(
142
145
zarrurls = {"plate" : [], "well" : []}
143
146
# zarrurls_in_paths = {}
144
147
148
+ # PARSE METADATA
149
+ # FIXME: hard-coded paths
150
+ root = (
151
+ "/data/active/fractal/3D/PelkmansLab/"
152
+ "CardiacMultiplexing/Cycle1_testSubset/"
153
+ )
154
+ mrf_path = root + "MeasurementDetail.mrf"
155
+ mlf_path = root + "MeasurementData.mlf"
156
+
157
+ site_metadata , total_files = parse_yokogawa_metadata (
158
+ mrf_path = mrf_path , mlf_path = mlf_path
159
+ )
160
+
161
+ # PIXEL SIZES
162
+ pixel_size_z = site_metadata ["pixel_size_z" ][0 ]
163
+ pixel_size_y = site_metadata ["pixel_size_y" ][0 ]
164
+ pixel_size_x = site_metadata ["pixel_size_x" ][0 ]
165
+
145
166
if not out_path .endswith ("/" ):
146
167
out_path += "/"
147
168
for plate in plates :
@@ -243,11 +264,43 @@ def create_zarr_structure(
243
264
"type" : "space" ,
244
265
"unit" : "micrometer" ,
245
266
},
246
- {"name" : "y" , "type" : "space" },
247
- {"name" : "x" , "type" : "space" },
267
+ {
268
+ "name" : "y" ,
269
+ "type" : "space" ,
270
+ "unit" : "micrometer" ,
271
+ },
272
+ {
273
+ "name" : "x" ,
274
+ "type" : "space" ,
275
+ "unit" : "micrometer" ,
276
+ },
248
277
],
249
278
"datasets" : [
250
- {"path" : f"{ level } " } for level in range (num_levels )
279
+ {
280
+ "path" : f"{ ind_level } " ,
281
+ "coordinateTransformations" : [
282
+ {
283
+ "type" : "scale" ,
284
+ "scale" : [
285
+ 1.0 ,
286
+ 1.0 * coarsening_xy ** ind_level ,
287
+ 1.0 * coarsening_xy ** ind_level ,
288
+ ],
289
+ }
290
+ ],
291
+ }
292
+ for ind_level in range (num_levels )
293
+ ],
294
+ # Global rescaling to physiacl units
295
+ "coordinateTransformations" : [
296
+ {
297
+ "type" : "scale" ,
298
+ "scale" : [
299
+ pixel_size_z ,
300
+ pixel_size_y ,
301
+ pixel_size_x ,
302
+ ],
303
+ }
251
304
],
252
305
}
253
306
]
@@ -302,7 +355,12 @@ def create_zarr_structure(
302
355
type = int ,
303
356
help = "number of levels in the Zarr pyramid" ,
304
357
)
305
-
358
+ parser .add_argument (
359
+ "-cxy" ,
360
+ "--coarsening_xy" ,
361
+ type = int ,
362
+ help = "FIXME" ,
363
+ )
306
364
parser .add_argument (
307
365
"-c" ,
308
366
"--path_dict_channels" ,
@@ -315,5 +373,6 @@ def create_zarr_structure(
315
373
out_path = args .out_path ,
316
374
ext = args .ext ,
317
375
num_levels = args .num_levels ,
376
+ coarsening_xy = args .coarsening_xy ,
318
377
path_dict_channels = args .path_dict_channels ,
319
378
)
0 commit comments