Henley13 / paper_translation_factories_2020

Methods, plots and numerical results for Chouaib et al. (2020)
BSD 3-Clause "New" or "Revised" License
4 stars 0 forks source link

3D Gaussian Fitting #6

Closed b2jia closed 4 years ago

b2jia commented 4 years ago

Thank you for publishing this great work, it really speaks to increasing effort to make science reproducible!

RE: fit_gaussian_3d, is there an example use-case available for this function? I'm interested in testing this out.

1) Specifically, the grid parameter generates an array to store an estimated 3D Gaussian (which is compared to the true data, image_spot). But the dimensions of the grid parameter - a 2D array of shape (3, V_z V_y V_x) is unfamiliar to me (why not a 3D array of size (V_z, V_y, V_x) as generated by np.mgrid()?

2) What is the order of parameters p0 - is it mu_z, mu_y, mu_x, sigma_z, sigma_yx, psf_background?

Thank you!

Henley13 commented 4 years ago

Hi @b2jia, thanks for the comment!

No there is no example of independent use of fit_gaussian_3d. I only use it internally to decompose clusters of spots. As you are not the only one recently to ask for a dedicated 3D gaussian fitting, I might add it to a future version of Big-FISH.

I answer your questions here concerning the version in this repository:

1) It is an old inheritance from a piece of Matlab code to fit a 1D function. Your proposition might work as well, if you properly adjust the code (https://stackoverflow.com/questions/12402045/mesh-grid-functions-in-python-meshgrid-mgrid-ogrid-ndgrid). Ultimately it allows the use of scipy.special.erf (not sure it would be possible for a 2D or 3D tensor) to fasten the computation.

2) The parameters we fit in p0 are mu_z, mu_y, mu_x, sigma_z, sigma_yx, psf_amplitude, psf_background.

I invite you to check the Big-FISH repository. This one is up-to-date: https://github.com/fish-quant/big-fish. In the most recent version of the package (0.4.0), not the one in this repository (0.1.0), fit_gaussian_3d is replaced by _fit_gaussian a proper private function (which handle 2D and 3D modelling by the way). Do not hesitate to open a new issue in this repository if needed!

Best,

Arthur