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

Python Error: TypeError: 'NoneType' object is not iterable #239

Closed
4srihy opened this issue Jul 13, 2022 · 3 comments
Closed

Python Error: TypeError: 'NoneType' object is not iterable #239

4srihy opened this issue Jul 13, 2022 · 3 comments
Labels

Comments

@4srihy
Copy link

4srihy commented Jul 13, 2022

While working in matlab, for some data, I am getting 'Python Error: TypeError: 'NoneType' object is not iterable' with the aperiodic_mode = 'knee'. This issue is sometimes specific to certain frequency range. How to resolve it? Code stops running when this error is thrown. Can we give any condition in matlab, so that code continues to run even after the error?

I have attaching the sample data of matlab
NoneTypeError.zip

@TomDonoghue
Copy link
Member

Hey @4srihy - I don't use Matlab, so I can't rerun the file you provided, and I can't see the trace of the error you mention. Can you write a copy of the command you are using the run fooof, and a screenshot of the error?

@4srihy
Copy link
Author

4srihy commented Jul 23, 2022

Dear Donogue,

Here is the command

fooof_ind = fooof(freqVals,SpecPower(1,:)',freq_range,settings,true);

Please note that the same command gives error for first series but works fine for second series.
Screenshot (84)

When I load the file with python and then run the following commands, it works there.

import numpy as np
from scipy.io import loadmat, savemat

from fooof import FOOOFGroup

Load the mat file

data = loadmat('abc.mat')

Unpack data from dictionary, and squeeze numpy arrays

freqs = np.squeeze(data['freqVals']).astype('double')
psds = np.squeeze(data['SpecPower']).astype('double')

fg = FOOOF(peak_width_limits=[4, 8], max_n_peaks=5, aperiodic_mode='knee')

Fit the FOOOF model on all PSDs, and report

fg.fit(freqs, psds[1,:], [20, 44])

@TomDonoghue
Copy link
Member

Hey @4srihy - sorry for dropping off / slow reply here.

Since this relates to Matlab, and the Matlab wrapper, then this issue would be better placed over on the fooof_mat repo:
https://github.com/fooof-tools/fooof_mat/

On the fooof_mat issues page (https://github.com/fooof-tools/fooof_mat/issues) there is quite a lot of discussion of how to address issues with using FOOOF in Matlab.
I think, for example, that your error might relate to this issue:
fooof-tools/fooof_mat#18

Basically, when the model fails to fit (as happens in that particular example), the Matlab wrapper fails. That's an issue with the Matlab wrapper. In general, model failing is pretty uncommon, and you should be able to avoid this by tweaking the settings. If you are getting models that fail, you should be able to just ignore these models and continue.

Since this issue is about fooof_mat, I'm going to close this issue here - but feel free to add any comments, and/or re-open this issue over on fooof_mat if you want to follow up / have more questions!

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

No branches or pull requests

2 participants