fooof-tools / fooof_mat

A Matlab wrapper for spectral parameterization.
MIT License
41 stars 20 forks source link

fm.fit taking forever #21

Open iyangand opened 3 years ago

iyangand commented 3 years ago

in the matlab wrapper fooof.m, I can get through the first few lines just fine, but then when the line "fm.fit(freqs, power_spectrum, f_range)" is executed, it's taking forever.

I think this is not a matlab/python problem since the first few lines run just fine (e.g. py.numpy.array, pylist, etc.).

I'm using python 3.7 w/ cpython on matlab 2020a.

TomDonoghue commented 3 years ago

We would need some more information to be able to troubleshoot this. Does model fitting finish at all, or is it hanging? How long is "forever"? What is the data you are trying to fit and what settings are you using?

iyangand commented 3 years ago

Thank you for quick response!

I am simply running the cell in 'fooof_example_one_spectrum.m', using the provided data in 'ch_dat_one.mat'

The model never finishes even when I let it run for >10 minutes.

I tried changing the default settings as follows, and still have the same issue. settings.peak_width_limits=[2 5]; settings.max_n_peaks=2; settings.min_peak_height=0.1; settings.peak_threshold=2; settings.aperiodic_mode='fixed'; settings.verbose=true;

EricKolibacz commented 3 years ago

Same here. But I get one additional output warning:

FOOOF WARNING: Lower-bound peak width limit is < or ~= the frequency resolution: 0.98 <= 0.50
    Lower bounds below frequency-resolution have no effect (effective lower bound is the frequency resolution).
    Too low a limit may lead to overfitting noise as small bandwidth peaks.
    We recommend a lower bound of approximately 2x the frequency resolution.

Some details of my Machine:

ans =

PythonEnvironment with properties:

      Version: "3.8"
   Executable: "/home/eric/venvs/fooof/bin/python3"
      Library: "libpython3.8.so.1.0"
         Home: "/home/eric/venvs/fooof"
       Status: Loaded
ExecutionMode: InProcess
    ProcessID: "8933"
  ProcessName: "MATLAB"
The installed packages are
```source
(fooof) eric@XXX:~$ pip list
Package       Version
------------- -------
fooof         1.0.0  
numpy         1.20.2 
pip           20.0.2 
pkg-resources 0.0.0  
scipy         1.6.3  
setuptools    44.0.0
EricKolibacz commented 3 years ago

I was able to solve it with the answer on StackOverflow. As the answer suggests "this issue sometimes can arise when Python attempts to use the MathWorks version of libcrypto". Just run:

py.sys.setdlopenflags(int32(10))
py.importlib.import_module('ssl')

and you should be good to go.