|
|
|
|
|
startup
|
|
|
clear all; clc
|
|
|
addpath('Y:\EEG_Data\PDDys\EEG\PD REST Scripts');
|
|
|
datalocation='Y:\EEG_Data\PDDys\EEG\Raw EEG Data\'; % Data are here
|
|
|
cd(datalocation);
|
|
|
savedir='Y:\EEG_Data\PDDys\EEG\Processed EEG Data\';
|
|
|
|
|
|
PDsx=[801 802 803 804 805 806 807 808 809 810 811 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 ]; % 803 S1 is garbage
|
|
|
CTLsx=[894 908 890 891 892 893 895 896 897 898 899 900 901 902 903 904 905 906 907 909 910 911 912 913 914 8010 8060 8070 ];
|
|
|
|
|
|
for subj=[PDsx,CTLsx]
|
|
|
for session=1:2
|
|
|
if (subj>850 && session==1) || subj<850 % If not ctl, do session 2
|
|
|
if ~(exist([savedir,num2str(subj),'_',num2str(session),'_PDDys_REST.mat'])==2)
|
|
|
disp(['Do Rest --- Subno: ',num2str(subj),' Session: ',num2str(session)]); disp(' ');
|
|
|
|
|
|
% Data are 68 chans: 1=63 is EEG, 64 is VEOG, 66-68 is XYZ. Ref'd to CPz - - will want to retrieve that during re-referencing
|
|
|
|
|
|
EEG = pop_loadbv(datalocation,[num2str(subj),'_',num2str(session),'_ODDBALL.vhdr']);
|
|
|
|
|
|
locpath=('Y:\Programs\eeglab12_0_2_1b\plugins\dipfit2.2\standard_BESA\standard-10-5-cap385.elp');
|
|
|
EEG = pop_chanedit(EEG, 'lookup', locpath);
|
|
|
EEG = eeg_checkset( EEG );
|
|
|
|
|
|
for ai=2:length(EEG.event); temp=EEG.event(ai).type; TYPES(ai)=str2num(temp(2:end)) ; clear temp; end
|
|
|
UNIQUE_TYPES=unique(TYPES);
|
|
|
for ai=1:length(UNIQUE_TYPES); UNIQUE_TYPES_COUNT(ai)=sum(TYPES==UNIQUE_TYPES(ai)); end
|
|
|
clc; TRIGGERS=[UNIQUE_TYPES;UNIQUE_TYPES_COUNT]
|
|
|
|
|
|
|
|
|
All_STIM={'S 1','S 3'};
|
|
|
EEG = pop_epoch( EEG, All_STIM, [-2 2], 'newname', 'Epochs', 'epochinfo', 'yes');
|
|
|
EEG = eeg_checkset( EEG );
|
|
|
|
|
|
EEG.VEOG=squeeze(EEG.data(64,:,:));
|
|
|
EEG.X=squeeze(EEG.data(65,:,:));
|
|
|
EEG.Y=squeeze(EEG.data(66,:,:));
|
|
|
EEG.Z=squeeze(EEG.data(67,:,:));
|
|
|
EEG.data=EEG.data(1:63,:,:);
|
|
|
EEG.nbchan=63;
|
|
|
EEG.chanlocs(67)=[]; EEG.chanlocs(66)=[]; EEG.chanlocs(65)=[]; EEG.chanlocs(64)=[];
|
|
|
|
|
|
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' 'CPz'});
|
|
|
EEG = pop_chanedit(EEG,'lookup', locpath);
|
|
|
|
|
|
EEG = pop_reref(EEG,[],'refloc',struct('labels',{'CPz'},'type',{''},'theta',{180},'radius',{0.12662},'X',{-32.9279},'Y',{-4.0325e-15},'Z',{78.363},...
|
|
|
'sph_theta',{-180},'sph_phi',{67.208},'sph_radius',{85},'urchan',{64},'ref',{''}),'keepref','on');
|
|
|
|
|
|
EEG.MASTOIDS = squeeze(mean(EEG.data([10,21],:,:),1));
|
|
|
EEG.data = EEG.data([1:4,6:9,11:20,22:26,28:64],:,:);
|
|
|
EEG.nbchan=60;
|
|
|
EEG.chanlocs(27)=[]; EEG.chanlocs(21)=[]; EEG.chanlocs(10)=[]; EEG.chanlocs(5)=[];
|
|
|
|
|
|
EEG = pop_reref(EEG,[]);
|
|
|
|
|
|
EEG = pop_rmbase(EEG,[],[]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TASK='REST';
|
|
|
eeg_chans=1:60;
|
|
|
Do_ICA=1;
|
|
|
ref_chan=36;
|
|
|
EEG = pop_reref(EEG,ref_chan,'keepref','on');
|
|
|
|
|
|
|
|
|
[EEG,EEG.bad_chans,EEG.bad_epochs,EEG.bad_ICAs]=APPLE_PDDys(EEG,eeg_chans,ref_chan,Do_ICA,subj,EEG.VEOG,session,TASK);
|
|
|
|
|
|
|
|
|
save([savedir,num2str(subj),'_',num2str(session),'_PDDys_REST.mat'],'EEG');
|
|
|
clear EEG bad* UNIQUE* TYPES TRIGGERS
|
|
|
|
|
|
end
|
|
|
end
|
|
|
end
|
|
|
end
|
|
|
|
|
|
|