Skip to content

Commit

Permalink
add check/fix for incomplete final frame
Browse files Browse the repository at this point in the history
  • Loading branch information
Lachlan Whitehead committed Sep 3, 2024
1 parent 34ffc20 commit 317eb5a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/lls_core/models/deskew.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,15 @@ def read_image(cls, values: dict):
# If the image was convertible to AICSImage, we should use the metadata from there
if aics:
values["input_image"] = aics.xarray_dask_data

This comment has been minimized.

Copy link
@pr4deepr

pr4deepr Sep 3, 2024

Collaborator

Two things:

  • Shouldn't the code block be after the if statement, i.e., regardless of it being convertible to AICSImage or not, we would want this check.
  • When running final_frame.compute(), the try except only checks if its corrupted or not.. Is this what usually happens? I was under the impression you get an array of a different shape and that was the issue.

This comment has been minimized.

Copy link
@DrLachie

DrLachie Sep 6, 2024

Contributor

Sorry didn't see this post.
From my testing, the compute() attempts to fill the values into the shape its expecting from final_frame.shape, if there's a mismatch it throws a ValueError

#check if final frame is complte. If not, get rid of it
final_frame = values["input_image"][-1]
try:
final_frame.compute()
except ValueError as e:
print("Final frame is borked. Acquisition probably stopped prematurely. Removing final frame.")
values["input_image"] = values["input_image"][0:-1]

# Take pixel sizes from the image metadata, but only if they're defined
# and only if we don't already have them
if all(size is not None for size in aics.physical_pixel_sizes) and values.get("physical_pixel_sizes") is None:
Expand Down

0 comments on commit 317eb5a

Please sign in to comment.