Skip to content

fourier_ratio_deconvolution raises TypeError due to estimate_parameters return value in HyperSpy 2.4.0 and exSpy 0.3.2 #173

Description

@wcdyang

Describe the bug

Calling EELSSpectrum.fourier_ratio_deconvolution() with the default extrapolate_coreloss=True raises a TypeError: cannot unpack non-iterable bool object. The error occurs in power_law_extrapolation (exspy/signals/eels.py:1291), where pl.estimate_parameters(..., out=True) is expected to return a tuple (A, r) of fitted parameters. However, in HyperSpy 2.4.0, estimate_parameters with out=True returns a bool (success/failure flag) instead. The two packages' APIs seem to be out of sync.

To Reproduce

Steps to reproduce the behavior:

import hyperspy.api as hs
s_ll = hs.load('EELS Spectrum Image (low-loss).dm3')
s_cl = hs.load('EELS Spectrum Image (high-loss).dm3')
s_deconv = s_cl.fourier_ratio_deconvolution(low_loss=s_ll)

Expected behavior

Full traceback:

File .../exspy/signals/eels.py:1036, in EELSSpectrum.fourier_ratio_deconvolution(...)
    cl = self.power_law_extrapolation(window_size=20, extrapolation_size=100)

File .../exspy/signals/eels.py:1291, in EELSSpectrum.power_law_extrapolation(...)
    A, r = pl.estimate_parameters(
        s,
        axis.index2value(axis.size - window_size),
        axis.index2value(axis.size - 1),
        out=True,
    )

TypeError: cannot unpack non-iterable bool object

Python environement:

  • eXSpy version: 0.3.2
  • HyperSpy version: 2.4.0
  • Python version: 3.14.3

Additional context

The workaround is to disable extrapolation:

s_deconv = s_cl.fourier_ratio_deconvolution(
    low_loss=s_ll,
    extrapolate_coreloss=False,
    extrapolate_lowloss=False
)

However, disabling extrapolation causes significant Fourier ringing artefacts in the deconvolved spectrum, making the workaround unsuitable for practical use.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions