-
Notifications
You must be signed in to change notification settings - Fork 1
/
Bike2_FFT_preprocessing.m
94 lines (70 loc) · 3.81 KB
/
Bike2_FFT_preprocessing.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
% Strategy will be, load in preprocessed epochs -1000 to 2000 ms,
% for each epoch go through each channel, run an FFT on the -1000 to 0 data
%(prestimulus), get the spectra,
% Then subtract the spectra for left and right side of the head
% Then average those over epochs
%
%%
clear all
close all
ccc
exp = 'Bike2';
% subs = {'101' '102' '103' '104' '106' '107' '108' '110' '114'...
% '115' '116' '117' '118' '119' '120' '121' '123' '125' '126' '127'...
% '128' '129' '130' '131' '132' '133' '134' '135' '136'};
subs = {'100'}; %to test on just one sub
nsubs = length(subs);
conds = {'sask' '110st' '83ave'};
nconds = length(conds);
% Marker Numbers
nStandard = 1;
nTarget = 2;
nFalseAlarm = 3;
nCorrectResponse = 4;
Pathname = 'M:\Data\Bike_Mazumder\';
if ~exist([Pathname 'segments\'])
mkdir([Pathname 'segmentsFFT\']);
end
[ALLEEG EEG CURRENTSET ALLCOM] = eeglab;
for i_sub = 1:nsubs
for i_cond = 1:nconds
Filename = [subs{i_sub} '_' exp '_' conds{i_cond} '.vhdr'];
setname = Filename(1:end-5)
EEG = pop_loadbv(Pathname, Filename);
% get electrode locations
EEG=pop_chanedit(EEG, 'load',{'M:\Analysis\Skateboard\Skate_Vamp_Active_16.ced' 'filetype' 'autodetect'});
% arithmetically rereference to linked mastoid
for x=1:EEG.nbchan-2
EEG.data(x,:) = (EEG.data(x,:)-((EEG.data(EEG.nbchan-2,:))*.5));
end
%Filter the data with low pass of 30
EEG = pop_eegfilt( EEG, .1, 0, [], 0); %high pass filter
EEG = pop_eegfilt( EEG, 0, 30, [], 0); %low pass filter
all_events = length(EEG.event)
for i_event = 2:all_events
EEG.event(i_event).type = num2str(str2num((EEG.event(i_event).type(2:end))));
end
%epoch
EEG = pop_epoch( EEG, { num2str(nStandard) num2str(nTarget) }, [-1 2], 'newname', sprintf('%s epochs' , setname), 'epochinfo', 'yes'); %Changed from [-.2 1] to [-1 2]. DR
EEG = pop_rmbase( EEG, [-200 0]);
% Artifact rejection, trials with range >500 uV
EEG = pop_eegthresh(EEG,1,[1:size(EEG.data,1)],-1000,1000,EEG.xmin,EEG.xmax,0,1);
% EMCP occular correction
temp_ocular = EEG.data(end-1:end,:,:); %to save the EYE data for after
selection_cards = {num2str(nStandard),num2str(nTarget) }; %different bin names, each condition should be separate
EEG = gratton_emcp(EEG,selection_cards,{'VEOG'},{'HEOG'}); %this assumes the eye channels are called this
EEG.emcp.table %this prints out the regression coefficients
EEG.data(end-1:end,:,:) = temp_ocular; %replace the eye data
% Artifact rejection, trials with range >250 uV
EEG = pop_rmbase( EEG, [-200 0]); %baseline again since this changed it
EEG = pop_eegthresh(EEG,1,[1:size(EEG.data,1)-2],-500,500,EEG.xmin,EEG.xmax,0,1);
tempEEG = EEG;
%now select the corrected trials
EEG = pop_selectevent( tempEEG, 'type',nTarget,'renametype','Target','deleteevents','on','deleteepochs','on','invertepochs','off');
EEG = pop_editset(EEG, 'setname',[subs{i_sub} '_' exp '_' conds{i_cond} '_Corrected_Target']);
EEG = pop_saveset( EEG, 'filename',[subs{i_sub} '_' exp '_' conds{i_cond} '_Corrected_Target.set'],'filepath',[Pathname 'segmentsFFT\']);
EEG = pop_selectevent( tempEEG, 'type',nStandard ,'renametype','Standard','deleteevents','on','deleteepochs','on','invertepochs','off');
EEG = pop_editset(EEG, 'setname',[subs{i_sub} '_' exp '_' conds{i_cond} '_Corrected_Standard']);
EEG = pop_saveset( EEG, 'filename',[subs{i_sub} '_' exp '_' conds{i_cond} '_Corrected_Standard.set'],'filepath',[Pathname 'segmentsFFT\']);
end
end