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

[Feature] Statistical analysis of model from data #23

Open
Divitini opened this issue Apr 27, 2020 · 3 comments
Open

[Feature] Statistical analysis of model from data #23

Divitini opened this issue Apr 27, 2020 · 3 comments

Comments

@Divitini
Copy link

It would be useful to add a quick function that calculates some parameters to estimate the homogeneity in emission in a given area.
What I did in the past was to take the fitted model from a SI and use mean and std dev of the gaussian intensity and position. Also, I had a threshold on the relative intensity of a peak so that one could have an estimate of how many of the pixels are non-emissive.
I'm currently writing that into a function, let me know if anyone has any thoughts on:

  • what statistical parameters would be interesting to evaluate
  • best practice for functions applied to a model (in case they later need to be extended)
    Also, note that there is a function in hyperspy - print_summary_statistics - but I think that a luminescence-oriented function would be better.
    I suspect that since gaussian fitting will probably be a core function for luminescence there'll need to be a unified way to fit and process the resulting data.
@jlaehne
Copy link
Contributor

jlaehne commented May 5, 2020

print_summary_statistics works on signals, so on the original data. That gives you already some idea of the homogeneity. If you have multiple peaks, you can do the statistics on an interval of the signal axis with e.g. isig. You need a fit when you want to see the homogeneity for a specific component of a multi-peak signal where either the peaks overlap or if a simple background subtraction is not sufficient. You can convert the parameters of a fit to a signal and then use the print_summary_statistics function (but one parameter at a time) if you want to use it for fit results.

In principle, we should have a models folder like in HyperSpy, in which we place some generic models for typical signal types similar to the EDS and EELS models. In some cases it may even be interesting to have some specific statistics functions for the models.

However, from my experience, one needs rather a variety of specific models for different use cases - though mostly a combination of Gaussians and Lorentzians.

I guess what you could be aiming at is a function that takes any model, identifies the components and for the components the parameters and then calculates statistics on each of those.

Additionally, it would be a possibility to have a function that takes a signal-axis interval as input and calculates statistics on the data for that interval - though in principle it is a one-liner with isig and print_summary_statistics, so maybe no extra function needed.

As in print_summary_statistics, the following would probably be a good starting point: mean, standard deviation (std), maximum (max), minimum (min), first quartile (Q1), median, and third quartile.

@jlaehne
Copy link
Contributor

jlaehne commented Jun 15, 2022

I would propose the following way forward:

  • Create a function print_model_statistics for the BaseModel class in HyperSpy.
  • This function should iterate through the components of the model,
  • and for each component determine the relevant parameters (e.g. A, sigma, centre for Gaussian).
  • The statistics for each parameter should then be printed in a table per component similar as in print_summary_statistics.
  • As mentioned above, it would be good to have the possibility to define an intensity threshold.

It should go into HyperSpy and not LumisSpy as it could then be more general for any model and could be useful also for other types of signals.

@Divitini, do you still want to work on it,? Have you already implemented something that could be a starting point? We have a student who might be able to work on it at some point?

@Divitini
Copy link
Author

Divitini commented Jul 6, 2022

Sorry for the delay on this - I'm trying to dig out the code, although it was very basic and can be rewritten easily. I might have a postdoc who could be interested in doing this. I agree on your suggestions on the best way forward, thanks a lot for that!

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

No branches or pull requests

2 participants