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

Details of point spread function #5

Closed
CodyCBakerPhD opened this issue Apr 1, 2024 · 3 comments
Closed

Details of point spread function #5

CodyCBakerPhD opened this issue Apr 1, 2024 · 3 comments
Assignees

Comments

@CodyCBakerPhD
Copy link
Member

Extended data Fig 2 shows the point-spread function of the temporal focusing but does not report the mean and standard deviation of a fit; haven't found this in the data share yet either

@CodyCBakerPhD CodyCBakerPhD self-assigned this Apr 1, 2024
@emosb
Copy link

emosb commented May 1, 2024

So depending on how you are viewing the figure, there should be a hyperlink at the bottom (below the caption) where you can download the source data for the extended figures (for this I am accessing online via https://www.nature.com/articles/s41586-023-06683-4#Sec34). There are multiple sheets in the workbook with data corresponding to the different panels of the figure. For Extended Figure 2a there is a few rows of data with the values for the x, y, and z spread shown. The mean and std are not directly reported there but can be easily computed. I can also email you the spreadsheet if that is easier on your end.

@CodyCBakerPhD
Copy link
Member Author

Wonderful, thank you!

@CodyCBakerPhD
Copy link
Member Author

For reference:

import numpy
import pandas
import scipy

# Manually download the .xlsx, import it into Google Sheets, clear the column names and other tabs, and export to .tsv

file_path = "C:/Users/theac/Downloads/point_spread_function.tsv"
table = pandas.read_table(filepath_or_buffer=file_path, header=None)

def estimate_gaussian_parameters(domain: numpy.ndarray, intensity: numpy.ndarray) -> tuple[int, int]:
    absolute_intensity = numpy.absolute(intensity)
    probability = absolute_intensity / scipy.integrate.trapezoid(y=absolute_intensity, x=domain)
    mean = scipy.integrate.trapezoid(y=probability*domain, x=domain)
    var = scipy.integrate.trapezoid(y=probability*(probability-domain)**2, x=domain)
    std = numpy.sqrt(var)
    return mean, std

x_domain = numpy.array(table.iloc[0])
x_intensity = numpy.array(table.iloc[1])  # 'normalized' by what appears to be the peak intensity; perhaps shifted too?
x_mean, x_std = estimate_gaussian_parameters(domain=x_domain, intensity=x_intensity)

# remove nans from array
x_domain = x_domain[~numpy.isnan(x_intensity)]

y_domain = numpy.array(table.iloc[2])
y_intensity = numpy.array(table.iloc[3])
nan_indices = numpy.isnan(y_domain)
y_domain = y_domain[~nan_indices]
y_intensity = y_intensity[~nan_indices]
y_mean, y_std = estimate_gaussian_parameters(domain=y_domain, intensity=y_intensity)

z_domain = numpy.array(table.iloc[4])
z_intensity = numpy.array(table.iloc[5])
nan_indices = numpy.isnan(z_domain)
z_domain = z_domain[~nan_indices]
z_intensity = z_intensity[~nan_indices]
z_mean, z_std = estimate_gaussian_parameters(domain=z_domain, intensity=z_intensity)

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