Skip to content

Commit adb17a5

Browse files
interpolation fix
1 parent beb0816 commit adb17a5

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ After that we use [pop_rejcont](https://github.com/wojzaremba/active-delays/blob
101101

102102
**note** for the Aging group, we use the [pop_rejcont](https://github.com/wojzaremba/active-delays/blob/master/external_tools/eeglab11_0_4_3b/functions/popfunc/pop_rejcont.m) function also right before the ICA. This is because the data was too noisy for more than 50% of the participants to find eye components.
103103

104-
#### F_interpolate
104+
#### F_preprocces4
105105
This script loads a file with all the original channels, deletes the externals and uses these file locations to interpolate the channels of the corresponding's subjects data.
106106
In the case of 160 channel data, it uses the [transform_n_channels](https://github.com/CognitiveNeuroLab/Interpolating_160ch_to_64ch_eeglab) function to interpolate the remaining channels not to the original 160, but to 64 channel data so that it is the same as all the other data. For this to work Matlab needs to know the location of 2 things, the trannsform_n_channel.m file and the EEG files called 64.set and 64.fdt.
107107

src/B_preprocess1.m

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,15 @@
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
68-
EEG = pop_saveset( EEG, 'filename',[subject_list{s} '_info.set'],'filepath', data_path);
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
6968
elseif EEG.nbchan >159 && EEG.nbchan < 191 %160chan cap
7069
if isempty(EEG.chanlocs) && EEG.nbchan==160
7170
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)
7271
else
73-
EEG=pop_chanedit(EEG, 'lookup',[home_path 'Cap160_fromBESAWebpage.sfp']); %make sure you put here the location of this file for your computer
74-
EEG = pop_saveset( EEG, 'filename',[subject_list{s} '_info.set'],'filepath', data_path);
72+
EEG=pop_chanedit(EEG, 'lookup',[home_path 'Cap160_fromBESAWebpage.sfp']); %make sure you put here the location of this file for your computer
7573
end
7674
end
75+
EEG = pop_saveset( EEG, 'filename',[subject_list{s} '_info.set'],'filepath', data_path);
7776
old_n_chan = EEG.nbchan;
7877
EEG = clean_artifacts(EEG, 'FlatlineCriterion',5,'ChannelCriterion',0.8,'LineNoiseCriterion',4,'Highpass','off','BurstCriterion','off','WindowCriterion','off','BurstRejection','on','Distance','Euclidian');
7978
new_n_chan = EEG.nbchan;

src/F_interpolate.m renamed to src/F_preprocces4.m

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
clear variables
66
eeglab
77
close all
8-
Group = {'Aging' 'ASD' };%'Control'
8+
Group = {'Aging' 'ASD'};%'Control'
99
name_paradigm = 'restingstate'; % this is needed for saving the table at the end
1010
for g=1:length(Group)
1111
switch Group{g}
@@ -20,20 +20,14 @@
2020
subject_list = {'12022' '12023' '12031' '12081' '12094' '12188' '12255' '12335' '12339' '12362' '12364' '12372' '12376' '12390' '12398' '12407' '12408' '12451' '12454' '12457' '12458' '12459' '12468' '12478' '12498' '12510' '12517' '12532' '12564' '12631' '12633' '12634' '12636' '12665' '12670' '12696' '12719' '12724' '12751' '12763' '12769' '12776' '12790' '12806' '12814' '12823' '12830' '12847' '12851' '12855' '12856' '12857' '12859' '12871' '12872' '12892'};
2121
end
2222

23-
participant_badchan = string(zeros(length(subject_list), 2)); %prealocationg space for speed
23+
participant_badchan = string(zeros(length(subject_list), 5)); %prealocationg space for speed
2424
for s=1:length(subject_list)
2525
fprintf('\n******\nProcessing subject %s\n******\n\n', subject_list{s});
2626
clear labels_all labels_good lables_del data_subj
2727
data_path = [home_path subject_list{s} ''];% Path to the folder containing the current subject's data
2828
% Load original dataset
2929
fprintf('\n\n\n**** %s: Loading dataset ****\n\n\n', subject_list{s});
3030
EEGinter = pop_loadset('filename', [subject_list{s} '_info.set'], 'filepath', data_path);%loading participant file with 64 channels
31-
%For the aging
32-
if strcmp(Group{g},'Aging') && EEGinter.nbchan==160 && isempty(EEGinter.chanlocs)
33-
EEGinter = pop_editset(EEGinter, '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)
34-
elseif strcmp(Group{g},'Aging') && EEGinter.nbchan==64 && isempty(EEGinter.chanlocs)
35-
EEGinter = pop_editset(EEGinter, '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)
36-
end
3731
%saving the original amount of total channels
3832
labels_all = {EEGinter.chanlocs.labels}.'; %stores all the labels in a new matrix
3933
%interpolating the 160channels to 64 channels
@@ -57,16 +51,16 @@
5751
disp(EEG.nbchan); %writes down how many channels are there
5852
EEG = pop_interp(EEG, EEGinter.chanlocs, 'spherical');%interpolates the data
5953
end
60-
clear EEG_temp EEGinter
6154
EEG = eeg_checkset( EEG );
6255
EEG = pop_saveset( EEG, 'filename', [subject_list{s} '_inter.set'], 'filepath', data_path); %saves data
6356
disp(EEG.nbchan)
6457
%this part saves all the bad channels + ID numbers
6558
lables_del = setdiff(labels_all,labels_good); %only stores the deleted channels
6659
All_bad_chan = strjoin(lables_del); %puts them in one string rather than individual strings
6760
ID = string(subject_list{s});%keeps all the IDs
68-
data_subj = [ID, All_bad_chan]; %combines IDs and Bad channels
61+
data_subj = [ID, length(lables_del),EEGinter.nbchan, All_bad_chan, EEG.nbchan]; %combines IDs and Bad channels, total channels at the end
6962
participant_badchan(s,:) = data_subj;%combine new data with old data
63+
clear EEG_temp EEGinter
7064
end
7165
save([home_path name_paradigm '_participant_interpolation_info'], 'participant_badchan');
7266
end

0 commit comments

Comments
 (0)