Skip to content

Commit d985b34

Browse files
update
1 parent 3327747 commit d985b34

File tree

4 files changed

+82
-64
lines changed

4 files changed

+82
-64
lines changed

src/B_preprocess1.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
% ------------------------------------------------
99
clear variables
1010
eeglab
11-
group = {'Aging' 'ASD' 'Control'};%
11+
group = {'Aging' 'ASD' 'Control'};%
1212
for g=1:length(group)
1313
if strcmp(group{g},'ASD')
1414
subject_list = {'1101' '1164' '1808' '1852' '1855' '11014' '11094' '11151' '11170' '11275' '11349' '11516' '11558' '11583' '11647' '11729' '11735' '11768' '11783' '11820' '11912' '1106' '1108' '1132' '1134' '1154' '1160' '1173' '1174' '1179' '1190' '1838' '1839' '1874' '11013' '11056' '11098' '11106' '11198' '11244' '11293' '11325' '11354' '11369' '11375' '11515' '11560' '11580' '11667' '11721' '11723' '11750' '11852' '11896' '11898' '11913' '11927' '11958' '11965'}; %all the IDs for the indivual particpants
@@ -64,12 +64,12 @@
6464
end
6565
%adding channel location
6666
if EEG.nbchan >63 && EEG.nbchan < 95 %64chan cap (can be a lot of externals, this makes sure that it includes a everything that is under 96 channels, which could be an extra ribbon)
67-
EEG=pop_chanedit(EEG, 'lookup',[home_path 'standard-10-5-cap385.elp']); %make sure you put here the location of this file for your computer
67+
EEG=pop_chanedit(EEG, 'lookup',[home_path 'standard-10-5-cap385.elp']); %make sure you put here the location of this file for your computer
6868
elseif EEG.nbchan >159 && EEG.nbchan < 191 %160chan cap
6969
if isempty(EEG.chanlocs) && EEG.nbchan==160
7070
EEG = pop_editset(EEG, 'chanlocs', [home_path 'Cap160_fromBESAWebpage.sfp']); %need to first load any sort of sfp file with the correct channels (the locations will be overwritten to the correct ones later)
7171
else
72-
EEG=pop_chanedit(EEG, 'lookup',[home_path 'Cap160_fromBESAWebpage.sfp']); %make sure you put here the location of this file for your computer
72+
EEG=pop_chanedit(EEG, 'lookup',[home_path 'Cap160_fromBESAWebpage.sfp']); %make sure you put here the location of this file for your computer
7373
end
7474
end
7575
EEG = pop_saveset( EEG, 'filename',[subject_list{s} '_info.set'],'filepath', data_path);

src/F_preprocces4.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
clear variables
66
eeglab
77
close all
8-
Group = {'ASD'};%'Control'
8+
Group = {'ASD' 'Control' 'Aging'};%'Control'
99
name_paradigm = 'restingstate'; % this is needed for saving the table at the end
10+
function_folder = 'C:\Users\dohorsth\Documents\GitHub\resting-state-analysis-pipeline-microstates-frequency\src\Functions and files\';
1011
for g=1:length(Group)
1112
switch Group{g}
1213
case 'Control'
@@ -35,15 +36,19 @@
3536
EEG = pop_loadset('filename', [subject_list{s} '_clean.set'], 'filepath', data_path); %loads latest pre-proc file
3637
labels_good = {EEG.chanlocs.labels}.'; %saves all the channels that are in the _clean file
3738
EEG_temp = pop_loadset('filename', '64.set', 'filepath', home_path);
39+
EEG = pop_interp(EEG, EEGinter.chanlocs, 'spherical');
3840
for b=1:EEG.nbchan
3941
if strcmp(EEG.chanlocs(b).labels,'b32')
4042
EEG.chanlocs(b).labels = 'B32'; %the channel location file used to have a typo (b32 instead of B32)
4143
end
4244
end
43-
EEG = transform_n_channels(EEG,EEG_temp.chanlocs,64);
45+
oldFolder = cd;
46+
cd(function_folder)
47+
EEG = transform_n_channels(EEG,EEG_temp.chanlocs,64,'keep');
4448
%this deletes the channel location, so we add it back
4549
EEG = pop_editset(EEG, 'chanlocs', [home_path 'BioSemi64.sfp']); %need to first load any sort of sfp file with the correct channels (the locations will be overwritten to the correct ones later)
4650
EEG=pop_chanedit(EEG, 'lookup',[home_path 'standard-10-5-cap385.elp']); %make sure you put here the location of this file for your computer
51+
cd(oldFolder)
4752
else
4853
%interpolating for 64 channels
4954
EEG = pop_loadset('filename', [subject_list{s} '_clean.set'], 'filepath', data_path); %loads latest pre-proc file
Lines changed: 71 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
% transform_channels() - transform x amount of channel data into different
22
% amount of channels using the intpolation function of EEGlab
3-
% keeps the "landmark channels" that exist in both caps (Cz=A1 Pz=A19 Oz=A23 T8=B32 C4 =C7 Fz=D4 FPz=D8 C3=E4 T7=E9)
3+
%
44
%
5-
% Usage: EEGOUT = transform_channels(EEG,chanlocs_new,n_new_chan);
5+
% Usage: EEGOUT = transform_channels(EEG,chanlocs_new,n_new_chan,methode);
66
%
77
% Inputs:
88
% EEG - EEGLAB dataset
99
% chanlocs_new - chanlocs stucture with amount of channels
1010
% desired for EEG to be transformed to.
1111
% n_new_chan - 64 or 160, this will decide what channels to keep
12-
% Optional Inputs:
13-
% landmarks - adding this, the landmark channels will not be
14-
% interpolated. This will only count for : Cz=A1 Pz=A19
15-
% Oz=A23 T8=B32 C4 =C7 Fz=D4 FPz=D8 C3=E4 T7=E9
16-
% when not adding this, all new channels will be
17-
% interpolated. No landmark channels will be used.
12+
% Methods - there are 3 methods, choose which one
13+
% interpolate - this interpolates all the channels
14+
% keep - Only for 160 channel data that will be transformed
15+
% to 64 channel data. Keep only the original channels
16+
% and data that are closest to the 64channel
17+
% equivalent.
18+
%
1819
% Output:
1920
% EEGOUT - dataset with the new amount of channels
2021
%
2122
% Example:
22-
% EEG = transform_n_channels(EEG,EEG2.chanlocs,64);
23+
% EEG = transform_n_channels(EEG,EEG2.chanlocs,64,interpolate);
2324
% Extra:
2425
% To get the EEG2.chanlocs with the new amount of channels,
2526
% simply load an .set file with those amount of channels
@@ -32,14 +33,15 @@
3233
% This file is part of EEGLAB, see http://www.eeglab.org
3334
% for the documentation and details.
3435

35-
function EEG = transform_n_channels(ORGEEG, newchan,n_new_chan, landmark)
36-
if nargin == 3 % no landmark channels
37-
landmark = 'no';
38-
end
36+
function EEG = transform_n_channels(ORGEEG, newchan,n_new_chan, methode)
37+
% clearing things that are not correct anymore
38+
ORGEEG.icaact=[]; ORGEEG.icasphere =[]; ORGEEG.icaweights=[]; ORGEEG.icachansind=[];ORGEEG.icawinv=[];
3939
if n_new_chan == 64
4040
old = {'A1', 'A19' 'A23' 'B32' 'C7' 'D4' 'D8' 'E4' 'E9' 'C1' 'C2' 'C3' 'C4' 'C5' 'C6'};
4141
new = {'AA1', 'AA19' 'AA23' 'BB32' 'CC7' 'DD4' 'DD8' 'EE4' 'EE9' 'CC1' 'CC2' 'CC3' 'CC4' 'CC5' 'CC6'};
4242
final={'Cz' 'Pz' 'Oz' 'T8' 'C4' 'Fz' 'Fpz' 'C3' 'T7'};
43+
old_keep={'D9' 'D22' 'D20' 'D13' 'D19' 'D24' 'D32' 'E8' 'E6' 'D27' 'D17' 'E2' 'EE4' 'E11' 'EE9' 'E16' 'E14' 'E26' 'E25' 'A5' 'A7' 'E29' 'E18' 'E32' 'A10' 'A8' 'A15' 'A25' 'AA23' 'A21' 'AA19' 'A3' 'DD8' 'C32' 'C18' 'C20' 'D6' 'DD4' 'C28' 'C21' 'C16' 'C12' 'C11' 'C9' 'C23' 'C24' 'D2' 'AA1' 'CC3' 'CC7' 'B30' 'BB32' 'B19' 'B21' 'B23' 'B24' 'A32' 'B4' 'B13' 'B17' 'B10' 'B7' 'B5' 'A28'};
44+
new_keep={'Fp1' 'AF7' 'AF3' 'F1' 'F3' 'F5' 'F7' 'FT7' 'FC5' 'FC3' 'FC1' 'C1' 'C3' 'C5' 'T7' 'TP7' 'CP5' 'CP3' 'CP1' 'P1' 'P3' 'P5' 'P7' 'P9' 'PO7' 'PO3' 'O1' 'Iz' 'Oz' 'POz' 'Pz' 'CPz' 'Fpz' 'Fp2' 'AF8' 'AF4' 'AFz' 'Fz' 'F2' 'F4' 'F6' 'F8' 'FT8' 'FC6' 'FC4' 'FC2' 'FCz' 'Cz' 'C2' 'C4' 'C6' 'T8' 'TP8' 'CP6' 'CP4' 'CP2' 'P2' 'P4' 'P6' 'P8' 'P10' 'PO8' 'PO4' 'O2'};
4345
% Cz=A1 Pz=A19 Oz=A23 T8=B32 C4 =C7 Fz=D4 FPz=D8 C3=E4 T7=E9
4446
for c=1:length(old)%updating channel names to prefent duplicates
4547
for n=1:length(ORGEEG.chanlocs)
@@ -48,84 +50,95 @@
4850
end
4951
end
5052
end
51-
[ORGEEG] = pop_interp(ORGEEG, newchan, 'spherical');
53+
if strcmp(methode, 'keep') %for this one we need to skip the iterpolation
54+
%need the chose 160 channels in the 64 channel order
55+
data=ORGEEG.data([105;118;116;109;115;120;128;136;134;123;113;130;132;139;137;144;142;154;153;5;7;157;146;160;10;8;15;25;23;21;19;3;104;96;82;84;102;100;92;85;80;76;75;73;87;88;98;1;67;71;62;64;51;53;55;56;32;36;45;49;42;39;37;28],:);
56+
ORGEEG = pop_select( ORGEEG, 'channel',{'AA1','A3','A5','A7','A8','A10','A15','AA19','A21','AA23','A25','A28','A32','B4','B5','B7','B10','B13','B17','B19','B21','B23','B24','B30','BB32','CC3','CC7','C9','C11','C12','C16','C18','C20','C21','C23','C24','C28','C32','D2','DD4','D6','DD8','D9','D13','D17','D19','D20','D22','D24','D27','D32','E2','EE4','E6','E8','EE9','E11','E14','E16','E18','E25','E26','E29','E32'});
57+
% {'A1', 'A19' 'A23' 'B32' 'C3' 'C7' 'D4' 'D8' 'E4' 'E9' 'C1' 'C2' 'C3' 'C4' 'C5' 'C6'};
58+
else
59+
60+
[ORGEEG] = pop_interp(ORGEEG, newchan, 'spherical');
61+
end
5262
%% giving the right urchan to the new ones
53-
for u=1:length(ORGEEG.chanlocs)
54-
for c=1:length(final)%updating channel names to prefent duplicates
55-
for n=1:length(ORGEEG.chanlocs)
56-
if strcmp(ORGEEG.chanlocs(n).labels, final{c})
57-
urch = ORGEEG.chanlocs(n).urchan;
63+
if strcmp(methode, 'keep') %for this one we need to look for different channels then the rest
64+
ORGEEG.data = data;
65+
else
66+
for u=1:length(ORGEEG.chanlocs)
67+
for c=1:length(final)%updating channel names to prefent duplicates
68+
for n=1:length(ORGEEG.chanlocs)
69+
if strcmp(ORGEEG.chanlocs(n).labels, final{c})
70+
urch = ORGEEG.chanlocs(n).urchan;
71+
end
5872
end
59-
end
60-
for n=1:length(ORGEEG.chanlocs)
61-
if strcmp(ORGEEG.chanlocs(n).labels, new{c}) %looking for the old channels
62-
ORGEEG.chanlocs(n).urchan = urch; %updating their lables with the new name
73+
for n=1:length(ORGEEG.chanlocs)
74+
if strcmp(ORGEEG.chanlocs(n).labels, new{c}) %looking for the old channels
75+
ORGEEG.chanlocs(n).urchan = urch; %updating their lables with the new name
76+
end
77+
6378
end
64-
6579
end
6680
end
6781
end
6882
%% Only selecting the right channels
6983
% ORGEEG = pop_select( ORGEEG, 'channel',{'Fp1' 'AF7' 'AF3' 'F1' 'F3' 'F5' 'F7' 'FT7' 'FC5' 'FC3' 'FC1' 'C1' 'EE4' 'C5' 'EE9' 'TP7' 'CP5' 'CP3' 'CP1' 'P1' 'P3' 'P5' 'P7' 'P9' 'PO7' 'PO3' 'O1' 'Iz' 'AA23' 'POz' 'AA19' 'CPz' 'DD8' 'Fp2' 'AF8' 'AF4' 'AFz' 'DD4' 'F2' 'F4' 'F6' 'F8' 'FT8' 'FC6' 'FC4' 'FC2' 'FCz' 'AA1' 'C2' 'CC7' 'C6' 'BB32' 'TP8' 'CP6' 'CP4' 'CP2' 'P2' 'P4' 'P6' 'P8' 'P10' 'PO8' 'PO4' 'O2'});
70-
if strcmp(landmark, 'no')
84+
if strcmp(methode, 'interpolate')
7185
ORGEEG = pop_select( ORGEEG, 'nochannel',{'AA1', 'A2', 'A3', 'A4', 'A5', 'A6', 'A7', 'A8', 'A9', 'A10', 'A11', 'A12', 'A13', 'A14', 'A15', 'A16', 'A17', 'A18', 'AA19', 'A20', 'A21', 'A22', 'AA23', 'A24', 'A25', 'A26', 'A27', 'A28', 'A29', 'A30', 'A31', 'A32', 'B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B8', 'B9', 'B10', 'B11', 'B12', 'B13', 'B14', 'B15', 'B16', 'B17', 'B18', 'B19', 'B20', 'B21', 'B22', 'B23', 'B24', 'B25', 'B26', 'B27', 'B28', 'B29', 'B30', 'B31', 'BB32', 'CC1', 'CC2', 'CC3', 'CC4', 'CC5', 'CC6', 'CC7' 'C8', 'C9', 'C10', 'C11', 'C12', 'C13', 'C14', 'C15', 'C16', 'C17', 'C18', 'C19', 'C20', 'C21', 'C22', 'C23', 'C24', 'C25', 'C26', 'C27', 'C28', 'C29', 'C30', 'C31', 'C32', 'D1', 'D2', 'D3', 'DD4', 'D5', 'D6', 'D7', 'DD8', 'D9', 'D10', 'D11', 'D12', 'D13', 'D14', 'D15', 'D16', 'D17', 'D18', 'D19', 'D20', 'D21', 'D22', 'D23', 'D24', 'D25', 'D26', 'D27', 'D28', 'D29', 'D30', 'D31', 'D32', 'E1', 'E2', 'E3', 'EE4', 'E5', 'E6', 'E7', 'E8', 'EE9', 'E10', 'E11', 'E12', 'E13', 'E14', 'E15', 'E16', 'E17', 'E18', 'E19', 'E20', 'E21', 'E22', 'E23', 'E24', 'E25', 'E26', 'E27', 'E28', 'E29', 'E30', 'E31', 'E32'});
72-
else
73-
ORGEEG = pop_select( ORGEEG, 'nochannel',{'Cz', 'A2', 'A3', 'A4', 'A5', 'A6', 'A7', 'A8', 'A9', 'A10', 'A11', 'A12', 'A13', 'A14', 'A15', 'A16', 'A17', 'A18', 'Pz', 'A20', 'A21', 'A22', 'Oz', 'A24', 'A25', 'A26', 'A27', 'A28', 'A29', 'A30', 'A31', 'A32', 'B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B8', 'B9', 'B10', 'B11', 'B12', 'B13', 'B14', 'B15', 'B16', 'B17', 'B18', 'B19', 'B20', 'B21', 'B22', 'B23', 'B24', 'B25', 'B26', 'B27', 'B28', 'B29', 'B30', 'B31', 'T8', 'CC1', 'CC2', 'CC3', 'CC4', 'CC5', 'CC6', 'C4' 'C8', 'C9', 'C10', 'C11', 'C12', 'C13', 'C14', 'C15', 'C16', 'C17', 'C18', 'C19', 'C20', 'C21', 'C22', 'C23', 'C24', 'C25', 'C26', 'C27', 'C28', 'C29', 'C30', 'C31', 'C32', 'D1', 'D2', 'D3', 'Fz', 'D5', 'D6', 'D7', 'Fpz', 'D9', 'D10', 'D11', 'D12', 'D13', 'D14', 'D15', 'D16', 'D17', 'D18', 'D19', 'D20', 'D21', 'D22', 'D23', 'D24', 'D25', 'D26', 'D27', 'D28', 'D29', 'D30', 'D31', 'D32', 'E1', 'E2', 'E3', 'C3', 'E5', 'E6', 'E7', 'E8', 'T7', 'E10', 'E11', 'E12', 'E13', 'E14', 'E15', 'E16', 'E17', 'E18', 'E19', 'E20', 'E21', 'E22', 'E23', 'E24', 'E25', 'E26', 'E27', 'E28', 'E29', 'E30', 'E31', 'E32'});
74-
for c=1:length(final)%updating channel names to final names
86+
elseif strcmp(methode, 'keep')
87+
for c=1:length(old_keep)%updating channel names to final names
7588
for n=1:length(ORGEEG.chanlocs)
76-
if strcmp(ORGEEG.chanlocs(n).labels, new{c})
77-
ORGEEG.chanlocs(n).labels = final{c};
89+
if strcmp(ORGEEG.chanlocs(n).labels, old_keep{c})
90+
ORGEEG.chanlocs(n).labels = new_keep{c};
91+
ORGEEG.chanlocs(n).urchan=c;
7892
end
7993
end
8094
end
95+
else
96+
disp('error no methode was inputted')
8197
end
8298
elseif n_new_chan == 160
83-
% old ={'Cz' 'Pz' 'Oz' 'T8' 'C4' 'Fz' 'Fpz' 'C3' 'T7'};
84-
% final = {'A1', 'A19' 'A23' 'B32' 'C7' 'D4' 'D8' 'E4' 'E9'};
85-
% new = {'AA1', 'AA19' 'AA23' 'BB32' 'CC7' 'DD4' 'DD8' 'EE4' 'EE9'};
86-
8799
old={ 'Cz' 'Pz' 'Oz' 'T8' 'C4' 'Fz' 'Fpz' 'C3' 'T7' 'C1' 'C2' 'C5' 'C6'};
88-
new = {'AA1', 'AA19' 'AA23' 'BB32' 'CC7' 'DD4' 'DD8' 'EE4' 'EE9' 'CC1' 'CC2' 'CC5' 'CC6'};
89-
final = {'A1', 'A19' 'A23' 'B32' 'C7' 'D4' 'D8' 'E4' 'E9'};
90-
100+
new = {'AA1', 'AA19' 'AA23' 'BB32' 'CC7' 'DD4' 'DD8' 'EE4' 'EE9' 'CC1' 'CC2' 'CC5' 'CC6'};
91101
for c=1:length(old)%updating channel names to prefent duplicates
92102
for n=1:length(ORGEEG.chanlocs)
93103
if strcmp(ORGEEG.chanlocs(n).labels, old{c}) %looking for the old channels
94104
ORGEEG.chanlocs(n).labels = new{c}; %updating their lables with the new name
95105
end
96106
end
97107
end
98-
[ORGEEG] = pop_interp(ORGEEG, newchan, 'spherical');
99-
%% giving the right urchan to the new ones
100-
for u=1:length(ORGEEG.chanlocs)
101-
for c=1:length(final)%updating channel names to prefent duplicates
108+
[ORGEEG] = pop_interp(ORGEEG, newchan, 'spherical'); % to create the extra channels (also needed for keep)
109+
%% only selecting the ones you need
110+
if strcmp(methode, 'interpolate')
111+
ORGEEG = pop_select( ORGEEG, 'nochannel',{'Fp1', 'AF7', 'AF3', 'F1', 'F3', 'F5', 'F7', 'FT7', 'FC5', 'FC3', 'FC1', 'CC1', 'EE4', 'CC5', 'EE9', 'TP7', 'CP5', 'CP3', 'CP1', 'P1', 'P3', 'P5', 'P7', 'P9', 'PO7', 'PO3', 'O1', 'Iz', 'AA23', 'POz', 'AA19', 'CPz', 'DD8', 'Fp2', 'AF8', 'AF4', 'AFz', 'DD4', 'F2', 'F4', 'F6', 'F8', 'FT8', 'FC6', 'FC4', 'FC2', 'FCz', 'AA1', 'CC2','CC7', 'CC4', 'CC6', 'BB32', 'TP8', 'CP6', 'CP4', 'CP2', 'P2', 'P4', 'P6', 'P8', 'P10', 'PO8', 'PO4', 'O2'});
112+
elseif strcmp(methode, 'keep')
113+
%% need to find the 64channels to delete; all from the 64chan except the equivalents (A1 should go not Cz)
114+
new_del={'D9' 'D22' 'D20' 'D13' 'D19' 'D24' 'D32' 'E8' 'E6' 'D27' 'D17' 'E2' 'E4' 'E11' 'E9' 'E16' 'E14' 'E26' 'E25' 'A5' 'A7' 'E29' 'E18' 'E32' 'A10' 'A8' 'A15' 'A25' 'A23' 'A21' 'A19' 'A3' 'D8' 'C32' 'C18' 'C20' 'D6' 'D4' 'C28' 'C21' 'C16' 'C12' 'C11' 'C9' 'C23' 'C24' 'D2' 'A1' 'C3' 'C7' 'B30' 'B32' 'B19' 'B21' 'B23' 'B24' 'A32' 'B4' 'B13' 'B17' 'B10' 'B7' 'B5' 'A28'};
115+
old_keep={'Fp1' 'AF7' 'AF3' 'F1' 'F3' 'F5' 'F7' 'FT7' 'FC5' 'FC3' 'FC1' 'CC1' 'EE4' 'CC5' 'EE9' 'TP7' 'CP5' 'CP3' 'CP1' 'P1' 'P3' 'P5' 'P7' 'P9' 'PO7' 'PO3' 'O1' 'Iz' 'AA23' 'POz' 'AA19' 'CPz' 'DD8' 'Fp2' 'AF8' 'AF4' 'AFz' 'DD4' 'F2' 'F4' 'F6' 'F8' 'FT8' 'FC6' 'FC4' 'FC2' 'FCz' 'AA1' 'CC2' 'CC7' 'CC6' 'BB32' 'TP8' 'CP6' 'CP4' 'CP2' 'P2' 'P4' 'P6' 'P8' 'P10' 'PO8' 'PO4' 'O2'};
116+
for c=1:length(new_del)%updating channel names to final names
102117
for n=1:length(ORGEEG.chanlocs)
103-
if strcmp(ORGEEG.chanlocs(n).labels, final{c})
104-
urch = ORGEEG.chanlocs(n).urchan;
118+
if strcmp(ORGEEG.chanlocs(n).labels, new_del{c}) %looking for the new names
119+
urchan=ORGEEG.chanlocs(n).urchan;
105120
end
106121
end
107122
for n=1:length(ORGEEG.chanlocs)
108-
if strcmp(ORGEEG.chanlocs(n).labels, new{c}) %looking for the old channels
109-
ORGEEG.chanlocs(n).urchan = urch; %updating their lables with the new name
123+
if strcmp(ORGEEG.chanlocs(n).labels, old_keep{c}) %looking for the new names
124+
ORGEEG.chanlocs(n).urchan=urchan;
110125
end
111-
112126
end
113-
end
114-
end
115-
%% only selecting the ones you need
116-
if strcmp(landmark, 'no')
117-
ORGEEG = pop_select( ORGEEG, 'nochannel',{'Fp1', 'AF7', 'AF3', 'F1', 'F3', 'F5', 'F7', 'FT7', 'FC5', 'FC3', 'FC1', 'CC1', 'EE4', 'CC5', 'EE9', 'TP7', 'CP5', 'CP3', 'CP1', 'P1', 'P3', 'P5', 'P7', 'P9', 'PO7', 'PO3', 'O1', 'Iz', 'AA23', 'POz', 'AA19', 'CPz', 'DD8', 'Fp2', 'AF8', 'AF4', 'AFz', 'DD4', 'F2', 'F4', 'F6', 'F8', 'FT8', 'FC6', 'FC4', 'FC2', 'FCz', 'AA1', 'CC2','CC7', 'CC4', 'CC6', 'BB32', 'TP8', 'CP6', 'CP4', 'CP2', 'P2', 'P4', 'P6', 'P8', 'P10', 'PO8', 'PO4', 'O2'});
118-
else
119-
ORGEEG = pop_select( ORGEEG, 'nochannel',{'Fp1', 'AF7', 'AF3', 'F1', 'F3', 'F5', 'F7', 'FT7', 'FC5', 'FC3', 'FC1', 'CC1', 'E4' , 'CC5', 'CC7', 'E9', 'TP7', 'CP5', 'CP3', 'CP1', 'P1', 'P3', 'P5', 'P7', 'P9', 'PO7', 'PO3', 'O1', 'Iz', 'A23' , 'POz', 'A19' , 'CPz', 'D8', 'Fp2', 'AF8', 'AF4', 'AFz', 'D4', 'F2', 'F4', 'F6', 'F8', 'FT8', 'FC6', 'FC4', 'FC2','FCz', 'A1', 'CC2', 'CC6', 'B32', 'TP8', 'CP6', 'CP4', 'CP2', 'P2', 'P4', 'P6', 'P8', 'P10', 'PO8', 'PO4', 'O2'});
120-
for c=1:length(final)%updating channel names to final names
127+
end
128+
ORGEEG = pop_select( ORGEEG, 'nochannel',{'D9' 'D22' 'D20' 'D13' 'D19' 'D24' 'D32' 'E8' 'E6' 'D27' 'D17' 'E2' 'E4' 'E11' 'E9' 'E16' 'E14' 'E26' 'E25' 'A5' 'A7' 'E29' 'E18' 'E32' 'A10' 'A8' 'A15' 'A25' 'A23' 'A21' 'A19' 'A3' 'D8' 'C32' 'C18' 'C20' 'D6' 'D4' 'C28' 'C21' 'C16' 'C12' 'C11' 'C9' 'C23' 'C24' 'D2' 'A1' 'C3' 'C7' 'B30' 'B32' 'B19' 'B21' 'B23' 'B24' 'A32' 'B4' 'B13' 'B17' 'B10' 'B7' 'B5' 'A28'});
129+
for c=1:length(new_del)%updating channel names to final names
121130
for n=1:length(ORGEEG.chanlocs)
122-
if strcmp(ORGEEG.chanlocs(n).labels, new{c}) %looking for the new names
123-
ORGEEG.chanlocs(n).labels = final{c}; % updating them with their final names
131+
if strcmp(ORGEEG.chanlocs(n).labels, old_keep{c}) %looking for the new names
132+
ORGEEG.chanlocs(n).labels = new_del{c}; % updating them with their final names
124133
end
125134
end
126-
end
135+
end
136+
%% moving the ORGEEG to correct location
137+
ORGEEG.data= [[ORGEEG.chanlocs.urchan].',ORGEEG.data];
138+
ORGEEG.data=sortrows(ORGEEG.data,1);
139+
ORGEEG.data=ORGEEG.data(:,2:end);
127140
end
128141
end
129-
[~,index] = sortrows([ORGEEG.chanlocs.urchan].'); ORGEEG.chanlocs = ORGEEG.chanlocs(index); clear index
142+
[~,index] = sortrows([ORGEEG.chanlocs.urchan].'); ORGEEG.chanlocs = ORGEEG.chanlocs(index);clear index
130143
EEG = ORGEEG;
131144
end

0 commit comments

Comments
 (0)