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

Struggling with matching HoloPy simulation to experimental holographic images - need advice #448

Open
73Emilie opened this issue Nov 28, 2024 · 3 comments

Comments

@73Emilie
Copy link

I'm having some trouble with my holography project and could really use some help.

I'm trying to match experimental holographic images with simulated ones generated by HoloPy, but the results aren't great. Here's my situation:

In my experiments, I'm using an LED light source (haven't tried laser yet), and I'm trying to locate particles that are about 10 microns away from the focal plane. Even though I know where the particles should be, when I try to match the experimental images with simulated ones (using either pixel differences or radial intensity profiles), I'm getting errors of more than 5 microns, and these errors seem pretty random. When visually comparing experimental and simulated images under the same conditions, I've noticed that some of the fine fringe structures don't quite match up (which might be due to the light source's coherence issues). This structural mismatch leads to significant errors when using algorithmic matching approaches.

I suspect the LED's lower coherence might be causing issues, but before I switch to a laser setup, I'd like to know if there could be other problems I'm missing. Even though I'm using Mie theory with lens effects in the simulation, I'm wondering if working so close to the focal plane (0-10 microns) could be making things worse?

Has anyone dealt with similar matching problems? Any insights would be really helpful, especially:

What else besides coherence could be causing these matching issues?
Is working near the focal plane making things more difficult?
Any suggestions for improving the matching accuracy?
Thanks in advance for any help!

@vnmanoharan
Copy link
Contributor

Working close to the focal plane might be an issue if the resolution of your camera isn't sufficient to detect the fringes. Could you please post your experimental and simulated holograms, along with the code you are using to calculate the hologram? Also what are the output parameters of your LED (wavelength, bandwidth)?

@73Emilie
Copy link
Author

73Emilie commented Dec 5, 2024

Working close to the focal plane might be an issue if the resolution of your camera isn't sufficient to detect the fringes. Could you please post your experimental and simulated holograms, along with the code you are using to calculate the hologram? Also what are the output parameters of your LED (wavelength, bandwidth)?

Thank you very much for your response.Below are the results of my attempts using a monochromatic LED light source with a wavelength of 530 nm and a bandwidth of approximately 10-30 nm.

I have categorized the difficulties I encountered as follows:

1. Particles Below the Focal Plane: Inaccurate Matching of Central Fringe Patterns

Comparison: Experimental image at z = -2.5 μm vs. simulation image, along with the radial intensity distribution graph.
My Confusion: The central fringe patterns cannot be precisely matched, and there are slight spatial shifts in the subsequent intensity peaks.

截屏2024-12-05 21 36 43 截屏2024-12-05 21 37 00

2. Particles Above the Focal Plane but Very Close to It (Within z = 1.5-4.5 μm): Simulation Images Are Overall Very Dark with Only the Center Being Bright, Unlike Experimental Images

2.1
Observation: From z = 1.5 μm to z = 4.5 μm, the entire simulation image is very dark.
Note: In the simulation, I set the particle diameter to 3.1 μm.
[🐰]([url](
截屏2024-12-05 20 59 54
截屏2024-12-05 20 59 59
截屏2024-12-05 21 00 05
截屏2024-12-05 21 00 11
截屏2024-12-05 21 00 17
截屏2024-12-05 21 00 21
截屏2024-12-05 20 59 50))
However, my experimental images in this range are not as dark as the simulated images:z=2μm
截屏2024-12-05 22 35 11

2.2
Observation: Within this range, there is a significant difference between the experimental and simulation images. For example, at z = +4.5 μm:
截屏2024-12-05 22 10 53
截屏2024-12-05 22 11 10

match results outside this rang:(z>4.5)
z=12.5
截屏2024-12-05 22 14 34
截屏2024-12-05 22 14 47

Observation: There are slight peak shifts and insufficient fringe resolution.
Note: In the experimental images, the focal plane was determined by eye (images consistent with z = 0 μm in simulations are considered to be on the focal plane).
截屏2024-12-05 22 22 59

4. Code Implementing the Above Functions:

# Radial intensity calculation function  
def radial_profile(data, center):  
    """  
    Calculate the radial intensity distribution of the image.  
    
    Parameters:  
    - data: 2D numpy array, image data  
    - center: tuple, center coordinates (x, y)  
    
    Returns:  
    - radialprofile: 1D numpy array, radial intensity  
    """  
    if data.ndim > 2:  
        data = data.squeeze()  
    if data.ndim != 2:  
        raise ValueError(f"data_exp should be a 2D array, but got shape {data.shape}")  
    
    y, x = np.indices(data.shape)  
    r = np.sqrt((x - center[0])**2 + (y - center[1])**2)  
    r = r.astype(int)  
    
    tbin = np.bincount(r.ravel(), data.ravel())  
    nr = np.bincount(r.ravel())  
    radialprofile = tbin / nr  
    return radialprofile  

# Basic parameter settings  
# Center coordinates of experimental image (pixels)  
a, b = 50,50  
# Center coordinates of simulated image (pixels)  
c, d = 50, 50   
pixel_spacing = 0.08833  # Pixel spacing (unit: μm)  
spacing = pixel_spacing  
x = c * spacing  
y = d * spacing  
medium_index = 1.33  
illum_wavelen = 0.530  # Illumination wavelength (unit: μm)  
NA = 1.20  
n_water = 1.33  
lens_angle = np.arcsin(NA / n_water)  
theory = MieLens(lens_angle)  
sphere_n = 1.59  
sphere_r = 1.55  # Sphere radius (unit: μm)  
polarization = (1, 0)  # X-direction polarization  

# Experimental image processing  
imagepath = get_example_data_path()  
raw_holo = hp.load_image(imagepath, spacing=pixel_spacing, medium_index=medium_index, illum_wavelen=illum_wavelen)  
print("Original image size:", raw_holo.shape)  

bgpath = [ '']  
bg = load_average(bgpath, refimg=raw_holo)  
holo_exp = bg_correct(raw_holo, bg)  
data_exp = np.array(holo_exp).squeeze()  

# Maximum value normalization for experimental image  
data_exp = data_exp / np.max(data_exp)  

if data_exp.ndim != 2:  
    raise ValueError(f"data_exp should be a 2D array, but got shape {data_exp.shape}")  

# Simulated image  
sphere = Sphere(n=sphere_n, r=sphere_r, center=(y, x, 0.0))  
detector = hp.detector_grid(shape=data_exp.shape, spacing=pixel_spacing)  

holo_sim = calc_holo(detector, sphere, medium_index, illum_wavelen,  
                illum_polarization=polarization, theory=theory)   
data_sim = np.array(holo_sim).squeeze()  

# Maximum value normalization for simulated image  
data_sim = data_sim / np.max(data_sim)  

# Ensure simulated image is also 2D  
if data_sim.ndim != 2:  
    raise ValueError(f"data_sim should be a 2D array, but got shape {data_sim.shape}")  

# Calculate radial intensity  
radial_exp = radial_profile(data_exp, center=(a, b))  
radial_sim = radial_profile(data_sim, center=(c, d))   
radius_exp = np.arange(len(radial_exp)) * pixel_spacing  
radius_sim = np.arange(len(radial_sim)) * pixel_spacing  

Due to issues like inaccurate fringe patterns, it is challenging to achieve precise matching using the fitting model provided by Holopy. Do you have any suggestions?

P.S.: I am currently also setting up an optical path using a laser light source to try it out. However, the issue mentioned in section 2.1, which is related to the simulation, should be independent of the experimental light source.

Thank you once again for your assistance and support. I truly appreciate your help.

@vnmanoharan
Copy link
Contributor

Thanks for sending these details! For the issues described in 2.1 and 2.2, the problem seems to be that the experimental holograms are saturated. The pixels at the center are at maximum brightness, so the experiment is not capturing the full range of intensities. The simulation appears dark because there is a wide range of intensities, and the image is normalized. Best option here is to retake the hologram at a lower incident intensity, so that you don't have saturation. Alternatively you can scale your experimental hologram to best match the simulation, though you will not get good agreement where the experimental hologram is saturated.

For the issue described in section 1, you can check to see if this is a result of the the bandwidth of the LED. Try simulating a hologram for a wavelength of, say 510 nm (at the lower end of the band) and at 550 nm (at the high end) and see how the fringes change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants