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-optics birefringence reconstruction prototype #170

Draft
wants to merge 74 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
4a20aeb
Phase reconstruction is invariant to voxel-size (#164)
talonchandler Apr 23, 2024
f662aaa
poster scripting
talonchandler May 13, 2024
945dbcb
may 14 poster draft
talonchandler May 14, 2024
05db85d
last-minute poster changes
talonchandler May 27, 2024
15d2fbd
quick clearning
talonchandler Jun 10, 2024
6034cbb
checkpoint before svd refactor
talonchandler Jun 12, 2024
592675d
SVD refactor
talonchandler Jun 17, 2024
0fa4bbe
pass singular system
talonchandler Jun 17, 2024
63dd98c
update visualization script
talonchandler Sep 9, 2024
546ed16
Merge branch 'main' into vector-prototype
talonchandler Sep 9, 2024
96d8b85
fix visualization script scaling
talonchandler Sep 9, 2024
005ea54
correct phase recon regression, legacy recon assumes axially even gre…
talonchandler Sep 9, 2024
4034ce3
helper functions
talonchandler Sep 10, 2024
2e155fe
fluorescence wrap safety
talonchandler Sep 10, 2024
783b916
3d phase wrap safety
talonchandler Sep 10, 2024
55f8e5a
fix axial nyquist bug
talonchandler Sep 10, 2024
22a059b
2d phase wrap safety
talonchandler Sep 10, 2024
7c7f2a5
fix interaction between padding and wrap safety
talonchandler Sep 10, 2024
a977bfe
clean defaults
talonchandler Sep 10, 2024
5039a7d
Merge branch 'wrap-safe-transfer-functions' into vector-prototype
talonchandler Sep 10, 2024
6562ce7
refactor singular system computation
talonchandler Sep 10, 2024
242ceca
remove accidental duplicate
talonchandler Sep 10, 2024
bbe8935
refactor visuals
talonchandler Sep 10, 2024
ca4e7c5
fix warnings from tensoring a tensor
talonchandler Sep 10, 2024
2745005
match defaults
talonchandler Sep 10, 2024
6143b6a
readme type
talonchandler Sep 10, 2024
f8d6b0c
handle napari dependency
talonchandler Sep 10, 2024
790df57
Revert "fix warnings from tensoring a tensor"
talonchandler Sep 10, 2024
6fa39fd
Reapply "fix warnings from tensoring a tensor"
talonchandler Sep 10, 2024
da6a40b
revive old version of greens tensor for backwards compatibility
talonchandler Sep 11, 2024
974a700
fix tests that fail because of napari on github
talonchandler Sep 11, 2024
995c90d
wrap-safe vector transfer function
talonchandler Sep 27, 2024
69fea21
sampling tests
talonchandler Sep 27, 2024
93d5940
fourier-space oversampling
talonchandler Sep 27, 2024
6ad3d02
better visualizations for debugging
talonchandler Oct 1, 2024
1f03a8f
complex-valued napari visuals
talonchandler Oct 1, 2024
d86e0ab
complex utils
talonchandler Oct 1, 2024
4f32ac1
fix colormaps
talonchandler Oct 2, 2024
f251db5
debugging coherent tfs
talonchandler Oct 2, 2024
427386c
formatting
talonchandler Oct 2, 2024
2b7fd04
fix rotation matrices
talonchandler Oct 2, 2024
902c690
fix dc term
talonchandler Oct 2, 2024
1cb7d53
cleaning up
talonchandler Oct 2, 2024
3b0f252
first-pass visuals checkpoint
talonchandler Oct 5, 2024
cd081e9
matplotlib visuals
talonchandler Oct 7, 2024
b3ec8c6
temporarily turn off rotations
talonchandler Oct 7, 2024
8e1f292
debugging progress
talonchandler Oct 7, 2024
7968e75
example script to generate matplotlib tf figures
talonchandler Oct 7, 2024
7d6be60
add rose asset
talonchandler Oct 7, 2024
c61c491
add all assets
talonchandler Oct 7, 2024
674fa40
plot all stokes
talonchandler Oct 8, 2024
90aced9
brighter plot for greens
talonchandler Oct 8, 2024
86e9fa4
visual improvements
talonchandler Oct 8, 2024
3c5db57
revised rotation-symmetric Green's tensor
talonchandler Oct 8, 2024
35c3261
ignore
talonchandler Oct 8, 2024
75e23b0
fix green's tensor units
talonchandler Oct 8, 2024
d0d6f7e
modify circular anisotropy gellman matrices so that all transfer func…
talonchandler Oct 8, 2024
92bb6d6
improved matplotlib visuals
talonchandler Oct 15, 2024
7cece20
clean up plotting script
talonchandler Oct 15, 2024
74c8bfc
fix bug with 3x3 hardcoded shape
talonchandler Oct 15, 2024
ee6b744
update tf components
talonchandler Oct 15, 2024
3ffbf4f
minor reconstruction updates
talonchandler Oct 15, 2024
5036883
refactor greens tensor spectrum
talonchandler Oct 15, 2024
17d8283
clean test script
talonchandler Oct 15, 2024
b19c0c9
clean models
talonchandler Oct 15, 2024
ab745e9
simple memory reduction
talonchandler Oct 15, 2024
f2f0b03
clean debug statements
talonchandler Oct 16, 2024
ef8ac77
reorder svd for clean i/o
talonchandler Oct 16, 2024
4fccfcc
invert phase contrast
talonchandler Oct 16, 2024
0d7ad4b
formatting
talonchandler Oct 16, 2024
7242f66
padding warning
talonchandler Oct 17, 2024
726a28b
revise visuals
talonchandler Oct 17, 2024
9b3fcc4
visual cleanup
talonchandler Nov 8, 2024
75be3e5
manage large reconstructions
talonchandler Nov 8, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
from numpy.fft import fftshift

import waveorder as wo
from waveorder import optics, waveorder_reconstructor, util, visual
from waveorder import optics, waveorder_reconstructor, util

import zarr
from pathlib import Path
from iohub import open_ome_zarr
from waveorder.visuals import jupyter_visuals

# %%
# Initialization
Expand Down Expand Up @@ -110,7 +111,7 @@
Source_PolState[i, 1] = E_in[1]


visual.plot_multicolumn(
jupyter_visuals.plot_multicolumn(
fftshift(Source, axes=(1, 2)), origin="lower", num_col=5
)

Expand Down Expand Up @@ -162,7 +163,7 @@

# %%
# browse raw intensity stacks (stack_idx_1: z index, stack_idx2: pattern index)
visual.parallel_5D_viewer(
jupyter_visuals.parallel_5D_viewer(
np.transpose(I_meas[:, :, :, :, ::-1], (4, 1, 0, 2, 3)),
num_col=4,
size=10,
Expand All @@ -171,7 +172,7 @@

# %%
# browse uncorrected Stokes parameters (stack_idx_1: z index, stack_idx2: pattern index)
visual.parallel_5D_viewer(
jupyter_visuals.parallel_5D_viewer(
np.transpose(S_image_recon, (4, 1, 0, 2, 3)),
num_col=3,
size=8,
Expand All @@ -182,7 +183,7 @@

# %%
# browse corrected Stokes parameters (stack_idx_1: z index, stack_idx2: pattern index)
visual.parallel_5D_viewer(
jupyter_visuals.parallel_5D_viewer(
np.transpose(S_image_tm, (4, 1, 0, 2, 3)),
num_col=3,
size=8,
Expand Down Expand Up @@ -213,7 +214,7 @@

# %%
# browse the z-stack of components of scattering potential tensor
visual.parallel_4D_viewer(
jupyter_visuals.parallel_4D_viewer(
np.transpose(f_tensor, (3, 0, 1, 2)),
num_col=4,
origin="lower",
Expand Down Expand Up @@ -278,7 +279,7 @@

# %%
# browse the reconstructed physical properties
visual.parallel_4D_viewer(
jupyter_visuals.parallel_4D_viewer(
np.transpose(
np.stack(
[
Expand Down Expand Up @@ -546,7 +547,7 @@

# %%
# browse XY planes of the phase and differential permittivity
visual.parallel_4D_viewer(
jupyter_visuals.parallel_4D_viewer(
np.transpose(
[
np.clip(phase_PT, phase_min, phase_max),
Expand Down Expand Up @@ -585,7 +586,7 @@
),
(3, 1, 2, 0),
)
orientation_3D_image_RGB = visual.orientation_3D_to_rgb(
orientation_3D_image_RGB = jupyter_visuals.orientation_3D_to_rgb(
orientation_3D_image, interp_belt=20 / 180 * np.pi, sat_factor=1
)

Expand All @@ -600,7 +601,7 @@

# plot the top view of 3D orientation colorsphere
plt.figure(figsize=(3, 3))
visual.orientation_3D_colorwheel(
jupyter_visuals.orientation_3D_colorwheel(
wheelsize=256, circ_size=50, interp_belt=20 / 180 * np.pi, sat_factor=1
)

Expand Down Expand Up @@ -639,7 +640,7 @@
in_plane_orientation[:, y_layer], origin="lower", aspect=z_step / ps
)
plt.figure(figsize=(3, 3))
visual.orientation_2D_colorwheel()
jupyter_visuals.orientation_2D_colorwheel()

# %%
# out-of-plane tilt
Expand Down Expand Up @@ -686,7 +687,7 @@

fig, ax = plt.subplots(1, 1, figsize=(15, 15))

visual.plot3DVectorField(
jupyter_visuals.plot3DVectorField(
np.abs(differential_permittivity_PT[1, :, :, z_layer]),
azimuth[1, :, :, z_layer],
theta[1, :, :, z_layer],
Expand Down Expand Up @@ -722,7 +723,7 @@
# %%
# Angular histogram of 3D orientation

visual.orientation_3D_hist(
jupyter_visuals.orientation_3D_hist(
azimuth[1].flatten(),
theta[1].flatten(),
ret_mask.flatten(),
Expand Down
20 changes: 10 additions & 10 deletions examples/maintenance/PTI_simulation/PTI_Simulation_Forward_2D3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
from waveorder import (
optics,
waveorder_simulator,
visual,
util,
)
from waveorder.visuals import jupyter_visuals

#####################################################################
# Initialization - imaging system and sample #
Expand Down Expand Up @@ -145,7 +145,7 @@
### Visualize sample properties

#### XY sections
visual.plot_multicolumn(
jupyter_visuals.plot_multicolumn(
[
target[:, :, z_layer],
azimuth[:, :, z_layer] % (2 * np.pi),
Expand All @@ -158,7 +158,7 @@
set_title=True,
)
#### XZ sections
visual.plot_multicolumn(
jupyter_visuals.plot_multicolumn(
[
np.transpose(target[y_layer, :, :]),
np.transpose(azimuth[y_layer, :, :]) % (2 * np.pi),
Expand Down Expand Up @@ -197,7 +197,7 @@
),
(3, 1, 2, 0),
)
orientation_3D_image_RGB = visual.orientation_3D_to_rgb(
orientation_3D_image_RGB = jupyter_visuals.orientation_3D_to_rgb(
orientation_3D_image, interp_belt=20 / 180 * np.pi, sat_factor=1
)

Expand All @@ -206,7 +206,7 @@
plt.figure(figsize=(10, 10))
plt.imshow(orientation_3D_image_RGB[:, y_layer], origin="lower")
plt.figure(figsize=(3, 3))
visual.orientation_3D_colorwheel(
jupyter_visuals.orientation_3D_colorwheel(
wheelsize=128,
circ_size=50,
interp_belt=20 / 180 * np.pi,
Expand All @@ -216,7 +216,7 @@
plt.show()

#### Angular histogram of 3D orientation
visual.orientation_3D_hist(
jupyter_visuals.orientation_3D_hist(
azimuth.flatten(),
inclination.flatten(),
np.abs(target).flatten(),
Expand Down Expand Up @@ -258,7 +258,7 @@
epsilon_tensor[2, 2] = epsilon_mean + epsilon_del * np.cos(2 * inclination)


visual.plot_multicolumn(
jupyter_visuals.plot_multicolumn(
[
epsilon_tensor[0, 0, :, :, z_layer],
epsilon_tensor[0, 1, :, :, z_layer],
Expand Down Expand Up @@ -334,7 +334,7 @@
)


visual.plot_multicolumn(
jupyter_visuals.plot_multicolumn(
[
del_f_component[0, :, :, z_layer],
del_f_component[1, :, :, z_layer],
Expand Down Expand Up @@ -425,11 +425,11 @@

#### Circularly polarized illumination patterns

visual.plot_multicolumn(
jupyter_visuals.plot_multicolumn(
fftshift(Source_cont, axes=(1, 2)), origin="lower", num_col=5, size=5
)
# discretized illumination patterns used in simulation (faster forward model)
visual.plot_multicolumn(
jupyter_visuals.plot_multicolumn(
fftshift(Source, axes=(1, 2)), origin="lower", num_col=5, size=5
)
print(Source_PolState)
Expand Down
16 changes: 8 additions & 8 deletions examples/maintenance/PTI_simulation/PTI_Simulation_Recon2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
from waveorder import (
optics,
waveorder_reconstructor,
visual,
)
from waveorder.visuals import jupyter_visuals

## Initialization
## Load simulated images and parameters
Expand Down Expand Up @@ -76,7 +76,7 @@
## Visualize 2 D transfer functions as a function of illumination pattern

# illumination patterns used
visual.plot_multicolumn(
jupyter_visuals.plot_multicolumn(
fftshift(Source_cont, axes=(1, 2)), origin="lower", num_col=5, size=5
)
plt.show()
Expand Down Expand Up @@ -118,7 +118,7 @@
S_image_tm, reg_inc=reg_inc, cupy_det=True
)

visual.plot_multicolumn(
jupyter_visuals.plot_multicolumn(
f_tensor,
num_col=4,
origin="lower",
Expand Down Expand Up @@ -255,14 +255,14 @@
),
(1, 2, 0),
)
orientation_3D_image_RGB = visual.orientation_3D_to_rgb(
orientation_3D_image_RGB = jupyter_visuals.orientation_3D_to_rgb(
orientation_3D_image, interp_belt=20 / 180 * np.pi, sat_factor=1
)

plt.figure(figsize=(5, 5))
plt.imshow(orientation_3D_image_RGB, origin="lower")
plt.figure(figsize=(3, 3))
visual.orientation_3D_colorwheel(
jupyter_visuals.orientation_3D_colorwheel(
wheelsize=256, circ_size=50, interp_belt=20 / 180 * np.pi, sat_factor=1
)
plt.show()
Expand Down Expand Up @@ -297,7 +297,7 @@
plt.figure(figsize=(5, 5))
plt.imshow(in_plane_orientation, origin="lower")
plt.figure(figsize=(3, 3))
visual.orientation_2D_colorwheel()
jupyter_visuals.orientation_2D_colorwheel()
plt.show()

# out-of-plane tilt
Expand Down Expand Up @@ -339,7 +339,7 @@
plt.figure(figsize=(10, 10))

fig, ax = plt.subplots(1, 1, figsize=(20, 10))
visual.plot3DVectorField(
jupyter_visuals.plot3DVectorField(
np.abs(retardance_pr_nm[0]),
azimuth[0],
theta[0],
Expand All @@ -362,7 +362,7 @@

plt.figure(figsize=(10, 10))
plt.imshow(ret_mask, cmap="gray", origin="lower")
visual.orientation_3D_hist(
jupyter_visuals.orientation_3D_hist(
azimuth[0].flatten(),
theta[0].flatten(),
ret_mask.flatten(),
Expand Down
22 changes: 11 additions & 11 deletions examples/maintenance/PTI_simulation/PTI_Simulation_Recon3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
from waveorder import (
optics,
waveorder_reconstructor,
visual,
)
from waveorder.visuals import jupyter_visuals

## Initialization
## Load simulated images and parameters
Expand Down Expand Up @@ -65,7 +65,7 @@


### Illumination patterns used
visual.plot_multicolumn(
jupyter_visuals.plot_multicolumn(
fftshift(Source_cont, axes=(1, 2)), origin="lower", num_col=5, size=5
)
plt.show()
Expand Down Expand Up @@ -113,7 +113,7 @@
S_image_tm, reg_inc=reg_inc, cupy_det=True
)

visual.plot_multicolumn(
jupyter_visuals.plot_multicolumn(
f_tensor[..., L // 2],
num_col=4,
origin="lower",
Expand Down Expand Up @@ -183,7 +183,7 @@
### Reconstructed phase, absorption, principal retardance, azimuth, and inclination assuming (+) and (-) optic sign

# browse the reconstructed physical properties
visual.plot_multicolumn(
jupyter_visuals.plot_multicolumn(
np.stack(
[
phase_PT[..., L // 2],
Expand Down Expand Up @@ -389,7 +389,7 @@
),
(3, 1, 2, 0),
)
orientation_3D_image_RGB = visual.orientation_3D_to_rgb(
orientation_3D_image_RGB = jupyter_visuals.orientation_3D_to_rgb(
orientation_3D_image, interp_belt=20 / 180 * np.pi, sat_factor=1
)

Expand All @@ -402,7 +402,7 @@
)
# plot the top view of 3D orientation colorsphere
plt.figure(figsize=(3, 3))
visual.orientation_3D_colorwheel(
jupyter_visuals.orientation_3D_colorwheel(
wheelsize=128,
circ_size=50,
interp_belt=20 / 180 * np.pi,
Expand Down Expand Up @@ -440,7 +440,7 @@
plt.figure(figsize=(10, 10))
plt.imshow(in_plane_orientation[:, y_layer], origin="lower", aspect=psz / ps)
plt.figure(figsize=(3, 3))
visual.orientation_2D_colorwheel()
jupyter_visuals.orientation_2D_colorwheel()
plt.show()


Expand Down Expand Up @@ -511,7 +511,7 @@


fig, ax = plt.subplots(2, 2, figsize=(10, 10))
visual.plot3DVectorField(
jupyter_visuals.plot3DVectorField(
np.abs(retardance_pr_PT[0, :, :, z_layer]),
azimuth[0, :, :, z_layer],
theta[0, :, :, z_layer],
Expand All @@ -529,7 +529,7 @@
)
ax[0, 0].set_title(f"XY section (z= {z_layer})")

visual.plot3DVectorField(
jupyter_visuals.plot3DVectorField(
np.transpose(np.abs(retardance_pr_PT[0, :, x_layer, :])),
np.transpose(azimuth_x[0, :, x_layer, :]),
np.transpose(theta_x[0, :, x_layer, :]),
Expand All @@ -547,7 +547,7 @@
)
ax[0, 1].set_title(f"YZ section (x = {x_layer})")

visual.plot3DVectorField(
jupyter_visuals.plot3DVectorField(
np.transpose(np.abs(retardance_pr_PT[0, y_layer, :, :])),
np.transpose(azimuth_y[0, y_layer, :, :]),
np.transpose(theta_y[0, y_layer, :, :]),
Expand Down Expand Up @@ -584,7 +584,7 @@

plt.figure(figsize=(10, 10))
plt.imshow(ret_mask[:, :, z_layer], cmap="gray", origin="lower")
visual.orientation_3D_hist(
jupyter_visuals.orientation_3D_hist(
azimuth[0].flatten(),
theta[0].flatten(),
ret_mask.flatten(),
Expand Down
Loading
Loading