diff --git a/examples/models/inplane_anisotropic_thin_pol3D.py b/examples/models/inplane_anisotropic_thin_pol3D.py deleted file mode 100644 index 599beaf2..00000000 --- a/examples/models/inplane_anisotropic_thin_pol3D.py +++ /dev/null @@ -1,65 +0,0 @@ -import napari -import numpy as np -from waveorder import util -from waveorder.models import inplane_anisotropic_thin_pol3d - -# Parameters -# all lengths must use consistent units e.g. um -simulation_arguments = {"yx_shape": (256, 256)} -transfer_function_arguments = {"swing": 0.1, "scheme": "5-State"} - -# Create a phantom -inplane_anisotropic_parameters = ( - inplane_anisotropic_thin_pol3d.generate_test_phantom( - **simulation_arguments - ) -) - -# Calculate transfer function -intensity_to_stokes_matrix = ( - inplane_anisotropic_thin_pol3d.calculate_transfer_function( - **transfer_function_arguments - ) -) - -# Display transfer function -viewer = napari.Viewer() -inplane_anisotropic_thin_pol3d.visualize_transfer_function( - viewer, intensity_to_stokes_matrix -) -input("Showing transfer functions. Press to continue...") -viewer.layers.select_all() -viewer.layers.remove_selected() - -# Simulate -czyx_data = inplane_anisotropic_thin_pol3d.apply_transfer_function( - *inplane_anisotropic_parameters, - intensity_to_stokes_matrix, -) - -# Reconstruct -inplane_anisotropic_parameters_recon = ( - inplane_anisotropic_thin_pol3d.apply_inverse_transfer_function( - czyx_data, intensity_to_stokes_matrix - ) -) - -# Display -arrays = [ - (inplane_anisotropic_parameters_recon[3], "Depolarization - recon"), - (inplane_anisotropic_parameters_recon[2], "Transmittance - recon"), - (inplane_anisotropic_parameters_recon[1], "Orientation - recon"), - (inplane_anisotropic_parameters_recon[0], "Retardance - recon"), - (czyx_data, "Data"), - (inplane_anisotropic_parameters[3], "Depolarization"), - (inplane_anisotropic_parameters[2], "Transmittance"), - (inplane_anisotropic_parameters[1], "Orientation"), - (inplane_anisotropic_parameters[0], "Retardance"), -] - -for array in arrays: - viewer.add_image(array[0].cpu().numpy(), name=array[1]) - -viewer.grid.enabled = True -viewer.grid.shape = (2, 5) -input("Showing object, data, and recon. Press to quit...") diff --git a/examples/models/inplane_oriented_thick_pol3D.py b/examples/models/inplane_oriented_thick_pol3D.py new file mode 100644 index 00000000..cea1f791 --- /dev/null +++ b/examples/models/inplane_oriented_thick_pol3D.py @@ -0,0 +1,63 @@ +import napari +import numpy as np +from waveorder import util +from waveorder.models import inplane_oriented_thick_pol3d + +# Parameters +# all lengths must use consistent units e.g. um +simulation_arguments = {"yx_shape": (256, 256)} +transfer_function_arguments = {"swing": 0.1, "scheme": "5-State"} + +# Create a phantom +inplane_oriented_parameters = ( + inplane_oriented_thick_pol3d.generate_test_phantom(**simulation_arguments) +) + +# Calculate transfer function +intensity_to_stokes_matrix = ( + inplane_oriented_thick_pol3d.calculate_transfer_function( + **transfer_function_arguments + ) +) + +# Display transfer function +viewer = napari.Viewer() +inplane_oriented_thick_pol3d.visualize_transfer_function( + viewer, intensity_to_stokes_matrix +) +input("Showing transfer functions. Press to continue...") +viewer.layers.select_all() +viewer.layers.remove_selected() + +# Simulate +czyx_data = inplane_oriented_thick_pol3d.apply_transfer_function( + *inplane_oriented_parameters, + intensity_to_stokes_matrix, +) + +# Reconstruct +inplane_oriented_parameters_recon = ( + inplane_oriented_thick_pol3d.apply_inverse_transfer_function( + czyx_data, intensity_to_stokes_matrix + ) +) + +# Display +arrays = [ + (inplane_oriented_parameters_recon[3], "Depolarization - recon"), + (inplane_oriented_parameters_recon[2], "Transmittance - recon"), + (inplane_oriented_parameters_recon[1], "Orientation - recon"), + (inplane_oriented_parameters_recon[0], "Retardance - recon"), + (czyx_data, "Data"), + (inplane_oriented_parameters[3], "Depolarization"), + (inplane_oriented_parameters[2], "Transmittance"), + (inplane_oriented_parameters[1], "Orientation"), + (inplane_oriented_parameters[0], "Retardance"), +] + +for array in arrays: + viewer.add_image(array[0].cpu().numpy(), name=array[1]) + +viewer.grid.enabled = True +viewer.grid.shape = (2, 5) +input("Showing object, data, and recon. Press to quit...") diff --git a/tests/models/test_inplane_anisotropic_thin_pol3D.py b/tests/models/test_inplane_oriented_thick_pol3D.py similarity index 66% rename from tests/models/test_inplane_anisotropic_thin_pol3D.py rename to tests/models/test_inplane_oriented_thick_pol3D.py index effee96d..51ade657 100644 --- a/tests/models/test_inplane_anisotropic_thin_pol3D.py +++ b/tests/models/test_inplane_oriented_thick_pol3D.py @@ -1,12 +1,12 @@ import pytest import torch from waveorder import stokes -from waveorder.models import inplane_anisotropic_thin_pol3d +from waveorder.models import inplane_oriented_thick_pol3d def test_calculate_transfer_function(): intensity_to_stokes_matrix = ( - inplane_anisotropic_thin_pol3d.calculate_transfer_function( + inplane_oriented_thick_pol3d.calculate_transfer_function( swing=0.1, scheme="5-State", ) diff --git a/waveorder/models/inplane_anisotropic_thin_pol3d.py b/waveorder/models/inplane_oriented_thick_pol3d.py similarity index 100% rename from waveorder/models/inplane_anisotropic_thin_pol3d.py rename to waveorder/models/inplane_oriented_thick_pol3d.py