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

Issue event-related MIPAC #22

Open
Sgas0000 opened this issue Feb 16, 2024 · 0 comments
Open

Issue event-related MIPAC #22

Sgas0000 opened this issue Feb 16, 2024 · 0 comments

Comments

@Sgas0000
Copy link

Sgas0000 commented Feb 16, 2024

Hello!

I am trying to implement an event-related MIPAC on my data, but I encountered an error that I struggle to solve.

Here is my EEG objet :

EEG = 

  struct with fields:

               group: ''
             session: []
            comments: []
              icaact: []
             icawinv: []
           icasphere: []
          icaweights: []
         icachansind: []
          urchanlocs: []
            chaninfo: []
                 ref: ''
               event: []
             urevent: []
    eventdescription: []
               epoch: []
    epochdescription: []
              reject: []
               stats: []
            specdata: []
          specicaact: []
          splinefile: []
       icasplinefile: ''
              dipfit: []
             history: ''
               saved: ''
                 etc: []
             datfile: ''
                 run: []
             subject: ''
           condition: ''
             setname: ''
            filename: ''
            filepath: ''
            chanlocs: [1×2 struct]
             nbchan: 2
                data: [2×1000×20 double]
               srate: 500.0000
                pnts: 1000
               times: [-0.4980 -0.4960 -0.4940 -0.4920 -0.4900 -0.4880 -0.4860 -0.4840 -0.4820 -0.4800 … ] (1×1000 double)
                xmin: -0.4980
                xmax: 1.5000
              trials: 20

And here is the part of my code where I apply the pop_pac() function :

nbins = 20 ; 
flow  = 2:1:29;  
fhigh = 30:5:150; 

EEG = pop_pac(EEG,'Channels',[flow(1),flow(end)],[fhigh(1),fhigh(end)],1,2,'method','ermipac','nbinskl',nbins,'nfreqs1',length(flow),'nfreqs2',length(fhigh),'bonfcorr',0);

When i run pop_pac() I have this error :

Unrecognized function or variable 'pacstruct'.

Error in eeg_pac (line 561)
                pacstruct.ermipac.pacval(i,j,k,:) = filtfilt(b,a,squeeze(pacstruct.ermipac.pacval(i,j,k,:))');

Error in pop_pac (line 440)
        [~, ~, freqs1, freqs2, alltfX, alltfY,~, pacstruct, tfXtimes, tfYtimes] = eeg_pac(X, Y, EEG.srate,  options{:});

I am wondering if the error is coming from the eeg_pac() function code here :

% Loop  phase frequencies
for find1 = 1:length(freqs1)
    if strcmpi(g.verbose, 'on')
        fprintf('Progress : %.2f %% \n', 100*(find1-1)/length(freqs1));
    end
    % Defining time vector and other stuff before runnning the loops
    if strcmp(g.method, 'ermipac')
        windowsearchsize = round(srate/freqs1(find1));
        micomplimits = [round(windowsearchsize/2)+1 ti_loopend-round(windowsearchsize/2)-1]; 
        tindxvector = micomplimits(1):micomplimits(2); %%%% HERE
    else
        tindxvector = 1:ti_loopend;
        windowsearchsize = [];
    end

In fact, there is a problem here cause tindxvector is empty because micomplimits(1) cause is positive and micomplimits(2) is negative. I tried to solve this error but as I don’t really know what is representing tindxvector I struggle a bit to understand what I am doing!

I tried to order micomplimits(1) and micomplimits(2) according to their values to obtain a non-void tindxvector :


        if micomplimits(1)<micomplimits(2)
            tindxvector = micomplimits(1):micomplimits(2);
        else
            tindxvector = micomplimits(2):micomplimits(1);
        end

But then I have another error so I think it was not a good idea :

Error using eeg_pac
Index in position 1 is invalid. Array indices must be positive integers or logical values.

Error in pop_pac (line 440)
        [~, ~, freqs1, freqs2, alltfX, alltfY,~, pacstruct, tfXtimes, tfYtimes] = eeg_pac(X, Y, EEG.srate,  options{:});

Have you already encountered this error? If yes, do you know how to solve it?

Thanks a lot for your help!!!

@Sgas0000 Sgas0000 changed the title Error event-related MIPAC Issue event-related MIPAC Feb 16, 2024
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

1 participant