clc
clear
close all



str_sample=['VPfar';
            'VPfat'];
%Update the filepath according to the actual storage path of the data file in your local folder
filepath=['E:\mydrive\SynologyDrive\Code of the sliding window HOC method\data\'];
for num_files=1:2 
    for num_sample=1:40
        filename=[filepath str_sample(num_files,:) '_EEG_EOG_' num2str(num_sample) '.mat'];
        if ~exist(filename,'file')
            continue;
        end
        [EEG_EOG]=nameloaddata(filename);
        EEG_EOG=EEG_EOG';
        Fs=250;
        Fs_data=200;
        mixed_single_EEG=EEG_EOG(1,:);
        mixed_single_EEG=mixed_single_EEG-mean(mixed_single_EEG);
         mixed_single_EEG=resample(mixed_single_EEG,Fs_data,Fs);


[startpointEOG,endpointEOG]=detecionEOG_HOS_new(mixed_single_EEG,Fs,0.4,0.2);%thr1=0.4 and thr2=0.2
t_EEG_all=(0:length(mixed_single_EEG)-1)/Fs;
figure
plot(t_EEG_all,mixed_single_EEG);
h1=line([startpointEOG/Fs startpointEOG/Fs], [min(mixed_single_EEG) max(mixed_single_EEG)], 'Color', 'red');
line([endpointEOG/Fs endpointEOG/Fs], [min(mixed_single_EEG) max(mixed_single_EEG)], 'Color', 'red');
    end
end
