@@ -196,14 +196,25 @@ def get_db_entry(
196
196
"""
197
197
198
198
199
+ class LifInfo (BaseModel ):
200
+ lif_file : Path
201
+ master_metadata : Optional [Path ] = None
202
+ child_metadata : list [Path ] = []
203
+ child_series : list [str ] = []
204
+ child_stacks : list [Path ] = []
205
+
206
+
207
+ class TiffInfo (BaseModel ):
208
+ tiff_file : Path
209
+ associated_metadata : Optional [Path ] = None
210
+ associated_series : Optional [str ] = None
211
+ associated_stack : Optional [Path ] = None
212
+
213
+
199
214
@router .post ("/sessions/{session_id}/clem/lif_files" )
200
215
def register_lif_file (
201
- lif_file : Path ,
216
+ lif_file : LifInfo ,
202
217
session_id : int ,
203
- master_metadata : Optional [Path ] = None ,
204
- child_metadata : list [Path ] = [],
205
- child_series : list [str ] = [],
206
- child_stacks : list [Path ] = [],
207
218
db : Session = murfey_db ,
208
219
):
209
220
# Return or register the LIF file entry
@@ -212,7 +223,7 @@ def register_lif_file(
212
223
db = db ,
213
224
table = CLEMLIFFile ,
214
225
session_id = session_id ,
215
- file_path = lif_file ,
226
+ file_path = lif_file . lif_file ,
216
227
)
217
228
except Exception :
218
229
logger .error (
@@ -223,9 +234,11 @@ def register_lif_file(
223
234
return False
224
235
225
236
# Add metadata information if provided
226
- if master_metadata is not None :
237
+ if lif_file . master_metadata is not None :
227
238
try :
228
- master_metadata = validate_and_sanitise (master_metadata , session_id , db )
239
+ master_metadata = validate_and_sanitise (
240
+ lif_file .master_metadata , session_id , db
241
+ )
229
242
clem_lif_file .master_metadata = str (master_metadata )
230
243
except Exception :
231
244
logger .warning (
@@ -235,7 +248,7 @@ def register_lif_file(
235
248
)
236
249
237
250
# Register child metadata if provided
238
- for metadata in child_metadata :
251
+ for metadata in lif_file . child_metadata :
239
252
try :
240
253
metadata_db_entry : CLEMImageMetadata = get_db_entry (
241
254
db = db ,
@@ -255,7 +268,7 @@ def register_lif_file(
255
268
continue
256
269
257
270
# Register child image series if provided
258
- for series in child_series :
271
+ for series in lif_file . child_series :
259
272
try :
260
273
series_db_entry : CLEMImageSeries = get_db_entry (
261
274
db = db ,
@@ -275,7 +288,7 @@ def register_lif_file(
275
288
continue
276
289
277
290
# Register child image stacks if provided
278
- for stack in child_stacks :
291
+ for stack in lif_file . child_stacks :
279
292
try :
280
293
stack_db_entry : CLEMImageStack = get_db_entry (
281
294
db = db ,
@@ -303,11 +316,8 @@ def register_lif_file(
303
316
304
317
@router .post ("/sessions/{session_id}/clem/tiff_files" )
305
318
def register_tiff_file (
306
- tiff_file : Path ,
319
+ tiff_file : TiffInfo ,
307
320
session_id : int ,
308
- associated_metadata : Optional [Path ] = None ,
309
- associated_series : Optional [str ] = None ,
310
- associated_stack : Optional [Path ] = None ,
311
321
db : Session = murfey_db ,
312
322
):
313
323
# Get or register the database entry
@@ -316,7 +326,7 @@ def register_tiff_file(
316
326
db = db ,
317
327
table = CLEMTIFFFile ,
318
328
session_id = session_id ,
319
- file_path = tiff_file ,
329
+ file_path = tiff_file . tiff_file ,
320
330
)
321
331
except Exception :
322
332
logger .error (
@@ -327,58 +337,58 @@ def register_tiff_file(
327
337
return False
328
338
329
339
# Add metadata if provided
330
- if associated_metadata is not None :
340
+ if tiff_file . associated_metadata is not None :
331
341
try :
332
342
metadata_db_entry : CLEMImageMetadata = get_db_entry (
333
343
db = db ,
334
344
table = CLEMImageMetadata ,
335
345
session_id = session_id ,
336
- file_path = associated_metadata ,
346
+ file_path = tiff_file . associated_metadata ,
337
347
)
338
348
# Link database entries
339
349
clem_tiff_file .associated_metadata = metadata_db_entry
340
350
except Exception :
341
351
logger .warning (
342
352
"Unable to register "
343
- f"metadata file { sanitise (str (associated_metadata ))!r} in association with "
353
+ f"metadata file { sanitise (str (tiff_file . associated_metadata ))!r} in association with "
344
354
f"TIFF file { sanitise (str (tiff_file ))!r} : \n "
345
355
f"{ traceback .format_exc ()} "
346
356
)
347
357
348
358
# Add series information if provided
349
- if associated_series is not None :
359
+ if tiff_file . associated_series is not None :
350
360
try :
351
361
series_db_entry : CLEMImageSeries = get_db_entry (
352
362
db = db ,
353
363
table = CLEMImageSeries ,
354
364
session_id = session_id ,
355
- series_name = associated_series ,
365
+ series_name = tiff_file . associated_series ,
356
366
)
357
367
# Link database entries
358
368
clem_tiff_file .child_series = series_db_entry
359
369
except Exception :
360
370
logger .warning (
361
371
"Unable to register "
362
- f"CLEM series { sanitise (associated_series )!r} in association with "
372
+ f"CLEM series { sanitise (tiff_file . associated_series )!r} in association with "
363
373
f"TIFF file { sanitise (str (tiff_file ))!r} : \n "
364
374
f"{ traceback .format_exc ()} "
365
375
)
366
376
367
377
# Add image stack information if provided
368
- if associated_stack is not None :
378
+ if tiff_file . associated_stack is not None :
369
379
try :
370
380
stack_db_entry : CLEMImageStack = get_db_entry (
371
381
db = db ,
372
382
table = CLEMImageStack ,
373
383
session_id = session_id ,
374
- file_path = associated_stack ,
384
+ file_path = tiff_file . associated_stack ,
375
385
)
376
386
# Link database entries
377
387
clem_tiff_file .child_stack = stack_db_entry
378
388
except Exception :
379
389
logger .warning (
380
390
"Unable to register "
381
- f"image stack { sanitise (str (associated_stack ))!r} in association with "
391
+ f"image stack { sanitise (str (tiff_file . associated_stack ))!r} in association with "
382
392
f"{ traceback .format_exc ()} "
383
393
)
384
394
@@ -737,7 +747,7 @@ def register_image_stack(
737
747
) # API posts to this URL
738
748
def process_raw_lifs (
739
749
session_id : int ,
740
- lif_file : Path ,
750
+ lif_file : LifInfo ,
741
751
db : Session = murfey_db ,
742
752
):
743
753
try :
@@ -759,7 +769,7 @@ def process_raw_lifs(
759
769
# Pass arguments along to the correct workflow
760
770
workflow .load ()(
761
771
# Match the arguments found in murfey.workflows.clem.process_raw_lifs
762
- file = lif_file ,
772
+ file = lif_file . lif_file ,
763
773
root_folder = "images" ,
764
774
session_id = session_id ,
765
775
instrument_name = instrument_name ,
0 commit comments