Skip to content

Commit c3c78a0

Browse files
committed
Completed draft of function to register LIF preprocessing results
1 parent c9ffa31 commit c3c78a0

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/murfey/workflows/clem/register_results.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,12 @@ def _validate_and_sanitise(
7272
try:
7373
base_path = list(rsync_basepath.parents)[-2].as_posix()
7474
except IndexError:
75-
# Print to troubleshoot
7675
logger.warning(f"Base path {rsync_basepath!r} is too short")
7776
base_path = rsync_basepath.as_posix()
78-
except Exception:
79-
raise Exception("Unexpected exception occurred when loading the file base path")
77+
except Exception as e:
78+
raise Exception(
79+
f"Unexpected exception encountered when loading the file base path: {e}"
80+
)
8081

8182
# Check that full file path doesn't contain unallowed characters
8283
# Currently allows only:
@@ -262,7 +263,7 @@ def register_lif_preprocessing_result(
262263
file_path=result.parent_lif,
263264
)
264265

265-
# Link entries to one another
266+
# Link tables to one another and populate fields
266267
clem_img_stk.associated_metadata = clem_metadata
267268
clem_img_stk.parent_lif = clem_lif_file
268269
clem_img_stk.parent_series = clem_img_series
@@ -272,6 +273,19 @@ def register_lif_preprocessing_result(
272273
db.commit()
273274
db.refresh()
274275

276+
clem_img_series.associated_metadata = clem_metadata
277+
clem_img_series.parent_lif = clem_lif_file
278+
db.add(clem_img_series)
279+
db.commit()
280+
db.refresh()
281+
282+
clem_metadata.parent_lif = clem_lif_file
283+
db.add(clem_metadata)
284+
db.commit()
285+
db.refresh()
286+
287+
logger.info(f"LIF preprocessing results registered for {result.series_name}")
288+
275289
return True
276290

277291
except Exception as e:

0 commit comments

Comments
 (0)