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

Unrecognized function or variable 'desired_nfreq'. #34

Closed
YaronLa opened this issue Apr 17, 2023 · 9 comments
Closed

Unrecognized function or variable 'desired_nfreq'. #34

YaronLa opened this issue Apr 17, 2023 · 9 comments

Comments

@YaronLa
Copy link

YaronLa commented Apr 17, 2023

I have been trying to follow the ROI tutorial, but I have run into some trouble. Specifically, when I attempt to compute Coherence and cross spectrum, I receive the same error. I have attached the code along with the error messages for reference.

If anyone have any ideas or suggestions on how to resolve this issue, I would be extremely grateful for the help.

EEG = pop_dipfit_settings( EEG, 'hdmfile','path_to_file','path_to_file,'path_to_file','coordformat','MNI','coord_transform',[0 0 0 0 0 0 1 1 1] ,'chansel',[1:61] );
EEG = pop_multifit(EEG, [1:55] ,'threshold',100,'plotopt',{'normlen','on'});
EEG = pop_roi_activity(EEG, 'leadfield',EEG.dipfit.sourcemodel,'model','LCMV','modelparams',{0.05},'atlas','LORETA-Talairach-BAs','nPCA',3, 'fooof', 'off');
EEG = pop_roi_connect(EEG, 'methods', { 'CS', 'COH'}, 'snippet', 'on', 'snip_length', 60, 'fcsave_format', 'mean_snips');

#Error message from roi_connect
Unrecognized function or variable 'desired_nfreq'.

Error in data2cs_event (line 114)
        if desired_nfreq ~= 0

Error in data2spwctrgc (line 108)
    CS = data2cs_event(data(:, :)',ndat, ndat - (floor(ndat/2)), ndat , [], CSpara);

Error in roi_connect (line 121)
        conn_mult = data2spwctrgc(source_roi_data, EEG.pnts, g.morder, 0, g.naccu, [], tmpMethods2);

Error in pop_roi_connect (line 219)
        EEG = roi_connect(EEG, 'morder', g.morder, 'naccu', g.naccu, 'methods', g.methods,'freqresolution',g.freqresolution); % compute connectivity over one snippet
@nguyen-td
Copy link
Collaborator

nguyen-td commented Apr 18, 2023

Thanks, I was able to reconstruct the error and will work on it today.

@arnodelorme
Copy link
Collaborator

Should be fixed in eb43bef

@YaronLa
Copy link
Author

YaronLa commented Apr 25, 2023

Thank you for the help. I can now calculate Cross-spectrum as well! However, There are still several connectivities that are giving error codes. I hope you can help.
When calculating Coherence:

EEG = pop_roi_connect(EEG, 'methods', {'COH'}, 'snippet', 'on', 'snip_length', 60, 'fcsave_format', 'mean_snips', 'freqresolution', 0);

Index in position 3 exceeds array bounds. Index must not exceed 101.

Error in data2spwctrgc (line 116)
            pow = real(diag(CS(:,:,ifreq)));

Error in roi_connect (line 121)
        conn_mult = data2spwctrgc(source_roi_data, EEG.pnts, g.morder, 0, g.naccu, [], tmpMethods2);

Error in pop_roi_connect (line 219)
        EEG = roi_connect(EEG, 'morder', g.morder, 'naccu', g.naccu, 'methods', g.methods,'freqresolution',g.freqresolution); % compute connectivity over one snippet

Error in eeg_eval (line 136)
            TMPEEG = feval(func, TMPEEG, g.params{:});

Error in pop_roi_connect (line 183)
            [ TMPEEG, com ] = eeg_eval( 'pop_roi_connect', TMPEEG, 'params', optionsSubj );

When calculating GC, PDC and DTF I recieve following error:

EEG = pop_roi_connect(EEG, 'methods', {'GC'}, 'snippet', 'on', 'snip_length', 60, 'fcsave_format', 'mean_snips', 'freqresolution', 0);

Error using schur
Input to SCHUR must not contain NaN or Inf.

Error in lyapslv (line 11)
[U,T] = schur(A);

Error in dlyap (line 64)
X = lyapslv('D',A,[],-Q);

Error in varma2iss (line 44)
O=dlyap(A,K*R*K');

Error in data2sctrgcmim (line 220)
          [eA2, eC2, eK2, eV2, eVy2] = varma2iss(reshape(A, nsubsetvars, []), [], SIG, eye(nsubsetvars));

Error in roi_connect (line 98)
        conn_mult = data2sctrgcmim(source_roi_data, EEG.pnts, g.morder, 0, g.naccu, [], inds, tmpMethods1, [], 'freqresolution', g.freqresolution);

Error in pop_roi_connect (line 219)
        EEG = roi_connect(EEG, 'morder', g.morder, 'naccu', g.naccu, 'methods', g.methods,'freqresolution',g.freqresolution); % compute connectivity over one snippet

Error in eeg_eval (line 136)
            TMPEEG = feval(func, TMPEEG, g.params{:});

Error in pop_roi_connect (line 183)
            [ TMPEEG, com ] = eeg_eval( 'pop_roi_connect', TMPEEG, 'params', optionsSubj );

There should be no such input as far as I am aware.
If you have any ideas or suggestions on how to resolve this issue, I would be extremely grateful for the help.

@CPernet CPernet reopened this Apr 30, 2023
@CPernet
Copy link

CPernet commented Apr 30, 2023

@arnodelorme is there still a problm with the freq vector

Error in data2spwctrgc (line 116)
            pow = real(diag(CS(:,:,ifreq)));

it seems it reaches beyond the size of the cross frequency sprectrum

@nguyen-td
Copy link
Collaborator

nguyen-td commented Apr 30, 2023

The first problem should be fixed with #36 / d820d24 but needs to be accepted first

@YaronLa
Copy link
Author

YaronLa commented May 1, 2023

Thank you very much. Now both Cross-Spectrum and Coherence is working! Now I only have the 'schur' issue when calculating GC, PDC and DTF

@stefanhaufe
Copy link
Collaborator

Hi, if I get a minimal working example (ideally including data), I can look into that. It does not sounds like a DTF or PDC issue but more like a GC issue, as varma2iss is not used by DTF/PDC.

I suspect a problem related to singularity or ill-conditioning of the data or cross-spectral matrices, especially in combintion with the "conditional" version of GC, or when calculating these multivariate measures on spaces that are too high-dim compared to the rank of the data.

@nguyen-td
Copy link
Collaborator

We have some very basic pipelines in the test_pipes folder, e.g., pipeline_connectivity.m . Here, we load some sample EEGLAB data and run the pipeline. I replaced

measures = { 'CS' 'COH' 'DTF' 'wPLI' 'PDC' 'MIM' 'MIC' 'GC' };
measures = { 'CS' 'COH' 'wPLI' 'PDC' 'MIM' 'MIC' 'GC' };
measures = { 'CS' 'COH' 'MIM' 'GC' };
measures = { 'CS' 'COH' 'MIM' };
measures = { 'TRGC' 'MIM' };
measures = { 'MIM' };
with only measures = { 'DTF' 'PDC' 'GC' }; and did not receive any errors after calling pop_roi_connect(), so it might have something to do with your data.

If possible, could you please confirm this by running the pipeline yourself and tell us if it works or not?

arnodelorme pushed a commit that referenced this issue May 3, 2023
@arnodelorme
Copy link
Collaborator

OK, I have merged the request. Feel free to reopen if the bug persist.

CPernet added a commit to LIMO-EEG-Toolbox/RestingState that referenced this issue May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants