Re: [hyperspy-devel] set initial parameter to multifit

45 views
Skip to first unread message

Francisco de la Peña

unread,
Feb 28, 2013, 7:10:22 AM2/28/13
to hypersp...@googlegroups.com, hypersp...@googlegroups.com
Dear Alberto,

By default Hyperspy uses as starting parameters the result of the fit at the previous coordinates. Of course, this has the drawback that, if something goes wrong at a given position, the error may propagate to all following  fits.

As you propose, one way to solve this problem is to set the starting parameters manually. For that you need to:
  1. Define the starting values at the coordinates of your choice in  parameter.map['values']
  2. Set parameter.map['is_set'] of the same coordinates to `True` 

If what you want to do is to set the current values as starting parameters for the whole dataset you can do it more conveniently, parameter by parameter, using Parameter.assign_current_value_to_all() . Probably it would be good to have an equivalent of this function in Model that acts on all the active components.

An alternative way to avoid these sort of problems is to use a mask to instruct the fitter not to fit at certain positions where you know that it won't fit well.

Another possibility (that requires new development) is to calculate the reduced chi square after each fit and, e.g. if it is found to be much worst than that of the previous position or bigger than a certain threshold, then the result of the fit is not used as starting parameters for the next position.

Does these help you with your problem?


Best,


Francisco

PS: by the way, because this post can be of general interest I have carbon copied hyperspy-users. Could you reply to that post instead?



2013/2/28 Alberto Eljarrat Ascunce <krr...@gmail.com>
Dear everyone, 

when using multifit to fit big spectrum images I have been running into the same problem. The single fit works fine on single spectra, and multifit can deal with the fitting until some pixel breaks it and it ceases to give good results. Please find attached to this email a picture to illustrate this behavior.

I have tried to set the initial parameters for the fit a) generally with the parameter.value, and, b) using parameter.map['values'] for each pixel. But I don't know which is really used for initial parameter in the individual fits performed by multifit. 

I think that this problem may come from the updating of each individual fit. Each parameter in the components of the model being updated to the result, through parameter.value, instead of the initial parameter.value or the value in parameter.map['values'].

My question is, which are the input parameters for each individual fit in multifit, and how can one set them beforehand?

Thanks everyone,
Alberto.

--
You received this message because you are subscribed to the Google Groups "hyperspy-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hyperspy-deve...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Alberto

unread,
Feb 28, 2013, 8:20:02 AM2/28/13
to hypersp...@googlegroups.com
Dear Francisco, 

thank you for the reply, it is very helpful for me to know how multifit works. I have tried the solution and setting the parameters with map improves a lot the results. But I am not sure about setting the parameter.map['is_set'] of the same coordinates to 'True'. When I do this the parameters for this coordinates are not fitted, the stay fixed (as if paramer.free == 'False').

Is this the expected behavior?

thank you again,
Alberto.


2013/2/28 Francisco de la Peña <frande...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "hyperspy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hyperspy-user...@googlegroups.com.

Francisco de la Peña

unread,
Feb 28, 2013, 9:10:39 AM2/28/13
to hypersp...@googlegroups.com
Alberto,

No this behaviour is not expected. I have not being able to reproduce it, could you send an example, ideally in the form of a script?

Best,

Francisco

2013/2/28 Alberto <krr...@gmail.com>

Alberto

unread,
Feb 28, 2013, 2:31:20 PM2/28/13
to hypersp...@googlegroups.com
Dear Francisco, 

I have redone some more times these fittings, and the results this time were correct. Maybe I had done something wrong in between, and this messed with my results.

Thank you again for you help and sorry to bother!
Alberto.
Reply all
Reply to author
Forward
0 new messages