Skip to content
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

Connect background corrections #353

Merged
merged 1 commit into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion recOrder/acq/acquisition_workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ def _generate_transfer_function_config(

def _generate_apply_inverse_config(apply_inverse_settings_path, calib_window):
birefringence_apply_inverse_settings = (
settings._BirefringenceApplyInverseSettings()
settings._BirefringenceApplyInverseSettings(
background_path=calib_window.acq_bg_directory
)
)

phase_apply_inverse_settings = settings._PhaseApplyInverseSettings()
Expand Down
6 changes: 4 additions & 2 deletions recOrder/cli/apply_inverse_transfer_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def apply_inverse_transfer_function_cli(
# Resolve background path into array
background_path = biref_inverse_dict["background_path"]
biref_inverse_dict.pop("background_path")
if background_path is not None:
if background_path != "":
cyx_no_sample_data = utils.new_load_background(background_path)
_check_background_consistency(
cyx_no_sample_data.shape, input_dataset.data.shape
Expand Down Expand Up @@ -338,8 +338,10 @@ def apply_inverse_transfer_function_cli(
**biref_inverse_dict,
)

brightfield_3d = reconstructed_parameters_3d[2]

zyx_phase = phase_thick_3d.apply_inverse_transfer_function(
tczyx_data[time_index, 0],
brightfield_3d,
real_potential_transfer_function,
imaginary_potential_transfer_function,
z_padding=settings.phase_transfer_function_settings.z_padding,
Expand Down
15 changes: 12 additions & 3 deletions recOrder/cli/settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from pydantic import BaseModel, DirectoryPath, validator
from typing import Literal, List

Expand Down Expand Up @@ -110,13 +111,21 @@ class TransferFunctionSettings(BaseModel):


class _BirefringenceApplyInverseSettings(BaseModel):
background_path: str = (
None # I'd DirectoryPath but it's not JSON serializable?
)
background_path: str = ""
remove_estimated_background: bool = False
orientation_flip: bool = False
orientation_rotate: bool = False

@validator("background_path")
def check_background_path(cls, v):
if v == "":
return v

raw_dir = r"{}".format(v)
if not os.path.isdir(raw_dir):
raise ValueError(f"{v} is not a existing directory")
return raw_dir


class _PhaseApplyInverseSettings(BaseModel):
reconstruction_algorithm: Literal["Tikhonov", "TV"] = "Tikhonov"
Expand Down
2 changes: 1 addition & 1 deletion recOrder/plugin/main_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def __init__(self, napari_viewer: Viewer):
self.orientation_offset = False
self.pad_z = 0
self.phase_reconstructor = None
self.acq_bg_directory = None
self.acq_bg_directory = ""
self.auto_shutter = True
self.lca_dac = None
self.lcb_dac = None
Expand Down