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

Trouble selecting data #4

Open
alapo opened this issue Sep 17, 2020 · 5 comments
Open

Trouble selecting data #4

alapo opened this issue Sep 17, 2020 · 5 comments

Comments

@alapo
Copy link

alapo commented Sep 17, 2020

I am attempting to replicate the analyses used in the paper. I have created a reproducible example below where 3 EEG files of 180 seconds are created. The data has 3 epochs of 60 seconds.

  1. Pre-oxy
  2. Surgery-S1
  3. PACU

I continue to get the following error img

I have also attempted to run each epoch individually (so there are no events) and I get the same error.

Below is my code
required files (events and channels).zip

%% Create fake data and save it as a *.mat file
load('C:\Program Files\MATLAB\R2019b\toolbox\nnet\nndemos\private\eegdata.mat')
x = eegdata;
clear eegdata
data = [repmat(x,16,112)];
data = data(:, 1:45000);

EEGdir = 'C:\Users\Gertrude\Desktop\Microstates\raw\Merged\GitHub\';

% Create 3 identical copies which I will import into eeglab with event
% information
save(strcat(EEGdir, 'S01.mat'), 'data');
save(strcat(EEGdir, 'S02.mat'), 'data')
save(strcat(EEGdir, 'S03.mat'), 'data')

%% 3.3.1 Loading datasets in EEGLAB

EEGdir = 'C:\Users\Gertrude\Desktop\Microstates\raw\Merged\GitHub\';
EEGFiles = dir([EEGdir '*.mat']);

for i = 1:length(EEGFiles)
    
    EEG = pop_importdata('dataformat','matlab','nbchan',0,'data',strcat(EEGdir,'\', EEGFiles(i).name),...
        'setname', strcat(EEGFiles(i).name(1:3), '-merged'),'srate',250,'subject', EEGFiles(i).name(1:3),'pnts',0,'xmin',0,...
        'chanlocs','C:\\Users\\Gertrude\\Desktop\\Microstates\\raw\\Merged\\GitHub\\chanlocs.ced');
    
    EEG = pop_importevent( EEG, 'event','G:\\My Drive\\Projects\\Anesthesiology\\Surgical EEGs\\Microstates\\raw\\events.txt','fields',{'latency' 'type' 'position'},'skipline',1,'timeunit',1);
    EEG = pop_reref( EEG, []); % take the average reference
    % save new .set
    EEG = pop_saveset( EEG, 'filename',strcat(EEGFiles(i).name(1:3) ,'-Interp.set'),'filepath','C:\\Users\\Gertrude\\Desktop\\Microstates\\raw\\Merged\\GitHub\\');
    [ALLEEG, EEG, CURRENTSET] = eeg_store( ALLEEG, EEG, 0 ); % store it
end
    eeglab redraw % updates EEGLAB GUI

[ALLEEG EEG CURRENTSET ALLCOM] = eeglab;
STUDY = []; CURRENTSTUDY = 0; ALLEEG = []; EEG=[]; CURRENTSET=[]; % clear eeglab

%% 3.3.2 Select data for microstate analysis
[EEG, ALLEEG] = pop_micro_selectdata( EEG, ALLEEG, 'datatype', 'spontaneous',...
'avgref', 1, ...
'normalise', 0, ...
'MinPeakDist', 10, ...
'Npeaks', 1000, ...
'GFPthresh', 1, ...
'dataset_idx', 1:3 );

% causes error seen here -->  https://i.imgur.com/DaPoBNu.png
@alapo
Copy link
Author

alapo commented Sep 28, 2020

Just wanted to follow up that the example contained within the original paper currently does not work.

EEGdir = 'C:\Users\Gertrude\Desktop\Microstates\raw\Poulsen Example\Microstate\EEG\';
EEGFiles = dir([EEGdir '*.set']);

for i = 1:length(EEGFiles)
    EEG = pop_loadset('filename',EEGFiles(i).name,'filepath',EEGdir);
    [ALLEEG, EEG, CURRENTSET] = eeg_store( ALLEEG, EEG, 0 );
    eeglab redraw % updates EEGLAB GUI    
end

%% 3.3.2 Select data for microstate analysis
[EEG, ALLEEG] = pop_micro_selectdata( EEG, ALLEEG, 'datatype', 'spontaneous',...
'avgref', 1, ...
'normalise', 0, ...
'MinPeakDist', 10, ...
'Npeaks', 1000, ...
'GFPthresh', 1, ...
'dataset_idx', 1:4 );

The error is shown below

Error using findpeaks
Too many input arguments.

Error in pop_micro_selectdata (line 172)
        [~, peakidx{i,1}] = findpeaks(GFP,'MinPeakDistance',MinTFdistance);

@vincent5290
Copy link

MEET THE SAME PROBLEMS

@alapo
Copy link
Author

alapo commented Jun 14, 2021

@vincent5290 I'm not sure if I understand...are you saying you are having the same problem as I reported?

@vincent5290
Copy link

vincent5290 commented Jun 14, 2021 via email

@rellks
Copy link

rellks commented Nov 18, 2021

I had the same problem. Try running >>which findpeaks and see if the path is from MATLAB toolbox and not another custom path. Using findpeaks from MATLAB\R2020b\toolbox\signal\signal\findpeaks.m worked for me.

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

3 participants