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

Vector reconstruction CLI prototype #484

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
precompute and apply svd
talonchandler committed Oct 16, 2024
commit 9ff5bad2bdd1ff908894ff1ac57cfe45e77c57d3
21 changes: 11 additions & 10 deletions recOrder/cli/apply_inverse_models.py
Original file line number Diff line number Diff line change
@@ -222,21 +222,22 @@ def birefringence_and_phase(
reconstructed_parameters_3d[0], wavelength_illumination
)

# Load vector transfer function
vector_transfer_function = torch.tensor(
transfer_function_dataset["vector_transfer_function"]
# Load singular system
U = torch.tensor(
transfer_function_dataset["singular_system_U"]
)
S = torch.tensor(
transfer_function_dataset["singular_system_S"][0]
)
Vh = torch.tensor(
transfer_function_dataset["singular_system_Vh"]
)
singular_system = (U, S, Vh)


# Convert retardance and orientation to stokes
stokes = stokes_after_adr(*reconstructed_parameters_3d)

# Compute svd
singular_system = (
inplane_oriented_thick_pol3d_vector.calculate_singular_system(
vector_transfer_function
)
)

# Apply reconstruction
joint_recon_params = inplane_oriented_thick_pol3d_vector.apply_inverse_transfer_function(
szyx_data=torch.stack(stokes),
29 changes: 26 additions & 3 deletions recOrder/cli/compute_transfer_function.py
Original file line number Diff line number Diff line change
@@ -50,12 +50,35 @@ def generate_and_save_vector_birefringence_transfer_function(
)
)

dataset.append_channel("ch1")
dataset.append_channel("ch2")
# Compute svd
U, S, Vh = inplane_oriented_thick_pol3d_vector.calculate_singular_system(
sfZYX_transfer_function
)
chunks = (1, 1, 1, zyx_shape[1], zyx_shape[2])

# Add dummy channels
for i in range(3):
dataset.append_channel(f"ch{i}")

dataset.create_image(
"vector_transfer_function",
sfZYX_transfer_function.cpu().numpy(),
chunks=(1, 1, 1, zyx_shape[1], zyx_shape[2]),
chunks=chunks,
)
dataset.create_image(
"singular_system_U",
U.cpu().numpy(),
chunks=chunks,
)
dataset.create_image(
"singular_system_S",
S[None].cpu().numpy(),
chunks=chunks,
)
dataset.create_image(
"singular_system_Vh",
Vh.cpu().numpy(),
chunks=chunks,
)