atpoulsen / Microstate-EEGlab-toolbox

Microstate EEGlab toolbox
45 stars 19 forks source link

Trouble selecting data #4

Open alapo opened 3 years ago

alapo commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

MEET THE SAME PROBLEMS

alapo commented 3 years ago

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

vincent5290 commented 3 years ago

true, how do u figure out

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: alapo @.> Sent: Tuesday, June 15, 2021 12:24:12 AM To: atpoulsen/Microstate-EEGlab-toolbox @.> Cc: Zeng Xinglin @.>; Mention @.> Subject: Re: [atpoulsen/Microstate-EEGlab-toolbox] Trouble selecting data (#4)

@vincent5290https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_vincent5290&d=DwMCaQ&c=KXXihdR8fRNGFkKiMQzstu-8MbOxd1NuZkcSBymGmgo&r=q2DYoCrvcIEc1BFL24je5g&m=CI2ccJC4WTfSCA-XpKtyJNiLC1pEd0tGS7gvCFvxlpU&s=PSMiCh_vZUAkKiVK5R6mQuF3M56cUbw53wbZQKkXvUE&e= I'm not sure if I understand...are you saying you are having the same problem as I reported?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_atpoulsen_Microstate-2DEEGlab-2Dtoolbox_issues_4-23issuecomment-2D860817463&d=DwMCaQ&c=KXXihdR8fRNGFkKiMQzstu-8MbOxd1NuZkcSBymGmgo&r=q2DYoCrvcIEc1BFL24je5g&m=CI2ccJC4WTfSCA-XpKtyJNiLC1pEd0tGS7gvCFvxlpU&s=e1gGlwD-18jw8Zo67-opniutbogSkG0mDXrahn04NIc&e=, or unsubscribehttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_ASYUESINQD2YRW7RGOLKEW3TSYUKZANCNFSM4RQ2WUVA&d=DwMCaQ&c=KXXihdR8fRNGFkKiMQzstu-8MbOxd1NuZkcSBymGmgo&r=q2DYoCrvcIEc1BFL24je5g&m=CI2ccJC4WTfSCA-XpKtyJNiLC1pEd0tGS7gvCFvxlpU&s=z5qDEPvVKysT_1cQgtIT3XvNm-0T37aHvCJIHqd1PTY&e=.

rellks commented 2 years ago

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.