Skip to content

Commit a834c20

Browse files
Merge pull request #2 from DouweHorsthuis/update_2
update after use
2 parents f2fa05f + dcf918e commit a834c20

File tree

10 files changed

+187
-210
lines changed

10 files changed

+187
-210
lines changed

README.md

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,19 @@ This is still a work in progress. This Repo will contain the full pipeline to an
2424

2525
**Table of Contents**
2626
1. [About The Project](#about-the-project)
27-
2. [Getting started](#getting-started)
27+
2. [Getting started](#getting-started)
2828
- [Prerequisites](#prerequisites)
29-
3. [Resting state project](#resting-state-project)
30-
3. [Pipeline](#pipeline)
31-
- [Raw data to .set and merge](#raw-data-to-.set-and-merge)
32-
- [Pre processing](#pre-processing)
33-
3. [License](#license)
34-
3. [Contact](#contact)
35-
3. [Acknowledgement](#acknowledgement)
29+
3. [Resting state project](#resting-state-project)
30+
3. [Pipeline](#pipeline)
31+
- [Raw data to .set and merge](#raw-data-to-.set-and-merge)
32+
- [Pre processing](#pre-processing)
33+
3. [Power Frequency Analysis](#power-frequency-analysis)
34+
3. [Microstates](#microstates)
35+
- [I_Mictrostates_groups](#i_mictrostates_groups)
36+
- [I_Mictrostates_all](#i_mictrostates_all)
37+
3. [License](#license)
38+
3. [Contact](#contact)
39+
3. [Acknowledgement](#acknowledgement)
3640

3741

3842

@@ -115,12 +119,17 @@ After that we use the the [pwelch function of Matlab](https://www.mathworks.com/
115119

116120
# add here what channels we use, for now it's just indivual but we will change this to groups and averages of those groups
117121

118-
### Microstates Groups & all
122+
123+
### Microstates
119124
this script follows the code as descibed in Poulsen, A. T., Pedroni, A., Langer, N., & Hansen, L. K. (2018). Microstate EEGlab toolbox: An introductory guide. [See their guide in bioRxiv for more information.](https://www.biorxiv.org/content/10.1101/289850v1)
120125

121-
In the first part the analysis only focuses on the group level. Since we use both eyes open and eyes closed data, we want to check how many microstates are suggested for both, so we can choose the best (same) amount for both. In the case of patient/control group we would need to compare all 4 the suggestions. Running the whole script would take a lot of time that wasn't needed.
126+
#### I_Mictrostates_groups
127+
In the We first focuses on the group level. Since we use both eyes open and eyes closed data, we want to check how many microstates are suggested for both, so we can choose the best (same) amount for both. In the case of patient/control group we would need to compare all 4 the suggestions. Running the whole script would take a lot of time that wasn't needed.
128+
129+
#### J_Microstates_all
130+
131+
The second script will backfit the mictrostates on the individual EEGs (since now you know how many microstates you want). Giving both plots per subject and adds data to the EEG structure to do stats on.
122132

123-
The second script will do everything again (since now you know how many microstates you want) and backfits it on the individual EEGs. Giving both plots per subject and adds data to the EEG structure to do stats on.
124133

125134

126135
## License

src/A_bdf_merge_sets.m

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,35 @@
11
% Testing the scr code 6/21/2021
2-
subject_list = {'10033' '10130' '10131' '10257' '10281' '10293' '10360' '10369' '10385' '10394' '10438' '10446' '10463' '10476' '10526' '10545' '10561' '10562' '10581' '10585' '10616' '10748' '10780' '10784' '10822' '10858' '10906' '10915' '10929' '10935' '12005' '12006' '12007' '12010' '12215' '12328' '12360' '12413' '12512' '12648' '12651' '12707' '12727' '12739' '12750' '12815' '12898' '12899'};% ------------------------------------------------
2+
%% extra controls
3+
subject_list = {'10297' '10331' '10385' '10497' '10553' '10590' '10640' '10867' '10906' '12004' '12006' '12139' '12177' '12188' '12197' '12203' '12206' '12230' '12272' '12415' '12449' '12474' '12482' '12516' '12534' '12549' '12588' '12632' '12735' '12746' '12755' '12770' '12852' '12870'};
4+
%subject_list = {'10033' '10130' '10131' '10257' '10281' '10293' '10360' '10369' '10385' '10394' '10438' '10446' '10463' '10476' '10526' '10545' '10561' '10562' '10581' '10585' '10616' '10748' '10780' '10784' '10822' '10858' '10906' '10915' '10929' '10935' '12005' '12006' '12007' '12010' '12215' '12328' '12360' '12413' '12512' '12648' '12651' '12707' '12727' '12739' '12750' '12815' '12898' '12899'};% ------------------------------------------------
35

46
%subject_list = {'1106' '1108' '1132' '1134' '1154' '1160' '1173' '1174' '1179' '1190' '1838' '1839' '1874' '11013' '11051' '11056' '11098' '11106' '11198' '11220' '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
57
filename = 'restingstate'; % if your bdf file has a name besides the ID of the participant (e.g. oddball_paradigm)
6-
home_path = '\\data.einsteinmed.org\users\Filip Ana Douwe\Resting state data\Control\'; %place data is (something like 'C:\data\')
8+
home_path = 'C:\Users\dohorsth\Desktop\Testing restingstate\Remaining_controls\'; %place data is (something like 'C:\data\')
79
blocks = 1; % the amount of BDF files. if different participant have different amounts of blocks, run those participant separate
8-
for s = 3:length(subject_list)
10+
for s = 1:length(subject_list)
911
clear ALLEEG
1012
eeglab
1113
close all
1214
data_path = [home_path subject_list{s} '\'];
1315
disp([data_path subject_list{s} '_' filename '.bdf'])
1416

1517
%if blocks == 1
16-
%if participants have only 1 block, load only this one file
17-
EEG = pop_biosig([data_path subject_list{s} '_' filename '.bdf']);
18-
19-
20-
% else
21-
% for bdf_bl = 1:blocks
22-
% %if participants have more than one block, load the blocks in a row
23-
% %your files need to have the same name, except for a increasing number at the end (e.g. id#_file_1.bdf id#_file_2)
24-
% EEG = pop_biosig([data_path subject_list{s} '_' filename '_' num2str(bdf_bl) '.bdf']);
25-
% [ALLEEG, ~] = eeg_store(ALLEEG, EEG, CURRENTSET);
26-
% end
27-
% %since there are more than 1 files, they need to be merged to one big .set file.
28-
% EEG = pop_mergeset( ALLEEG, 1:blocks, 0);
29-
% end
30-
[ALLEEG EEG CURRENTSET] = pop_newset(ALLEEG, EEG, 0,'setname', [subject_list{s} ' restingstate paradigm'],'gui','off'); %adds a name to the internal .set file
18+
%if participants have only 1 block, load only this one file
19+
EEG = pop_biosig([data_path subject_list{s} '_' filename '.bdf']);
20+
21+
22+
% else
23+
% for bdf_bl = 1:blocks
24+
% %if participants have more than one block, load the blocks in a row
25+
% %your files need to have the same name, except for a increasing number at the end (e.g. id#_file_1.bdf id#_file_2)
26+
% EEG = pop_biosig([data_path subject_list{s} '_' filename '_' num2str(bdf_bl) '.bdf']);
27+
% [ALLEEG, ~] = eeg_store(ALLEEG, EEG, CURRENTSET);
28+
% end
29+
% %since there are more than 1 files, they need to be merged to one big .set file.
30+
% EEG = pop_mergeset( ALLEEG, 1:blocks, 0);
31+
% end
32+
[ALLEEG EEG CURRENTSET] = pop_newset(ALLEEG, EEG, 0,'setname', [subject_list{s} ' restingstate paradigm'],'gui','off'); %adds a name to the internal .set file
3133
%save the bdf as a .set file
3234
EEG = pop_saveset( EEG, 'filename',[subject_list{s} '.set'],'filepath',data_path);
3335
end

src/A_bdf_non_paradigm_merge_sets.m

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,40 @@
11
% Testing the scr code 6/21/2021
22
% ------------------------------------------------
3-
%clear variables
4-
subject_list = {'10158' '10165' '10384' '10407' '10451' '10467' '10501' '10534' '10615' '10620' '10639' '10844' '10956'};
3+
%% extra controls
4+
clear variables
5+
%_closed.bdf
6+
%_open.bdf
7+
subject_list = {'10399' '12002' '12122'};
8+
%subject_list = {'10158' '10165' '10384' '10407' '10451' '10467' '10501' '10534' '10615' '10620' '10639' '10844' '10956'};
59
%subject_list = {'1101' '1164' '1808' '1852' '1855' '11014' '11094' '11151' '11170' '11275' '11349' '11516' '11558' '11583' '11647' '11729' '11735' '11768' '11783' '11820' '11912'};
610
filename = 'restingstate'; % if your bdf file has a name besides the ID of the participant (e.g. oddball_paradigm)
7-
home_path = '\\data.einsteinmed.org\users\Filip Ana Douwe\Resting state data\Control\'; %place data is (something like 'C:\data\')
11+
home_path = 'C:\Users\dohorsth\Desktop\Testing restingstate\Remaining_controls\'; %place data is (something like 'C:\data\')
812
wrongconfig = zeros(1,length(subject_list)); %there are 160channel files that have a wrong config file, this is to save them
9-
for s = 8:length(subject_list)
13+
for s = 1:length(subject_list)
1014
clear ALLEEG
1115
eeglab
1216
close all
1317
data_path = [home_path subject_list{s} '\'];
14-
disp([data_path subject_list{s} '_' filename '.bdf'])
18+
disp([data_path subject_list{s} '.bdf'])
1519

1620
%loading file 1, adding triggers
17-
EEG = pop_biosig([data_path subject_list{s} '_' filename '_open.bdf']);
21+
EEG = pop_biosig([data_path subject_list{s} '_open.bdf']);
1822
first = 1; %where the trigger will happen
1923
second = 10;
2024
TRIG = [first 0; second 50]; %script doesn't like only one trigger so adding 2 (first one can be ignored)
2125
%%%% Import All events back into the EEG data structure
2226
EEG = pop_importevent( EEG, 'event', TRIG, 'fields',{'latency','type'},'timeunit',NaN,'append','no');
23-
EEG = pop_editeventvals(EEG,'delete',1); %deleting the extra event
27+
EEG = pop_editeventvals(EEG,'delete',1); %deleting the extra event
2428
EEG = eeg_checkset(EEG);
2529
[ALLEEG EEG] = eeg_store(ALLEEG, EEG, CURRENTSET);
2630
%loading file 2, adding triggers
27-
EEG = pop_biosig([data_path subject_list{s} '_' filename '_closed.bdf']);
31+
EEG = pop_biosig([data_path subject_list{s} '_closed.bdf']);
2832
first = 1; %where the trigger will happen
2933
second = 10;
3034
TRIG = [first 0; second 51]; %script doesn't like only one trigger so adding 2 (first one can be ignored)
3135
%%%% Import All events back into the EEG data structure
3236
EEG = pop_importevent( EEG, 'event', TRIG, 'fields',{'latency','type'},'timeunit',NaN,'append','no');
33-
EEG = pop_editeventvals(EEG,'delete',1); %deleting the extra event
37+
EEG = pop_editeventvals(EEG,'delete',1); %deleting the extra event
3438
EEG = eeg_checkset(EEG);
3539
[ALLEEG EEG] = eeg_store(ALLEEG, EEG, CURRENTSET);
3640
EEG = pop_mergeset( ALLEEG, 1:2, 0);%merging into one
@@ -44,6 +48,14 @@
4448
wrongconfig(:,s)=string(subject_list(s));
4549
end
4650
disp('fixed configuration')
51+
if strcmp(subject_list{s},'10399') %collected data with 160chn config but only data in 64 ch
52+
EEG = pop_select( EEG, 'channel',{'A1','A2','A3','A4','A5','A6','A7','A8','A9','A10','A11','A12','A13','A14','A15','A16','A17','A18','A19','A20','A21','A22','A23','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','B32'});
53+
correct_64_chan={'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'};
54+
for n=1:64
55+
EEG.chanlocs(n).labels = correct_64_chan{n};
56+
wrongconfig(:,s)=string(subject_list(s));
57+
end
58+
end
4759
EEG = eeg_checkset(EEG);
4860
end
4961
%save the bdf as a .set file

src/B_preprocess1.m

Lines changed: 7 additions & 4 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 = {'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
@@ -17,8 +17,11 @@
1717
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'};
1818
home_path = 'C:\Users\dohorsth\Desktop\Testing restingstate\Aging\';
1919
elseif strcmp(group{g},'Control')
20-
subject_list = {'10158' '10165' '10384' '10407' '10451' '10467' '10501' '10534' '10615' '10620' '10639' '10844' '10956' '10033' '10130' '10131' '10257' '10281' '10293' '10360' '10369' '10394' '10438' '10446' '10463' '10476' '10526' '10545' '10561' '10562' '10581' '10585' '10616' '10748' '10780' '10784' '10822' '10858' '10906' '10915' '10929' '10935' '12005' '12007' '12010' '12215' '12328' '12360' '12413' '12512' '12648' '12651' '12707' '12727' '12739' '12750' '12815' '12898' '12899'};% ------------------------------------------------
21-
home_path = 'C:\Users\dohorsth\Desktop\Testing restingstate\Control\';
20+
%% extra controls
21+
subject_list = {'10297' '10331' '10385' '10399' '10497' '10553' '10590' '10640' '10867' '10906' '12002' '12004' '12006' '12122' '12139' '12177' '12188' '12197' '12203' '12206' '12230' '12272' '12415' '12449' '12474' '12482' '12516' '12534' '12549' '12588' '12632' '12735' '12746' '12755' '12770' '12852' '12870'};
22+
%% aged matched controls
23+
%subject_list = {'10158' '10165' '10384' '10407' '10451' '10467' '10501' '10534' '10615' '10620' '10639' '10844' '10956' '10033' '10130' '10131' '10257' '10281' '10293' '10360' '10369' '10394' '10438' '10446' '10463' '10476' '10526' '10545' '10561' '10562' '10581' '10585' '10616' '10748' '10780' '10784' '10822' '10858' '10906' '10915' '10929' '10935' '12005' '12007' '12010' '12215' '12328' '12360' '12413' '12512' '12648' '12651' '12707' '12727' '12739' '12750' '12815' '12898' '12899'};% ------------------------------------------------
24+
home_path = 'C:\Users\dohorsth\Desktop\Testing restingstate\Remaining_controls\';
2225
end
2326
deleted_channels=zeros(length(subject_list),2);
2427
wrongconfig_type2 = zeros(1,length(subject_list));
@@ -76,7 +79,7 @@
7679
old_n_chan = EEG.nbchan;
7780
EEG = clean_artifacts(EEG, 'FlatlineCriterion',5,'ChannelCriterion',0.8,'LineNoiseCriterion',4,'Highpass','off','BurstCriterion','off','WindowCriterion','off','BurstRejection','on','Distance','Euclidian');
7881
new_n_chan = EEG.nbchan;
79-
deleted_channels{s} = [string(subject_list{s}), old_n_chan-new_n_chan] ;
82+
deleted_channels(s,:) = [string(subject_list{s}), old_n_chan-new_n_chan] ;
8083
EEG = pop_saveset( EEG, 'filename',[subject_list{s} '_exchn.set'],'filepath', data_path);
8184
end
8285
%saving matrixes for quality control

src/C_manual_check.m

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@
33
%% ASD
44
%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
55
%home_path = 'C:\Users\dohorsth\Desktop\Testing restingstate\ASD\';
6-
%% ASD controls
6+
%% aged matched controls
77
%subject_list = {'10033' '10130' '10131' '10158' '10165' '10257' '10281' '10293' '10360' '10369' '10384' '10394' '10407' '10438' '10446' '10451' '10463' '10467' '10476' '10501' '10526' '10534' '10545' '10561' '10562' '10581' '10585' '10616' '10615' '10620' '10639' '10748' '10780' '10784' '10822' '10858' '10906' '10915' '10929' '10935' '10844' '10956' '12005' '12007' '12010' '12215' '12328' '12360' '12413' '12512' '12648' '12651' '12707' '12727' '12739' '12750' '12815' '12898' '12899'};% ------------------------------------------------
88
%home_path = 'C:\Users\dohorsth\Desktop\Testing restingstate\Control\';
9+
%% extra controls
10+
subject_list = {'10297' '10331' '10385' '10399' '10497' '10553' '10590' '10640' '10867' '10906' '12002' '12004' '12006' '12122' '12139' '12177' '12188' '12197' '12203' '12206' '12230' '12272' '12415' '12449' '12474' '12482' '12516' '12534' '12549' '12588' '12632' '12735' '12746' '12755' '12770' '12852' '12870'};
11+
% did these again because need extra channels deleted
12+
% subject_list = {'12139' '10399'};
13+
home_path = 'C:\Users\dohorsth\Desktop\Testing restingstate\Remaining_controls\';
914
%% MoBI
10-
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'};
11-
% controls and ASD subjects that need to be re-checked because of 160 channel info
12-
%'10131' '10257' '10369' '10438' '10545' '10585' '12360' '12898' '1808' '1852' '1855' '11345' '1106' '1134' '1154' '1160' '1174' '1179' '1190' '1838' '11106' '11375' '11913'
13-
home_path = 'C:\Users\dohorsth\Desktop\Testing restingstate\Aging\';
15+
% 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'};
16+
% % controls and ASD subjects that need to be re-checked because of 160 channel info
17+
% %'10131' '10257' '10369' '10438' '10545' '10585' '12360' '12898' '1808' '1852' '1855' '11345' '1106' '1134' '1154' '1160' '1174' '1179' '1190' '1838' '11106' '11375' '11913'
18+
% home_path = 'C:\Users\dohorsth\Desktop\Testing restingstate\Aging\';
1419
for s=1:length(subject_list)
1520
clear bad_chan;
1621
fprintf('\n******\nProcessing subject %s\n******\n\n', subject_list{s});

0 commit comments

Comments
 (0)