|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
clear; clc; close all;
|
|
|
|
|
|
cwd = pwd;
|
|
|
addpath(cwd);
|
|
|
|
|
|
datalocation= [cwd '\ALL_DATA\RAW_DATA\']; % Data are here
|
|
|
|
|
|
%%% load subject and Behaviour info from the excel sheet
|
|
|
[~, ~, SubjInfo] = xlsread([cwd '\Patients_MS.xlsx'],'AllPedaling');
|
|
|
|
|
|
savelocation= [cwd '\ALL_DATA\ALL_Processed_Data\']; % Data go here
|
|
|
cd(savelocation);
|
|
|
|
|
|
% add eeglab to the path
|
|
|
p = genpath('eeglab13_4_4b'); addpath(p);
|
|
|
|
|
|
%%
|
|
|
for nn = 1:size(SubjInfo,1)
|
|
|
|
|
|
type = SubjInfo{nn,1};
|
|
|
subj = SubjInfo{nn, 2};
|
|
|
|
|
|
disp([type,num2str(subj)]);
|
|
|
EEG = pop_loadbv(datalocation,[type,num2str(subj),'.vhdr'], [], []);
|
|
|
|
|
|
% Edit the event code
|
|
|
del = 0;
|
|
|
for b = 1:size(EEG.event,2)
|
|
|
if strcmp(EEG.event(b-del).type, 'boundary')
|
|
|
EEG.event(b-del) = []; del = del+1;
|
|
|
end
|
|
|
end
|
|
|
% get the time difference: S1 ---> S2
|
|
|
TimeDiff = (diff([EEG.event.latency])/EEG.srate)'; TimeDiff = ([0; TimeDiff]);
|
|
|
for b = 1:size(EEG.event,2); EEG.event(b).TimeDiff = TimeDiff(b); end
|
|
|
|
|
|
|
|
|
EEG = pop_epoch( EEG, { 'S 2' }, [-1 3], 'epochinfo', 'yes');
|
|
|
EEG = eeg_checkset( EEG );
|
|
|
|
|
|
|
|
|
if EEG.nbchan>63
|
|
|
EEG.X=squeeze(EEG.data(64,:,:));
|
|
|
EEG.Y=squeeze(EEG.data(65,:,:));
|
|
|
EEG.Z=squeeze(EEG.data(66,:,:));
|
|
|
EEG.data=EEG.data(1:63,:,:);
|
|
|
EEG.nbchan=63;
|
|
|
EEG.chanlocs(66)=[]; EEG.chanlocs(65)=[]; EEG.chanlocs(64)=[];
|
|
|
end
|
|
|
|
|
|
|
|
|
for ai=1:size(EEG.urevent,2), EEG.urevent(ai).bvtime=EEG.urevent(ai).bvmknum; end
|
|
|
for ai=1:size(EEG.event,2), EEG.event(ai).bvtime=EEG.event(ai).bvmknum; end
|
|
|
for ai=1:size(EEG.epoch,2), EEG.epoch(ai).eventbvtime=EEG.epoch(ai).eventbvmknum; end
|
|
|
|
|
|
|
|
|
EEG = pop_chanedit(EEG,'append',63,'changefield',{64 'labels' 'Pz'});
|
|
|
|
|
|
|
|
|
|
|
|
EEG = pop_reref(EEG,[],'refloc',struct('labels',{'Pz'},'type',{''},'theta',{180},'radius',{0.2535},'X',{-60.7385},'Y',{-7.4383e-15},'Z',{59.4629},...
|
|
|
'sph_theta',{-180},'sph_phi',{44.3920},'sph_radius',{85},'urchan',{64},'ref',{''}),'keepref','on');
|
|
|
|
|
|
|
|
|
|
|
|
EEG.data = EEG.data([2:9, 11:19, 21:25, 27:30, 32:64],:,:);
|
|
|
EEG.nbchan=59;
|
|
|
EEG.chanlocs(31)=[]; EEG.chanlocs(26)=[]; EEG.chanlocs(20)=[]; EEG.chanlocs(10)=[]; EEG.chanlocs(1)=[];
|
|
|
|
|
|
|
|
|
EEG = pop_reref(EEG,[]);
|
|
|
|
|
|
EEG = pop_rmbase(EEG,[],[]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subno = subj;
|
|
|
VEOG = 0;
|
|
|
session = 1;
|
|
|
TASK = ['Ped_',type];
|
|
|
|
|
|
EEG_chans=1:EEG.nbchan;
|
|
|
Do_ICA=1;
|
|
|
Reref = 'FCz';
|
|
|
chanidx = find(strcmpi(Reref,{EEG.chanlocs.labels}));
|
|
|
ref_chan=chanidx;
|
|
|
|
|
|
EEG = pop_reref(EEG,ref_chan,'keepref','on');
|
|
|
|
|
|
|
|
|
[EEG,bad_chans,bad_epochs,bad_ICAs]=APPLE_ActiveCap_v2(EEG,EEG_chans,ref_chan,Do_ICA,subno,VEOG,session,TASK);
|
|
|
|
|
|
|
|
|
save([savelocation,type,num2str(subj),'_Ped_Processed.mat'],'EEG','bad_chans','bad_epochs','bad_ICAs');
|
|
|
|
|
|
|
|
|
clearvars -except datalocation savelocation SubjInfo
|
|
|
|
|
|
end |