|
|
|
clear all; clc
|
|
datalocation='Y:\EEG_Data\PDDys\EEG\Raw EEG Data\'; % Data are here
|
|
savedir='Y:\EEG_Data\PDDys\EEG\Processed EEG Data\REST for PREDiCT\'; % Data go here
|
|
cd(savedir);
|
|
|
|
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];
|
|
CTLsx=[894 908 8010 890 891 892 893 895 896 897 898 899 900 901 902 903 904 905 906 907 909 910 911 912 913 914 8060 8070];
|
|
|
|
% Data are 68 chans: 1=63 is EEG, 64 is VEOG, 66-68 is XYZ accelerometer on hand (varied L or R).
|
|
% Ref'd to CPz - - will want to retrieve that during re-referencing. See below for code for that.
|
|
|
|
|
|
for subj=[PDsx,CTLsx]
|
|
for session=1:2;
|
|
if (subj>850 && session==1) || subj<850
|
|
if ~(exist([num2str(subj),'_',num2str(session),'_PD_REST.mat'])==2);
|
|
disp(['Do Rest --- Subno: ',num2str(subj),' Session: ',num2str(session)]); disp(' ');
|
|
|
|
|
|
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 bi=1:length(UNIQUE_TYPES); UNIQUE_TYPES_COUNT(bi)=sum(TYPES==UNIQUE_TYPES(bi)); end
|
|
clc; TRIGGERS=[UNIQUE_TYPES;UNIQUE_TYPES_COUNT]
|
|
|
|
Rest_Triggers=find(TYPES<5);
|
|
Last_Rest_Trigger=EEG.event(Rest_Triggers(end)).latency;
|
|
Last_Rest_Trigger_ms=Last_Rest_Trigger .* (1/(EEG.srate/1000));
|
|
Last_Rest_Trigger_Seconds=floor(Last_Rest_Trigger_ms/1000)+4;
|
|
|
|
|
|
EEG = pop_select( EEG,'time',[0 Last_Rest_Trigger_Seconds] );
|
|
|
|
|
|
clear UNIQUE* TYPES TRIGGERS
|
|
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 bi=1:length(UNIQUE_TYPES); UNIQUE_TYPES_COUNT(bi)=sum(TYPES==UNIQUE_TYPES(bi)); end
|
|
clc; TRIGGERS=[UNIQUE_TYPES;UNIQUE_TYPES_COUNT]
|
|
|
|
N_Trigs=0;
|
|
for ci=1:4, N_Trigs=N_Trigs+UNIQUE_TYPES_COUNT(UNIQUE_TYPES==ci); end
|
|
if N_Trigs<120, BOOM; end
|
|
|
|
|
|
|
|
|
|
|
|
save([savedir,num2str(subj),'_',num2str(session),'_PD_REST.mat'],'EEG');
|
|
|
|
|
|
clear EEG UNIQUE* TYPES TRIGGERS
|
|
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
BOOM;
|
|
|
|
|
|
|
|
|
|
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)=[];
|
|
|
|
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,[],[]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Screen('TextSize',wPtr,30);
|
|
Screen('TextFont',wPtr,'Times');
|
|
Screen('TextStyle',wPtr,0);
|
|
Screen('TextColor',wPtr,[255 255 255]);
|
|
beginningText1 = 'Experimenter: Continue';
|
|
DrawFormattedText(wPtr,beginningText1,'center','center');
|
|
Screen(wPtr, 'Flip');
|
|
KbWait([],3);
|
|
|
|
instructionText = 'Welcome and thank you for participating in our study. \n\n\n We are going to start by recording some activities \n\n of your brain activity at rest.';
|
|
DrawFormattedText(wPtr,instructionText,'center','center');
|
|
Screen(wPtr, 'Flip');
|
|
KbWait([],3);
|
|
|
|
instructionText = 'All you need to do is sit and rest quietly. \n\n\nWe will be recording resting EEG with your eyes \n\n\n CLOSED for the next minute. \n\n\n A tone will sound to let you know when \n\nthe time is up.';
|
|
DrawFormattedText(wPtr,instructionText,'center','center');
|
|
Screen(wPtr, 'Flip');
|
|
KbWait([],3);
|
|
|
|
|
|
DrawFormattedText(wPtr,'Close Eyes','center','center'); Screen(wPtr, 'Flip'); WaitSecs(1);
|
|
for ai=1:30
|
|
io64(ioObject,LTP1address,3); WaitSecs(.05); io64(ioObject,LTP1address,0); WaitSecs(.95);
|
|
io64(ioObject,LTP1address,4); WaitSecs(.05); io64(ioObject,LTP1address,0); WaitSecs(.95);
|
|
end
|
|
sound(Tone(1,:),echant);
|
|
|
|
instructionText = 'Now another minute with your eyes OPEN.';
|
|
DrawFormattedText(wPtr,instructionText,'center','center');
|
|
Screen(wPtr, 'Flip');
|
|
KbWait([],3);
|
|
|
|
|
|
DrawFormattedText(wPtr,' + ','center','center'); Screen(wPtr, 'Flip'); WaitSecs(1);
|
|
for ai=1:30
|
|
io64(ioObject,LTP1address,1); WaitSecs(.05); io64(ioObject,LTP1address,0); WaitSecs(.95);
|
|
io64(ioObject,LTP1address,2); WaitSecs(.05); io64(ioObject,LTP1address,0); WaitSecs(.95);
|
|
end
|
|
sound(Tone(1,:),echant);
|
|
|
|
|
|
|
|
|