From 15b0506b06ec2bb13226e2494d3decfda27ed40f Mon Sep 17 00:00:00 2001 From: Geneva Schlafly Date: Sun, 22 Sep 2024 19:28:59 -0500 Subject: [PATCH 1/2] Plot scaled MIP with axial voxel size differs --- src/VolumeRaytraceLFM/abstract_classes.py | 7 +++---- src/VolumeRaytraceLFM/reconstructions.py | 8 ++++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/VolumeRaytraceLFM/abstract_classes.py b/src/VolumeRaytraceLFM/abstract_classes.py index aa1ef65..92704e0 100644 --- a/src/VolumeRaytraceLFM/abstract_classes.py +++ b/src/VolumeRaytraceLFM/abstract_classes.py @@ -477,8 +477,8 @@ def rays_through_vol(pixels_per_ml, naObj, nMedium, volume_ctr_um): pixel behind each lenslet naObj (float): numerical aperture of the objective lens nMedium (float): refractive index of the volume - volume_ctr_um (np.array): 3D vector containing the coordinates of the center of the - volume in volume space units (um) + volume_ctr_um (np.array): 3D vector containing the coordinates of the center + of the volume in volume space units (um) Returns: ray_enter (np.array): (3, X, X) array where (3, i, j) gives the coordinates within the volume ray entrance plane for which the @@ -909,8 +909,7 @@ def _filter_invalid_rays( ) def compute_ray_collisions(self, ray_enter, ray_exit, voxel_size_um, vol_shape): - """ - Computes parameters for collisions of rays with voxels. + """Computes parameters for collisions of rays with voxels. For each ray defined by start (ray_enter) and end (ray_exit) points, calculates the intersected voxels and lengths of intersections within a volume of given shape (vol_shape) and voxel size (voxel_size_um). diff --git a/src/VolumeRaytraceLFM/reconstructions.py b/src/VolumeRaytraceLFM/reconstructions.py index af2090f..eb7f0d9 100644 --- a/src/VolumeRaytraceLFM/reconstructions.py +++ b/src/VolumeRaytraceLFM/reconstructions.py @@ -950,8 +950,12 @@ def visualize_and_save(self, ep, fig, output_dir): Delta_n = volume_estimation.get_delta_n().detach().unsqueeze(0) else: Delta_n = volume_estimation.get_delta_n().detach().unsqueeze(0) - mip_image = convert_volume_to_2d_mip(Delta_n) - mip_image_np = prepare_plot_mip(mip_image, plot=False) + vol_size_um = self.optical_info["voxel_size_um"] + rel_scaling_factor = vol_size_um[0] / vol_size_um[2] + mip_image = convert_volume_to_2d_mip( + Delta_n, scaling_factors=(1, 1, rel_scaling_factor) + ) + mip_image_np = prepare_plot_mip(mip_image, plot=True) plot_iteration_update_gridspec( self.birefringence_mip_sim, self.ret_img_meas, From 69d4889a3d400438b7f8a4d8b987ff3302fc9989 Mon Sep 17 00:00:00 2001 From: Geneva Schlafly Date: Sun, 22 Sep 2024 19:39:23 -0500 Subject: [PATCH 2/2] Test axial voxels on spicule --- config/spicule/iter_config.json | 4 ++-- config/spicule/optical_config.json | 4 ++-- recon_scripts/spicule.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config/spicule/iter_config.json b/config/spicule/iter_config.json index 2114ec4..e664780 100644 --- a/config/spicule/iter_config.json +++ b/config/spicule/iter_config.json @@ -1,5 +1,5 @@ { - "n_epochs": 10, + "n_epochs": 100, "regularization_weight": 0.5, "lr": 1e-3, "lr_birefringence": 1e-3, @@ -10,7 +10,7 @@ "datafidelity": "euler", "regularization_fcns": [ ["birefringence active L2", 10000], - ["birefringence active negative penalty", 1000000] + ["birefringence active negative penalty", 1000] ], "nerf_mode": false, "from_simulation": false, diff --git a/config/spicule/optical_config.json b/config/spicule/optical_config.json index 9de4e2c..c2ad9b2 100644 --- a/config/spicule/optical_config.json +++ b/config/spicule/optical_config.json @@ -1,7 +1,7 @@ { "volume_shape" : [31, 110, 110], - "axial_voxel_size_um" : 1.0, - "cube_voxels" : true, + "axial_voxel_size_um" : 6.75, + "cube_voxels" : false, "pixels_per_ml" : 16, "n_micro_lenses" : 94, "n_voxels_per_ml" : 1, diff --git a/recon_scripts/spicule.py b/recon_scripts/spicule.py index 5dc45f4..cfba5bd 100644 --- a/recon_scripts/spicule.py +++ b/recon_scripts/spicule.py @@ -131,6 +131,6 @@ def recon_spicule( init_vol_path = None recon_spicule( init_vol_path, - "debug", + "axial_voxels", load_rays=True )