SamFire hangs/error

68 views
Skip to first unread message

Luiz Tizei

unread,
Sep 9, 2016, 8:38:54 AM9/9/16
to hyperspy-users
I am trying to run SamFire on a spectrum image. I have created a model for the spectrum image and I can successfully fit one seed. However, when I try to start SamFire with samf.start(fitter='mpfit', bounded=True) I get the following error (after a few seconds and with a new figure opened with 7 subgraphs):

  0%|                                                                           | 0/3068 [00:00<?, ?it/s]C:\Program Files\HyperSpy WinPython Bundle v1.1\python-3.5.1.amd64\lib\site-packages\matplotlib\axes\_base.py:3045: UserWarning: Attempting to set identical bottom==top results
in singular transformations; automatically expanding.
bottom=0, top=0.0
  'bottom=%s, top=%s') % (bottom, top))

I am also joining the notebook I am running, in case it gives some useful input.

Thanks !

Luiz
SamFireTrial.ipynb

Tomas Ostasevicius

unread,
Sep 9, 2016, 10:00:00 AM9/9/16
to hyperspy-users
Hi Luiz,

The problem seems to be twofold:
 1. I forgot to add a way to update the goodness_test tolerance for samfire workers (the processes that perform individual pixel fits), sorry about that. It's trivial to fix in the code, however for you to get it may be more tricky, depending how you installed hyperspy in the first place.
 2. You need to change the gooness_test tolerance! This generally means that either your model or your variance estimation is wrong. 

Sadly, due to the first problem (again, my bad..) the temporary solution would be to cheat terribly - for example this:

# first estimate the variance whatever it may be
s.estimate_poissonian_noise_variance()

# then set up the model and fit the pixel as you did previously...
# [skipped, just run the same]

# then import numpy
import numpy as np

# and find what's the current mean value for the reduced chi-squared
thevalue = np.nanmean(m.red_chisq.data)

# and then estimate the variance again, but this time scaled such that the red_chisq will hopefully be around 1
s.estimate_poissonian_noise_variance(gain_factor=thevalue)

# after this, re-run the pixel fit
m.fit() # optionally with any arguments you used before

# and plot the reduced chi-squared, to check that the values are reasonable (i.e. hopefully less than 2)
m.red_chisq.plot()

# Continue to create samfire, as previously
....


Sorry that it's so backwards and cheating - I'll fix it in the next version

Tomas


--
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.
For more options, visit https://groups.google.com/d/optout.

Luiz Tizei

unread,
Sep 9, 2016, 1:55:19 PM9/9/16
to hyperspy-users
Hi Thomas,

It has worked! I got the report with seemly correct distributions for the center of the gaussian and fwhm. I will make some more trials to see if all is good.


Sorry for the pedestrian second question. Where can I have access to these values (center, amplitude, fwhm)? Is it somewhere in m.components?

Thanks!

Luiz

Thomas Aarholt

unread,
Sep 9, 2016, 2:38:25 PM9/9/16
to hypersp...@googlegroups.com
Hi Luiz,

Different Thomas answer, here:

I believe SAMFire still updates the components as normal, so you can access the values like you set them in the notebook you included in a previous email:

g1.A.value

Here A is the amplitude. For a gaussian, you also have centre and sigma.

If you would like to export these for your spectrum image, you can do

g1A = g1.A.as_signal()

in order to get signals with the values in them.

- Tom

Thomas Aarholt


Luiz Tizei

unread,
Sep 10, 2016, 1:48:24 AM9/10/16
to hyperspy-users
Hi Thomas,

Thanks for the reply. g1A = g1.A.as_signal() this does exactly what I was aiming for.

And sorry Tomas for misspelling your name in my first reply. 

Cheers,

Luiz
Reply all
Reply to author
Forward
0 new messages