Skip to content

Commit 204c610

Browse files
update according to 22q project
1 parent 353a548 commit 204c610

File tree

5 files changed

+104
-103
lines changed

5 files changed

+104
-103
lines changed

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ The data is down-sampled from 512Hz to 256 Hz.
9090
Externals are all deleted since not everyone has externals. So we cannot use them as a reference.
9191
We apply a 1Hz and 50Hz filter.
9292
We add channel info to all the channel. For this we use the following 3 files: standard-10-5-cap385, BioSemi160, BioSemi64. The first 2 are from BESA and have the correct layout. The 3rd is needed for the MoBI data. You can find these in the Functions and files folder (inside the src folder).
93-
Lastly this script uses eeglab's clean_artifacts function deletes the bad channels and bad parts of data. Channels will get deleted by the standard noise criteria, if they are flat over 5 seconds and the function checks if channels are overly correlated with each other.After that it devides the data in 0.5 second epochs. In these it looks if there data has peaks that go over 20 standard deviantion of the channels amplitlude. If so these get deleted. Because it's possible that between 2 of these moments there is a very short amount of data, we make sure to delete all the continues data if between 2 boundries there is less then 2 seconds of data.
93+
Lastly this script uses eeglab's clean_artifacts function deletes the bad channels and bad parts of data. Channels will get deleted by the standard noise criteria, if they are flat over 5 seconds and the function checks if channels are overly correlated with each other.After that it devides the data in 0.5 second epochs. In these it looks if there data has peaks that go over 35 standard deviantion of the channels amplitlude. If so these get deleted. Because it's possible that between 2 of these moments there is a very short amount of data, we make sure to delete all the continues data if between 2 boundries there is less then 2 seconds of data. We got to the criteria of 35, because 20 is the default setting, but because resting state data is different from task based data, we had to find out a way that we still had enough data left, without it being noisy.
9494

9595
#### C_manual_check
9696
This script plots all the data in EEGlab as continues data and allows you to delete channels manually.
@@ -104,11 +104,8 @@ This script loads a file with all the original channels, deletes the externals a
104104
We chose to interpolate before the ICA because like this we can still use the ICA weights for all the channels, and since we are setting a PCA (amount of ICs we want the ICA funtion to create) we account for the interpolated channels not being used for this.
105105

106106
This script will do an average reference.
107-
This is followed by an [Independent Component Analysis](https://eeglab.org/tutorials/06_RejectArtifacts/RunICA.html). We use the pca option to prevent rank-deficiencies.
108-
After his we delete only eye components by using [IClabel](https://github.com/sccn/ICLabel). IClabel will only delete the component if it has more than 80% eye data and less then 10% brain data. We arrived at this criteria after comparing (for a different dataset) how many components we (Ana, Douwe and Filip) would delete manually and what threshold would get the closest to that.
109-
After that we use [pop_rejcont](https://github.com/wojzaremba/active-delays/blob/master/external_tools/eeglab11_0_4_3b/functions/popfunc/pop_rejcont.m). This function epochs the data temporally and deletes the epochs that are noisy. We set this to a threshold of 8, because this would delete between 0-20% of the data. We save a matlab structure with how much data of each participant get's deleted.
110-
111-
**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.
107+
This is followed by an [Independent Component Analysis](https://eeglab.org/tutorials/06_RejectArtifacts/RunICA.html). We use the pca option to prevent rank-deficiencies, as best as we can. We set it to be all channels before interpolation - 1. We don't want more because this gives "Ghost ICs" that are duplicates of existing ones. We also exclude an extra IC because of the avg ref, hence the -1.
108+
After his we delete eye, muscle and channel noise components by using [IClabel](https://github.com/sccn/ICLabel). IClabel will only delete the component if it has more than 70% eye data or 80% muscle or 70% channel noise and always less then 10% brain data. Normally we only delete eye components (>0.8), and we arrived at this criteria after comparing (for a different dataset) how many components we (Ana, Douwe and Filip) would delete manually and what threshold would get the closest to that. However, since this is different data, and it's un epoched so its harder to clean, we decided to also delete extra components.
112109

113110

114111
#### G_preprocces4

src/B_preprocess1.m

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,21 @@
99
% ------------------------------------------------
1010
clear variables
1111
eeglab
12-
group = {'Control' '22q' 'schiz'};%
12+
group = { 'Control' '22q' 'schiz'};%
1313
lowpass_filter_hz=50; %50hz filter
1414
highpass_filter_hz=1; %1hz filter
15-
script_location= 'C:\Users\dohorsth\Documents\GitHub\resting-state-analysis-pipeline-microstates-frequency\src\';
15+
script_location= 'D:\restingstate\scripts\';
16+
1617
for g=1:length(group)
1718
if strcmp(group{g},'22q')
18-
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
19-
home_path = 'D:\Data\';
19+
subject_list = {'2201' '2202' '2204' '2207' '2212' '2216' '2222' '2229' '2231' '2243' '2256' '2257' '2260' '2261' '2267' '2270' '2274' '2281' '2284' '2286' '2292' '2295'};
20+
home_path = 'D:\restingstate\data\';
2021
elseif strcmp(group{g},'schiz')
21-
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'};
22-
home_path = 'D:\Data\';
22+
subject_list = {'7003' '7007' '7019' '7025' '7046' '7049' '7051' '7054' '7058' '7059' '7061' '7064' '7065' '7073' '7075' '7078' '7089' '7092' '7094' '7123' '7556' '7808'};
23+
home_path = 'D:\restingstate\data\';
2324
elseif strcmp(group{g},'Control')
24-
subject_list = {'10281'};%'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'};% ------------------------------------------------
25-
home_path = 'C:\Users\dohorsth\Desktop\practice\';%'C:\Users\dohorsth\Desktop\Testing restingstate\Remaining_controls\';
25+
subject_list = {'10293' '10561' '10562' '10581' '10616' '10748' '10822' '10858' '10935' '12004' '12010' '12139' '12177' '12188' '12197' '12203' '12206' '12215' '12272' '12413' '12415' '12449' '12482' '12512' '12588' '12632' '12648' '12651' '12707' '12727' '12739' '12746' '12750' '12755' '12770' '12815' '12852' '12870'};
26+
home_path = 'D:\restingstate\data\';
2627
end
2728
deleted_channels=zeros(length(subject_list),2);
2829
deleted_data=zeros(length(subject_list),2);
@@ -77,16 +78,30 @@
7778
% components in ICA or if these are pre-deleted now (which they shouldn't)
7879
%EEG = pop_clean_rawdata(EEG,
7980
%'FlatlineCriterion',5,'ChannelCriterion',0.8,'LineNoiseCriterion',4,'Highpass','off','BurstCriterion','off','WindowCriterion','off','BurstRejection','off','Distance','Euclidian');%doesn't delete bad periods
80-
EEG = pop_clean_rawdata(EEG, 'FlatlineCriterion',5,'ChannelCriterion',0.8,'LineNoiseCriterion',4,'Highpass','off','BurstCriterion',20,'WindowCriterion','off','BurstRejection','on','Distance','Euclidian'); % deletes bad chns and bad periods
81+
%first at 'BurstCriterion',20, this caused too much data to be
82+
%deleted, second time at 'BurstCriterion',50, this caused too few data to be
83+
EEG = pop_clean_rawdata(EEG, 'FlatlineCriterion',5,'ChannelCriterion',0.8,'LineNoiseCriterion',4,'Highpass','off','BurstCriterion',35,'WindowCriterion','off','BurstRejection','on','Distance','Euclidian'); % deletes bad chns and bad periods
8184
EEG.deleteddata_wboundries=100-EEG.pnts/old_samples*100;
8285
new_n_chan = EEG.nbchan;
8386
deleted_sample=EEG.pnts;
84-
for i = length(EEG.event)-1:-1:1
85-
if strcmp(EEG.event(i).type, 'boundary') && strcmp(EEG.event(i+1).type, 'boundary') && EEG.event(i+1).latency/EEG.srate-EEG.event(i).latency/EEG.srate < 2 %following event is also a boundary and less then 2 seconds of "good" data between them
86-
disp(i)
87-
EEG = pop_select( EEG, 'notime',[EEG.event(i).latency/EEG.srate EEG.event(i+1).latency/EEG.srate] );
87+
if ~isempty(EEG.event) %at least 1 participant with no events
88+
%adding one boundary at the end to stop issues, will delete later
89+
for i=1:length(EEG.event)
90+
EEG.event(i).time=EEG.event(i).latency/EEG.srate
8891
end
92+
EEG.event(length(EEG.event)+1)=EEG.event(length(EEG.event)); EEG.event(length(EEG.event)).type='temp';% EEG.event(length(EEG.event)).latency=EEG.event(length(EEG.event)).latency+100;EEG.event(length(EEG.event)).duration=EEG.event(length(EEG.event)).duration+100;
93+
for i = length(EEG.event)-1:-1:1%12139 caused issue
94+
if strcmp(EEG.event(i).type, 'boundary') && strcmp(EEG.event(i+1).type, 'boundary') && EEG.event(i+1).latency/EEG.srate-EEG.event(i).latency/EEG.srate < 2 %following event is also a boundary and less then 2 seconds of "good" data between them
95+
disp(i)
96+
EEG = pop_select( EEG, 'notime',[EEG.event(i).latency/EEG.srate EEG.event(i+1).latency/EEG.srate] );
97+
if strcmp(EEG.event(length(EEG.event)).type, 'boundary')
98+
EEG.event(length(EEG.event)+1)=EEG.event(length(EEG.event)); EEG.event(length(EEG.event)).type='temp';
99+
end
100+
end
101+
end
102+
EEG.event(length(EEG.event)) = [];
89103
end
104+
% deleting the event we added before
90105
new_samples=EEG.pnts;
91106
EEG.deleteddata=100-EEG.pnts/old_samples*100;
92107
deleted_channels(s,:) = [string(subject_list{s}), old_n_chan-new_n_chan] ;

src/C_manual_check.m

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,10 @@
44
% Deleting remaining bad channels by eye + seeing if there is something
55
% of note going on with the raw data of each person
66
clear variables
7-
%% ASD
8-
%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
9-
%home_path = 'C:\Users\dohorsth\Desktop\Testing restingstate\ASD\';
10-
%% aged matched controls
11-
%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'};% ------------------------------------------------
12-
%home_path = 'C:\Users\dohorsth\Desktop\Testing restingstate\Control\';
13-
%% extra controls
14-
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'};
15-
home_path = 'C:\Users\dohorsth\Desktop\Testing restingstate\Remaining_controls\';
16-
%% MoBI
17-
% 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'};
18-
% % controls and ASD subjects that need to be re-checked because of 160 channel info
19-
% %'10131' '10257' '10369' '10438' '10545' '10585' '12360' '12898' '1808' '1852' '1855' '11345' '1106' '1134' '1154' '1160' '1174' '1179' '1190' '1838' '11106' '11375' '11913'
20-
% home_path = 'C:\Users\dohorsth\Desktop\Testing restingstate\Aging\';
7+
%subject_list = {'2201' '2202' '2204' '2207' '2212' '2216' '2222' '2229' '2231' '2243' '2256' '2257' '2260' '2261' '2267' '2270' '2274' '2281' '2284' '2286' '2292' '2295'};
8+
%subject_list = {'7003' '7007' '7019' '7025' '7046' '7049' '7051' '7054' '7058' '7059' '7061' '7064' '7065' '7073' '7075' '7078' '7089' '7092' '7094' '7123' '7556' '7808'};
9+
subject_list = {'10293' '10561' '10562' '10581' '10616' '10748' '10822' '10858' '10935' '12004' '12010' '12139' '12177' '12188' '12197' '12203' '12206' '12215' '12272' '12413' '12415' '12449' '12482' '12512' '12588' '12632' '12648' '12651' '12707' '12727' '12739' '12746' '12750' '12755' '12770' '12815' '12852' '12870'};
10+
home_path = 'D:\restingstate\data\';
2111
for s=1:length(subject_list)
2212
clear bad_chan;
2313
fprintf('\n******\nProcessing subject %s\n******\n\n', subject_list{s});
@@ -33,3 +23,8 @@
3323
close all
3424

3525
end
26+
%2204 a lot of alpha eyes closed
27+
%7064 muscle artifact, check ICA
28+
%10561 noisy
29+
%12449 don't use only 16 chn left
30+
%12707 check n channels (seems few left)

0 commit comments

Comments
 (0)