Skip to content

Commit

Permalink
Merge pull request #106 from PolarizedLightFieldMicroscopy/two_var_op…
Browse files Browse the repository at this point in the history
…tic_axis

Two variable optic axis
  • Loading branch information
gschlafly authored Jul 30, 2024
2 parents 312a747 + b6484fd commit 9cb1a63
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pytest-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![python versions](https://img.shields.io/badge/python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue)
![python versions](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue)
[![Run Pytest](https://github.com/PolarizedLightFieldMicroscopy/forward-model/actions/workflows/pytest-action.yml/badge.svg)](https://github.com/PolarizedLightFieldMicroscopy/forward-model/actions/workflows/pytest-action.yml)
# GeoBirT
Polarized light field microscopy forward model and inverse model using geometrical optics and Jones Calculus.
Expand Down
27 changes: 19 additions & 8 deletions src/VolumeRaytraceLFM/birefringence_implementations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1972,7 +1972,9 @@ def calc_cummulative_JM_of_ray_torch(
)
return material_jones

def retrieve_properties_from_vox_idx(self, volume, vox, active_props_only=False):
def retrieve_properties_from_vox_idx(
self, volume: BirefringentVolume, vox: torch.Tensor, active_props_only=False
):
"""Retrieves the birefringence and optic axis from the volume based on the
provided voxel indices. This function is used to retrieve the properties
of the voxels that each ray segment interacts with."""
Expand All @@ -1983,21 +1985,30 @@ def retrieve_properties_from_vox_idx(self, volume, vox, active_props_only=False)
safe_indices = torch.clamp(indices, min=0)
mask = indices >= 0
Delta_n = torch.where(
mask, volume.birefringence_active[safe_indices], torch.tensor(0.0)
mask,
volume.birefringence_active[safe_indices],
torch.tensor(0.0, device=device),
)

if volume.optic_axis_planar is not None:
opticAxis = torch.empty(
(3, len(indices)), dtype=torch.get_default_dtype(), device=device
(3, *indices.shape), dtype=torch.get_default_dtype(), device=device
)
opticAxis[0, :] = torch.where(
mask, volume.optic_axis_active[0, safe_indices], torch.tensor(0.0)
opticAxis[0, :, :] = torch.where(
mask,
volume.optic_axis_active[0, safe_indices],
torch.tensor(0.0, device=device),
)
opticAxis[1:, :] = torch.where(
mask, volume.optic_axis_planar[:, safe_indices], torch.tensor(0.0)
opticAxis[1:, :, :] = torch.where(
mask.unsqueeze(0),
volume.optic_axis_planar[:, safe_indices],
torch.tensor(0.0, device=device),
)
else:
opticAxis = torch.where(
mask, volume.optic_axis_active[:, safe_indices], torch.tensor(0.0)
mask.unsqueeze(0),
volume.optic_axis_active[:, safe_indices],
torch.tensor(0.0, device=device),
)
else:
Delta_n = volume.Delta_n[vox]
Expand Down
2 changes: 1 addition & 1 deletion src/VolumeRaytraceLFM/jones/jones_calculus.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def linear_retarter_azim90(ret, backend=BackEnds.NUMPY):
return np.array([[np.exp(1j * ret / 2), 0], [0, np.exp(-1j * ret / 2)]])
else:
return torch.tensor(
[torch.exp(1j * ret / 2), 0], [0, torch.exp(-1j * ret / 2)]
[[torch.exp(1j * ret / 2), 0], [0, torch.exp(-1j * ret / 2)]]
)

@staticmethod
Expand Down
4 changes: 2 additions & 2 deletions src/streamlit_app/pages/2_Reconstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,8 @@ def create_optimizer(volume):
st.error("Ground truth volume is unknown.")

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
ret_image_measured = torch.tensor(output_ret_image, device=device)
azim_image_measured = torch.tensor(output_azim_image, device=device)
ret_image_measured = torch.as_tensor(output_ret_image, device=device)
azim_image_measured = torch.as_tensor(output_azim_image, device=device)
optical_info["volume_shape"] = list(est_vol_shape)
# Compute ray geometry
rays_est = BirefringentRaytraceLFM(backend=backend, optical_info=optical_info)
Expand Down

0 comments on commit 9cb1a63

Please sign in to comment.