-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Final frame fix #82
Final frame fix #82
Changes from 8 commits
f378a3b
9f2cea7
a2106dd
0d93f9e
629cadc
34ffc20
317eb5a
78dadb8
02dc13f
b014a00
74106c7
951105b
50f35b6
e3da612
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -59,6 +59,7 @@ def read_image(cls, values: dict): | |||||
from lls_core.types import is_pathlike | ||||||
from pathlib import Path | ||||||
input_image = values.get("input_image") | ||||||
logger.info(f"Processing File {input_image}") # this is handy for debugging | ||||||
if is_pathlike(input_image): | ||||||
if values.get("save_name") is None: | ||||||
values["save_name"] = Path(values["input_image"]).stem | ||||||
|
@@ -74,6 +75,21 @@ def read_image(cls, values: dict): | |||||
# Use the Deskew version of this validator, to do the actual image loading | ||||||
return super().read_image(values) | ||||||
|
||||||
@validator("input_image", pre=True, always=True) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
def incomplete_final_frame(cls, v: DataArray) -> Any: | ||||||
""" | ||||||
Check final frame, if acquisition is stopped halfway through it causes failures | ||||||
This validator will remove a bad final frame | ||||||
""" | ||||||
final_frame = v[-1] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that >>> arr
<xarray.DataArray (T: 2, C: 3, Z: 4, Y: 5, X: 6)>
>>> arr[-1]
<xarray.DataArray (C: 3, Z: 4, Y: 5, X: 6)> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep that's correct. I only want to check the final frame, that's the only one that should fail in this way, I could probably drop to a single channel as well to save processing time but it's a pretty marginal improvement and this is clearer I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In that case, we could reduce the memory usage and possibly clarify what is happening by doing:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah that is a bit more explicit, will make that change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can click the "commit suggestion" button to use the change directly if you want. |
||||||
try: | ||||||
final_frame.compute() | ||||||
except ValueError as e: | ||||||
logger.warn("Final frame is borked. Acquisition probably stopped prematurely. Removing final frame.") | ||||||
v = v[0:-1] | ||||||
multimeric marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
return v | ||||||
|
||||||
|
||||||
@validator("workflow", pre=True) | ||||||
def parse_workflow(cls, v: Any): | ||||||
# Load the workflow from disk if it was provided as a path | ||||||
|
@@ -345,7 +361,7 @@ def _process_crop(self) -> Iterable[ImageSlice]: | |||||
deconv_args: dict[Any, Any] = {} | ||||||
if self.deconvolution is not None: | ||||||
deconv_args = dict( | ||||||
num_iter = self.deconvolution.psf_num_iter, | ||||||
num_iter = self.deconvolution.decon_num_iter, | ||||||
psf = self.deconvolution.psf[slice.channel].to_numpy(), | ||||||
decon_processing=self.deconvolution.decon_processing | ||||||
) | ||||||
|
@@ -390,13 +406,13 @@ def _process_non_crop(self) -> Iterable[ImageSlice]: | |||||
dxdata=self.dx, | ||||||
dzpsf=self.dz, | ||||||
dxpsf=self.dx, | ||||||
num_iter=self.deconvolution.psf_num_iter | ||||||
num_iter=self.deconvolution.decon_num_iter | ||||||
) | ||||||
else: | ||||||
data = skimage_decon( | ||||||
vol_zyx=data, | ||||||
psf=self.deconvolution.psf[slice.channel].to_numpy(), | ||||||
num_iter=self.deconvolution.psf_num_iter, | ||||||
num_iter=self.deconvolution.decon_num_iter, | ||||||
clip=False, | ||||||
filter_epsilon=0, | ||||||
boundary='nearest' | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.