From 4b620529172b5333f7ac97ed2cc4352a307eec68 Mon Sep 17 00:00:00 2001 From: douwehorsthuis Date: Thu, 21 Oct 2021 13:33:34 -0400 Subject: [PATCH] Replacing it with most up-to-date pipeline files --- README.md | 2 +- src/A_merge_sets.m | 49 +++-- src/B_downs_filt.m | 31 --- src/C_channelInfo_excludeexterm.m | 30 --- src/C_manual_check.m | 19 ++ src/D_exclud_channels.m | 24 --- src/D_reref_exclextrn_avgref_ica_autoexcom.m | 117 +++++++++++ src/E_interpolate.m | 40 ++++ src/E_ref.m | 26 --- src/F_epoching.m | 58 ++++++ src/F_ica.m | 34 --- src/F_vg_ica_autoexcom.m | 50 ----- src/F_vg_ica_excom.m | 34 --- src/G_epoching - needs to be changes.m | 43 ---- src/G_epoching.m | 45 ---- src/G_individual_trials_export.m | 186 +++++++++++++++++ src/G_vg_excom.m | 48 ----- src/G_vg_interpolate.m | 52 ----- src/RT_bin.m | 46 ----- src/binlist.txt | 12 ++ src/binlist_all_rt.txt | 8 - src/eventlist.txt | 3 - src/events.txt | 5 - src/rt_events.txt | 2 - src/vg_trail_to_excel_all_1.m | 207 ------------------- 25 files changed, 464 insertions(+), 707 deletions(-) delete mode 100644 src/B_downs_filt.m delete mode 100644 src/C_channelInfo_excludeexterm.m create mode 100644 src/C_manual_check.m delete mode 100644 src/D_exclud_channels.m create mode 100644 src/D_reref_exclextrn_avgref_ica_autoexcom.m create mode 100644 src/E_interpolate.m delete mode 100644 src/E_ref.m create mode 100644 src/F_epoching.m delete mode 100644 src/F_ica.m delete mode 100644 src/F_vg_ica_autoexcom.m delete mode 100644 src/F_vg_ica_excom.m delete mode 100644 src/G_epoching - needs to be changes.m delete mode 100644 src/G_epoching.m create mode 100644 src/G_individual_trials_export.m delete mode 100644 src/G_vg_excom.m delete mode 100644 src/G_vg_interpolate.m delete mode 100644 src/RT_bin.m create mode 100644 src/binlist.txt delete mode 100644 src/binlist_all_rt.txt delete mode 100644 src/eventlist.txt delete mode 100644 src/events.txt delete mode 100644 src/rt_events.txt delete mode 100644 src/vg_trail_to_excel_all_1.m diff --git a/README.md b/README.md index 3424f36..42acaeb 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Logo -

EEG pipeline using EEGlab Specific to Visual Gating

+

EEG pipeline using EEGlab

This EEG pipeline is made to analyze data collected with a biosemi system, using however many channels you want. There are several cleaning steps (e.g. channel rejection, ICA, epoch rejection) after which stats can be done using R studio. This pipeline contains several scripts, organized alphabetically. Each script runs a loop on all the participants, making sure that the same steps are taken for each participant. The reason it is not one big script is, because after running each script it would be a good moment to check if you are happy with the data. diff --git a/src/A_merge_sets.m b/src/A_merge_sets.m index e15f2c7..e5a75d3 100644 --- a/src/A_merge_sets.m +++ b/src/A_merge_sets.m @@ -1,19 +1,32 @@ -% EEGLAB merge sets modified from Ana on 2017-07-11 +% EEGLAB merge sets, and creates .set file +% by Douwe Horsthuis updated on 6/21/2021 % ------------------------------------------------ -[ALLEEG EEG CURRENTSET ALLCOM] = eeglab; -EEG = pop_biosig('\\data.einsteinmed.org\users\Ana and Douwe\22Q\Visual gating\Data\12459\12459_visualgating_1.bdf', 'ref',[67 68] ,'refoptions',{'keepref' 'off'}); -[ALLEEG EEG CURRENTSET] = pop_newset(ALLEEG, EEG, 0,'setname','12459_1','gui','off'); -EEG = pop_saveset( EEG, 'filename','12459_1.set','filepath','\\data.einsteinmed.org\users\Ana and Douwe\22Q\Visual gating\Data\12459\\'); -[ALLEEG EEG] = eeg_store(ALLEEG, EEG, CURRENTSET); -EEG = pop_biosig('\\data.einsteinmed.org\users\Ana and Douwe\22Q\Visual gating\Data\12459\12459_visualgating_2.bdf', 'ref',[67 68] ,'refoptions',{'keepref' 'off'}); -[ALLEEG EEG CURRENTSET] = pop_newset(ALLEEG, EEG, 0,'setname','12459_2','gui','off'); -EEG = pop_saveset( EEG, 'filename','12459_2.set','filepath','\\data.einsteinmed.org\users\Ana and Douwe\22Q\Visual gating\Data\12459\\'); -[ALLEEG EEG] = eeg_store(ALLEEG, EEG, CURRENTSET); -EEG = eeg_checkset( EEG ); -EEG = pop_mergeset( ALLEEG, [1 2 ], 0); -[ALLEEG EEG CURRENTSET] = pop_newset(ALLEEG, EEG, 1,'setname','12459','gui','off'); -EEG = eeg_checkset( EEG ); -EEG = pop_saveset( EEG, 'filename','12459.set','filepath','\\data.einsteinmed.org\users\Ana and Douwe\22Q\Visual gating\Data\12459\'); -[ALLEEG EEG] = eeg_store(ALLEEG, EEG, CURRENTSET); -[ALLEEG EEG CURRENTSET ALLCOM] = eeglab; -12459 \ No newline at end of file +subject_list = {'some sort of ID' 'a different id for a different particpant'}; %all the IDs for the indivual particpants +filename = 'the_rest_of_the_file_name'; % if your bdf file has a name besides the ID of the participant (e.g. oddball_paradigm) +home_path = 'path_where_to_load_in_pc'; %place data is (something like 'C:\data\') +blocks = 5; % the amount of BDF files. if different participant have different amounts of blocks, run those participant separate +for s = 1:length(subject_list) + clear ALLEEG + eeglab + close all + data_path = [home_path subject_list{s} '\']; + disp([data_path subject_list{s} '_' filename '.bdf']) + if blocks == 1 + %if participants have only 1 block, load only this one file + EEG = pop_biosig([data_path subject_list{s} '_' filename '.bdf']); + else + for bdf_bl = 1:blocks + %if participants have more than one block, load the blocks in a row + %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) + EEG = pop_biosig([data_path subject_list{s} '_' filename '_' num2str(bdf_bl) '.bdf']); + [ALLEEG, ~] = eeg_store(ALLEEG, EEG, CURRENTSET); + end + %since there are more than 1 files, they need to be merged to one big .set file. + EEG = pop_mergeset( ALLEEG, 1:blocks, 0); + end + %adding info to the EEG structure + EEG.subject = subject_list{s}; %subject ID + %save the bdf as a .set file + + EEG = pop_saveset( EEG, 'filename',[subject_list{s} '.set'],'filepath',data_path); +end diff --git a/src/B_downs_filt.m b/src/B_downs_filt.m deleted file mode 100644 index 458260f..0000000 --- a/src/B_downs_filt.m +++ /dev/null @@ -1,31 +0,0 @@ - - -% This defines the set of subjects -subject_list = {'12549','12588','12648','12666','12707','12727','12746','12750','12755','12770','12815','12852','12858','12870'};% -nsubj = length(subject_list); % number of subjects - -% Path to the parent folder, which contains the data folders for all subjects -home_path = '\\data.einsteinmed.org\users\Ana and Douwe\22Q\Visual gating\Data\'; - -% Loop through all subjects -for s=1:nsubj - fprintf('\n******\nProcessing subject %s\n******\n\n', subject_list{s}); - - % Path to the folder containing the current subject's data - data_path = [home_path subject_list{s} '\\']; - - % Load original dataset - fprintf('\n\n\n**** %s: Loading dataset ****\n\n\n', subject_list{s}); - EEG = pop_loadset('filename', [subject_list{s} '.set'], 'filepath', data_path); - EEG = eeg_checkset( EEG ); - EEG = pop_resample( EEG, 256); - EEG = eeg_checkset( EEG ); - EEG = pop_eegfiltnew(EEG, [],1,1690,1,[],1); - EEG = eeg_checkset( EEG ); - EEG = pop_eegfiltnew(EEG, [],45,152,0,[],1); - EEG = eeg_checkset( EEG ); - EEG = pop_saveset( EEG, 'filename',[subject_list{s} '_downft.set'],'filepath', data_path); - [ALLEEG EEG] = eeg_store(ALLEEG, EEG, CURRENTSET); - eeglab redraw; -end; - diff --git a/src/C_channelInfo_excludeexterm.m b/src/C_channelInfo_excludeexterm.m deleted file mode 100644 index 7942a6f..0000000 --- a/src/C_channelInfo_excludeexterm.m +++ /dev/null @@ -1,30 +0,0 @@ -eeglab - -% This defines the set of subjects -subject_list = {'2201','2202','2204','2207','2208','2212','2216','2217','2220','2221','2222','2223','2229','2231','2236','2237','2238','2243','2247','2250','2252','2254','2256','2257','2261','2262','2267','2270','2274','2281','2284','2285','2286','2292','2295','2297','7003','7007','7019','7025','7046','7048','7049','7051','7054','7058','7059','7061','7063','7064','7073','7074','7075','7078','7089','7092','7123','7556','7808','10092','10130','10149','10172','10214','10360','10394','10446','10463','10476','10581','10585','10590','10640','10748','10780','10784','10862','10888','10915','10967','12004','12005','12006','12007','12012','12038','12139','12177','12188','12197','12203','12206','12215','12230','12272','12313','12328','12329','12413','12433','12449','12482','12512','12549','12588','12648','12666','12707','12727','12746','12750','12755','12770','12815','12852','12858','12870'};% -nsubj = length(subject_list); % number of subjects - -% Path to the parent folder, which contains the data folders for all subjects -home_path = '\\data.einsteinmed.org\users\Ana and Douwe\22Q\Visual gating\Data\'; - -% Loop through all subjects -for s=1:nsubj - fprintf('\n******\nProcessing subject %s\n******\n\n', subject_list{s}); - - % Path to the folder containing the current subject's data - data_path = [home_path subject_list{s} '/']; - - % Load original dataset - fprintf('\n\n\n**** %s: Loading dataset ****\n\n\n', subject_list{s}) - - EEG = pop_loadset('filename', [subject_list{s} '_downft.set'], 'filepath', data_path); - EEG=pop_chanedit(EEG, 'lookup','C:\Users\dohorsth\Documents\Matlab\eeglab2019_1\plugins\dipfit\standard_BESA\standard-10-5-cap385.elp'); - [ALLEEG EEG] = eeg_store(ALLEEG, EEG, CURRENTSET); - EEG = pop_select( EEG,'nochannel',{'EXG1','EXG2','EXG3','EXG4','EXG5','EXG6','EXG7','EXG8'}); - EEG = pop_saveset( EEG, 'filename',[subject_list{s} '_exext.set'],'filepath', data_path); - - end; - - - - \ No newline at end of file diff --git a/src/C_manual_check.m b/src/C_manual_check.m new file mode 100644 index 0000000..872cf1d --- /dev/null +++ b/src/C_manual_check.m @@ -0,0 +1,19 @@ +% Plotting the raw data to see if there are remaining bad or flat channels +% Created by Douwe Horsthuis last update 5/21/2021 +% ------------------------------------------------ +subject_list = {'some sort of ID' 'a different id for a different particpant'}; +home_path = 'the main folder where you store your data'; +for s=1:length(subject_list) + clear bad_chan; + fprintf('\n******\nProcessing subject %s\n******\n\n', subject_list{s}); + data_path = [home_path subject_list{s} '\']; + EEG = pop_loadset('filename', [subject_list{s} '_exchn.set'], 'filepath', data_path); + pop_eegplot( EEG, 1, 1, 1); + prompt = 'Delete channels? If yes, input them all as strings inside {}. If none hit enter '; + bad_chan = input(prompt); % + if isempty(bad_chan) ~=1 + EEG = pop_select( EEG, 'nochannel',bad_chan); + EEG = pop_saveset( EEG, 'filename',[subject_list{s} '_exchn.set'],'filepath', data_path); + end + close all +end diff --git a/src/D_exclud_channels.m b/src/D_exclud_channels.m deleted file mode 100644 index 879bb32..0000000 --- a/src/D_exclud_channels.m +++ /dev/null @@ -1,24 +0,0 @@ -eeglab - -% This defines the set of subjects -subject_list = {'2201','2202','2204','2207','2208','2212','2216','2217','2220','2221','2222','2223','2229','2231','2236','2237','2238','2243','2247','2250','2252','2254','2256','2257','2261','2262','2267','2270','2274','2281','2284','2285','2286','2292','2295','2297','7003','7007','7019','7025','7046','7048','7049','7051','7054','7058','7059','7061','7063','7064','7073','7074','7075','7078','7089','7092','7123','7556','7808','10092','10130','10149','10172','10214','10360','10394','10446','10463','10476','10581','10585','10590','10640','10748','10780','10784','10862','10888','10915','10967','12004','12005','12006','12007','12012','12038','12139','12177','12188','12197','12203','12206','12215','12230','12272','12313','12328','12329','12413','12433','12449','12482','12512','12549','12588','12648','12666','12707','12727','12746','12750','12755','12770','12815','12852','12858','12870'};% -nsubj = length(subject_list); % number of subjects - -% Path to the parent folder, which contains the data folders for all subjects -home_path = '\\data.einsteinmed.org\users\Ana and Douwe\22Q\Visual gating\Data\'; - -% Loop through all subjects - -for s=1:nsubj - fprintf('\n******\nProcessing subject %s\n******\n\n', subject_list{s}); - - % Path to the folder containing the current subject's data - data_path = [home_path subject_list{s} '\\']; - - % Load original dataset - fprintf('\n\n\n**** %s: Loading dataset ****\n\n\n', subject_list{s}); - EEG = pop_loadset('filename', [subject_list{s} '_exext.set'], 'filepath', data_path); - EEG = eeg_checkset( EEG ); - EEG = pop_rejchan(EEG ,'threshold',5,'norm','on','measure','kurt'); - EEG = pop_saveset( EEG, 'filename',[subject_list{s} '_exchn.set'],'filepath', data_path); -end; diff --git a/src/D_reref_exclextrn_avgref_ica_autoexcom.m b/src/D_reref_exclextrn_avgref_ica_autoexcom.m new file mode 100644 index 0000000..a2515a1 --- /dev/null +++ b/src/D_reref_exclextrn_avgref_ica_autoexcom.m @@ -0,0 +1,117 @@ +% This scripts allows you to re-reference to any channel including externals +% it deletes the externals +% does an average reference +% uses runica to do an Independent Component Analysis +% uses IClabel to define the eye component +% Deletes these and the components also get printed. +% last edits done on by Douwe 9/7/2021 +% ------------------------------------------------ + +clear variables + +% This defines the set of subjects +subject_list = {'some sort of ID' 'a different id for a different particpant'}; +% Path to the parent folder, which contains the data folders for all subjects +home_path = 'the main folder where you store all the data'; +figure_path = 'the main folder where you store all the ic figures'; +components = num2cell(zeros(length(subject_list), 8)); %prealocationg space for speed +refchan = { }; %if you want to re-ref to a channel add the name of the channel here, if empty won't re-ref to any specific channel (for example {'EXG3' 'EXG4'} or {'Cz'}) +for s=1:length(subject_list) + fprintf('\n******\nProcessing subject %s\n******\n\n', subject_list{s}); + % Path to the folder containing the current subject's data + data_path = [home_path subject_list{s} '\\']; + fprintf('\n\n\n**** %s: Loading dataset ****\n\n\n', subject_list{s}); + EEG = pop_loadset('filename', [subject_list{s} '_exchn.set'], 'filepath', data_path); + %re-referencing, if refchan is empty this get's skipped + if isempty(refchan)~=1 %if no re-reference channels chose this gets skipped + for j=1:length(EEG.chanlocs) + if strcmp(refchan{1}, EEG.chanlocs(j).labels) + ref1=j; %stores here the index of the first ref channel + end + end + if length(refchan) ==1 + EEG = pop_reref( EEG, ref1); % re-reference to the channel if there is only one input) + elseif length(refchan) ==2 %if 2 re-ref channels are chosen it needs to find the second one + for j=1:length(EEG.chanlocs) + if strcmp(refchan{2}, EEG.chanlocs(j).labels) + ref2=j; + end + end + EEG = pop_reref( EEG, [ref1 ref2]); %re-references to the average of 2 channels + end + end + EEG = eeg_checkset( EEG ); + %deleting externals + EEG = pop_select( EEG,'nochannel',{'EXG1','EXG2','EXG3','EXG4','EXG5','EXG6','EXG7','EXG8' 'GSR1' 'GSR2' 'Erg1' 'Erg2' 'Resp' 'Plet' 'Temp'}); + EEG = pop_saveset( EEG, 'filename',[subject_list{s} '_exext.set'],'filepath', data_path); + %another re-ref to the averages as suggested for the ICA + EEG = pop_reref( EEG, []); + EEG = eeg_checkset( EEG ); + EEG = pop_saveset( EEG, 'filename',[subject_list{s} '_ref.set'],'filepath', data_path); + %Independent Component Analysis + EEG = eeg_checkset( EEG ); + pca = EEG.nbchan-1; %the PCA part of the ICA needs stops the rank-deficiency + EEG = pop_runica(EEG, 'extended',1,'interupt','on','pca',pca); %using runica function, with the PCA part + EEG = eeg_checkset( EEG ); + EEG = pop_saveset( EEG, 'filename',[subject_list{s} '_ica.set'],'filepath', data_path); + %organizing components + clear bad_components brain_ic muscle_ic eye_ic hearth_ic line_noise_ic channel_ic other_ic + EEG = iclabel(EEG); %does ICLable function + ICA_components = EEG.etc.ic_classification.ICLabel.classifications ; %creates a new matrix with ICA components + %Only the eyecomponent will be deleted, thus only components 3 will be put into the 8 component + ICA_components(:,8) = ICA_components(:,3); %row 1 = Brain row 2 = muscle row 3= eye row 4 = Heart Row 5 = Line Noise row 6 = channel noise row 7 = other, combining this makes sure that the component also gets deleted if its a combination of all. + bad_components = find(ICA_components(:,8)>0.80 & ICA_components(:,1)<0.10); %if the new row is over 80% of the component and the component has less the 5% brain + %Still labeling all the other components so they get saved in the end + brain_ic = length(find(ICA_components(:,1)>0.80)); + muscle_ic = length(find(ICA_components(:,2)>0.80 & ICA_components(:,1)<0.05)); + eye_ic = length(find(ICA_components(:,3)>0.80 & ICA_components(:,1)<0.05)); + hearth_ic = length(find(ICA_components(:,4)>0.80 & ICA_components(:,1)<0.05)); + line_noise_ic = length(find(ICA_components(:,5)>0.80 & ICA_components(:,1)<0.05)); + channel_ic = length(find(ICA_components(:,6)>0.80 & ICA_components(:,1)<0.05)); + other_ic = length(find(ICA_components(:,7)>0.80 & ICA_components(:,1)<0.05)); + %Plotting all eye componentes and all remaining components + if isempty(bad_components)~= 1 %script would stop if people lack bad components + if ceil(sqrt(length(bad_components))) == 1 + pop_topoplot(EEG, 0, [bad_components bad_components] ,subject_list{s} ,0,'electrodes','on'); + else + pop_topoplot(EEG, 0, [bad_components] ,subject_list{s},[ceil(sqrt(length(bad_components))) ceil(sqrt(length(bad_components)))] ,0,'electrodes','on'); + end + title(subject_list{s}); + print([figure_path subject_list{s} '_Bad_ICs_topos'], '-dpng' ,'-r300'); + EEG = pop_subcomp( EEG, [bad_components], 0); %excluding the bad components + close all + else %instead of only plotting bad components it will plot all components + title(subject_list{s}); text( 0.2,0.5, 'there are no eye-components found') + print([figure_path subject_list{s} '_Bad_ICs_topos'], '-dpng' ,'-r300'); + end + title(subject_list{s}); + pop_topoplot(EEG, 0, 1:size(EEG.icaweights,1) ,subject_list{s},[ceil(sqrt(size(EEG.icaweights,1))) ceil(sqrt(size(EEG.icaweights,1)))] ,0,'electrodes','on'); + print([figure_path subject_list{s} '_remaining_ICs_topos'], '-dpng' ,'-r300'); + close all + %putting both figures in 1 plot saving it, deleting the other 2. + figure('units','normalized','outerposition',[0 0 1 1]) + if EEG.nbchan<65 + subplot(1,5,1); + else + subplot(1,10,1); + end + imshow([figure_path subject_list{s} '_Bad_ICs_topos.png']); + title('Deleted components') + if EEG.nbchan<65 + subplot(1,5,2:5); + else + subplot(1,10,2:10); + end + imshow([figure_path subject_list{s} '_remaining_ICs_topos.png']); + title('Remaining components') + print([figure_path subject_list{s} '_ICs_topos'], '-dpng' ,'-r300'); + %deleting two original files + delete([figure_path subject_list{s} '_Bad_ICs_topos.png']) + delete([figure_path subject_list{s} '_remaining_ICs_topos.png']) + close all + EEG = pop_saveset( EEG, 'filename',[subject_list{s} '_excom.set'],'filepath', data_path);%save + subj_comps=[subject_list(s), num2cell(brain_ic), num2cell(muscle_ic), num2cell(eye_ic), num2cell(hearth_ic), num2cell(line_noise_ic), num2cell(channel_ic), num2cell(other_ic)]; + components(s,:)=[subj_comps]; +end +save([home_path 'components'], 'components'); + diff --git a/src/E_interpolate.m b/src/E_interpolate.m new file mode 100644 index 0000000..e9093f5 --- /dev/null +++ b/src/E_interpolate.m @@ -0,0 +1,40 @@ +% this scripts interpolates channels using the _downft.set file and the excom file. It +% creates a matrix with all the previously deleted channels. Created by +% Douwe Horsthuis last update on 6/22/2021 +clear variables +eeglab +close all +subject_list = {'some sort of ID' 'a different id for a different particpant'}; % This defines the set of subjects +name_paradigm = 'name'; % this is needed for saving the table at the end +%participant_info = []; % needed for creating matrix at the end +% Path to the parent folder, which contains the data folders for all subjects +home_path = 'the main folder where you store your data'; +participant_badchan = string(zeros(length(subject_list), 2)); %prealocationg space for speed +% Loop through all subjects +for s=1:length(subject_list) + fprintf('\n******\nProcessing subject %s\n******\n\n', subject_list{s}); + clear labels_all labels_good lables_del data_subj + % Path to the folder containing the current subject's data + data_path = [home_path subject_list{s} '']; + % Load original dataset + fprintf('\n\n\n**** %s: Loading dataset ****\n\n\n', subject_list{s}); + EEG = pop_loadset('filename', [subject_list{s} '_info.set'], 'filepath', data_path);%loading participant file with 64 channels + %deleting externals + EEGinter = pop_select( EEG,'nochannel',{'EXG1','EXG2','EXG3','EXG4','EXG5','EXG6','EXG7','EXG8' 'GSR1' 'GSR2' 'Erg1' 'Erg2' 'Resp' 'Plet' 'Temp'}); + labels_all = {EEGinter.chanlocs.labels}.'; %stores all the labels in a new matrix + EEG = pop_loadset('filename', [subject_list{s} '_excom.set'], 'filepath', data_path); %loads latest pre-proc file + labels_good = {EEG.chanlocs.labels}.'; %saves all the channels that are in the excom file + disp(EEG.nbchan); %writes down how many channels are there + EEG = pop_interp(EEG, EEGinter.chanlocs, 'spherical');%interpolates the data + EEG = eeg_checkset( EEG ); + EEG = pop_saveset( EEG, 'filename', [subject_list{s} '_inter.set'], 'filepath', data_path); %saves data + disp(EEG.nbchan) %should print 64 + + %this part saves all the bad channels + ID numbers + lables_del = setdiff(labels_all,labels_good); %only stores the deleted channels + All_bad_chan = strjoin(lables_del); %puts them in one string rather than individual strings + ID = string(subject_list{s});%keeps all the IDs + data_subj = [ID, All_bad_chan]; %combines IDs and Bad channels + participant_badchan(s,:) = data_subj;%combine new data with old data +end +save([home_path name_paradigm '_participant_interpolation_info'], 'participant_badchan'); \ No newline at end of file diff --git a/src/E_ref.m b/src/E_ref.m deleted file mode 100644 index f9b322e..0000000 --- a/src/E_ref.m +++ /dev/null @@ -1,26 +0,0 @@ -eeglab - -% This defines the set of subjects -subject_list = {'12313','12328','12329','12413','12433','12449','12482','12512','12549','12588','12648','12666','12707','12727','12746','12750','12755','12770','12815','12852','12858','12870'}; - -% Path to the parent folder, which contains the data folders for all subjects -home_path = '\\data.einsteinmed.org\users\Ana and Douwe\22Q\Visual gating\Data\'; - -% Loop through all subjects -for s=1:nsubj - fprintf('\n******\nProcessing subject %s\n******\n\n', subject_list{s}); - - % Path to the folder containing the current subject's data - data_path = [home_path subject_list{s} '\\']; - - % Load original dataset - fprintf('\n\n\n**** %s: Loading dataset ****\n\n\n', subject_list{s}); - EEG = pop_loadset('filename', [subject_list{s} '_exchn.set'], 'filepath', data_path); - EEG = eeg_checkset( EEG ); - EEG = pop_reref( EEG, []); - EEG = eeg_checkset( EEG ); - EEG = pop_saveset( EEG, 'filename',[subject_list{s} '_ref.set'],'filepath', data_path); - [ALLEEG EEG] = eeg_store(ALLEEG, EEG, CURRENTSET); - eeglab redraw; -end; - diff --git a/src/F_epoching.m b/src/F_epoching.m new file mode 100644 index 0000000..943781d --- /dev/null +++ b/src/F_epoching.m @@ -0,0 +1,58 @@ +% EEGLAB and ERPlab epoching script by Douwe Horsthuis on 6/21/2020 +% This script epochs the data +% it deletes the noisy epochs. +% it creates ERPs +% It creates a matrix with how much data it deletes at the end. +% it can also record the RTs and put them in and excel, but it needs folder after the homepath called \All RT files\ +clear variables +eeglab +% This defines the set of subjects +subject_list = {'some sort of ID' 'a different id for a different particpant'}; +name_paradigm = 'name'; % this is needed for saving the table at the end +%participant_info_temp = []; % needed for creating matrix at the end +% Path to the parent folder, which contains the data folders for all subjects +home_path = 'the main folder where you store your data\'; +binlist_location = 'the folder where you stored your binlist\'; %binlist should be named binlist.txt +epoch_time = [-50 400]; +baseline_time = [-50 0]; +n_bins=3;% enter here the number of bins in your binlist +participant_info_temp = string(zeros(length(subject_list), 2+n_bins)); %prealocationg space for speed +% Loop through all subjects +for s=1:length(subject_list) + fprintf('\n******\nProcessing subject %s\n******\n\n', subject_list{s}); + clear data_subj + % Path to the folder containing the current subject's data + data_path = [home_path subject_list{s} '/']; + + % Load original dataset + fprintf('\n\n\n**** %s: Loading dataset ****\n\n\n', subject_list{s}); + EEG = pop_loadset('filename', [subject_list{s} '_inter.set'], 'filepath', data_path); + %epoching + EEG = eeg_checkset( EEG ); + EEG = pop_creabasiceventlist( EEG , 'AlphanumericCleaning', 'on', 'BoundaryNumeric', { -99 }, 'BoundaryString', { 'boundary' } ); + EEG = eeg_checkset( EEG ); + EEG = pop_binlister( EEG , 'BDF', [binlist_location '\binlist.txt'], 'IndexEL', 1, 'SendEL2', 'EEG', 'Voutput', 'EEG' ); + EEG = eeg_checkset( EEG ); + EEG = pop_epochbin( EEG , epoch_time, baseline_time); %epoch size and baseline size + EEG = eeg_checkset( EEG ); + %deleting bad epochs (need erplab plugin for this) + EEG= pop_artmwppth( EEG , 'Channel', 1:EEG.nbchan, 'Flag', 1, 'Threshold', 120, 'Twindow', epoch_time, 'Windowsize', 200, 'Windowstep', 200 );% to flag bad epochs + percent_deleted = (length(nonzeros(EEG.reject.rejmanual))/(length(EEG.reject.rejmanual)))*100; %looks for the length of all the epochs that should be deleted / length of all epochs * 100 + EEG = pop_rejepoch( EEG, [EEG.reject.rejmanual] ,0);%this deletes the flaged epoches + %creating ERPS and saving files + ERP = pop_averager( EEG , 'Criterion', 1, 'DSindex',1, 'ExcludeBoundary', 'on', 'SEM', 'on' ); + EEG = pop_saveset( EEG, 'filename',[subject_list{s} '_epoched.set'],'filepath', data_path); + ERP = pop_savemyerp(ERP, 'erpname', [subject_list{s} '.erp'], 'filename', [subject_list{s} '.erp'], 'filepath', data_path); %saving a.ERP file + %the following line creates an excel with RTs. For this to be possible make sure you have the right events in your eventlist. + %values = pop_rt2text(ERP, 'eventlist',1, 'filename', [home_path '\All RT files\' subject_list{s} '_rt.xls'], 'header', 'on', 'listformat', 'basic' ); + + ID = string(subject_list{s}); + data_subj = [ID, percent_deleted, ERP.EVENTLIST.trialsperbin]; %ERP.EVENTLIST.trialsperbin gives all the trials per bin + participant_info_temp(s,:) = data_subj; +end +colNames = [{'ID','%data deleted'} ERP.bindescr]; %adding names for columns [ERP.bindescr] adds all the name of the bins +participant_info = array2table( participant_info_temp,'VariableNames',colNames); %creating table with column names +save([home_path name_paradigm '_participant_epoching_cleaing_bin_info'], 'participant_info'); + + + diff --git a/src/F_ica.m b/src/F_ica.m deleted file mode 100644 index 552ddd3..0000000 --- a/src/F_ica.m +++ /dev/null @@ -1,34 +0,0 @@ -eeglab - -% This defines the set of subjects -subject_list = {'12449','12482','12512','12549','12588','12648','12666','12707','12727','12746','12750','12755','12770','12815','12852','12858','12870'}; - -nsubj = length(subject_list); % number of subjects - -% Path to the parent folder, which contains the data folders for all subjects -home_path = '\\data.einsteinmed.org\users\Ana and Douwe\22Q\Visual gating\Data\'; - -% Loop through all subjects -for s=1:nsubj - fprintf('\n******\nProcessing subject %s\n******\n\n', subject_list{s}); - - % Path to the folder containing the current subject's data - data_path = [home_path subject_list{s} '\\']; - - % Load original dataset - fprintf('\n\n\n**** %s: Loading dataset ****\n\n\n', subject_list{s}); - EEG = pop_loadset('filename', [subject_list{s} '_ref.set'], 'filepath', data_path);%loads _ref file - EEG = eeg_checkset( EEG ); - EEG = pop_runica(EEG, 'extended',1,'interupt','on'); %runs runica function - EEG = eeg_checkset( EEG ); - EEG = pop_saveset( EEG, 'filename',[subject_list{s} '_ica.set'],'filepath', data_path); - EEG = iclabel(EEG); %does ICLable function - ICA_components = EEG.etc.ic_classification.ICLabel.classifications ; %creates a new matrix with ICA components - bad_components_muscle = find(ICA_components(:,2)>0.80 & ICA_components(:,1)<0.05); %if component has 80% muscle and 5% or less brain - bad_components_eye = find(ICA_components(:,3)>0.80 & ICA_components(:,1)<0.05);%if component has 80% eye and 5% or less brain - bad_components_Channel_Noise = find(ICA_components(:,6)>0.80 & ICA_components(:,1)<0.05);%if component has 80% channel noise and 5% or less brain - BC = [ bad_components_muscle; bad_components_eye; bad_components_Channel_Noise];%combining the bad components - EEG = pop_subcomp( EEG, BC, 0); %excluding the bad components - EEG = pop_saveset( EEG, 'filename',[subject_list{s} '_excom.set'],'filepath', data_path);%save - eeglab redraw; -end; diff --git a/src/F_vg_ica_autoexcom.m b/src/F_vg_ica_autoexcom.m deleted file mode 100644 index a02ef32..0000000 --- a/src/F_vg_ica_autoexcom.m +++ /dev/null @@ -1,50 +0,0 @@ -% This scripts uses the EEGLAB runica and IClabel label to created ICA -% components and defined and deleted the bad. Created by Douwe Horsthuis 5/7/2020 - -clear all -eeglab - -% This defines the set of subjects -subject_list = {'12449','12482'}; -name_paradigm = 'Visual_Gating' % this is needed for saving the table at the end -nsubj = length(subject_list); % number of subjects -bad_ICA_components_temp = [] % needed for creating table with bad components -% Path to the parent folder, which contains the data folders for all subjects -home_path = '\\data.einsteinmed.org\users\Ana and Douwe\22Q\Visual gating\Data\'; - -% Loop through all subjects -for s=1:nsubj - fprintf('\n******\nProcessing subject %s\n******\n\n', subject_list{s}); - - % Path to the folder containing the current subject's data - data_path = [home_path subject_list{s} '\\']; - - % Load original dataset - fprintf('\n\n\n**** %s: Loading dataset ****\n\n\n', subject_list{s}); - EEG = pop_loadset('filename', [subject_list{s} '_ica.set'], 'filepath', data_path);%loads _ref file - EEG = eeg_checkset( EEG ); - EEG = pop_runica(EEG, 'extended',1,'interupt','on'); %runs runica function - EEG = eeg_checkset( EEG ); - EEG = pop_saveset( EEG, 'filename',[subject_list{s} '_ica.set'],'filepath', data_path); - EEG = iclabel(EEG); %does ICLable function - ICA_components = EEG.etc.ic_classification.ICLabel.classifications ; %creates a new matrix with ICA components - bad_components_muscle = find(ICA_components(:,2)>0.80 & ICA_components(:,1)<0.05); %if component has 80% muscle and 5% or less brain - bad_components_eye = find(ICA_components(:,3)>0.80 & ICA_components(:,1)<0.05);%if component has 80% eye and 5% or less brain - bad_components_Channel_Noise = find(ICA_components(:,6)>0.80 & ICA_components(:,1)<0.05);%if component has 80% channel noise and 5% or less brain - BC = [ bad_components_muscle; bad_components_eye; bad_components_Channel_Noise];%combining the bad components - EEG = pop_subcomp( EEG, BC, 0); %excluding the bad components - EEG = pop_saveset( EEG, 'filename',[subject_list{s} '_excom.set'],'filepath', data_path);%save - - %this part saves all the individual bad components + ID numbers - bad_eye = length(bad_components_eye); - bad_muscle = length(bad_components_muscle); - bad_channel = length(bad_components_Channel_Noise); - ID = string(subject_list{s}); - data_subj = []; - data_subj = [ID, bad_eye, bad_muscle, bad_channel]; % combining everything into one matrix - bad_ICA_components_temp = [bad_ICA_components_temp; data_subj]; % combining it with previouse matrix - eeglab redraw; -end; -colNames = {'ID','N Eye Comp','N Muscle Comp','N Chan_noise'}; %adding names for columns -bad_ICA_components = array2table( bad_ICA_components_temp,'VariableNames',colNames); %creating table with column names -save([home_path name_paradigm '_bad_ICA_components'], 'bad_ICA_components'); %saving table \ No newline at end of file diff --git a/src/F_vg_ica_excom.m b/src/F_vg_ica_excom.m deleted file mode 100644 index 552ddd3..0000000 --- a/src/F_vg_ica_excom.m +++ /dev/null @@ -1,34 +0,0 @@ -eeglab - -% This defines the set of subjects -subject_list = {'12449','12482','12512','12549','12588','12648','12666','12707','12727','12746','12750','12755','12770','12815','12852','12858','12870'}; - -nsubj = length(subject_list); % number of subjects - -% Path to the parent folder, which contains the data folders for all subjects -home_path = '\\data.einsteinmed.org\users\Ana and Douwe\22Q\Visual gating\Data\'; - -% Loop through all subjects -for s=1:nsubj - fprintf('\n******\nProcessing subject %s\n******\n\n', subject_list{s}); - - % Path to the folder containing the current subject's data - data_path = [home_path subject_list{s} '\\']; - - % Load original dataset - fprintf('\n\n\n**** %s: Loading dataset ****\n\n\n', subject_list{s}); - EEG = pop_loadset('filename', [subject_list{s} '_ref.set'], 'filepath', data_path);%loads _ref file - EEG = eeg_checkset( EEG ); - EEG = pop_runica(EEG, 'extended',1,'interupt','on'); %runs runica function - EEG = eeg_checkset( EEG ); - EEG = pop_saveset( EEG, 'filename',[subject_list{s} '_ica.set'],'filepath', data_path); - EEG = iclabel(EEG); %does ICLable function - ICA_components = EEG.etc.ic_classification.ICLabel.classifications ; %creates a new matrix with ICA components - bad_components_muscle = find(ICA_components(:,2)>0.80 & ICA_components(:,1)<0.05); %if component has 80% muscle and 5% or less brain - bad_components_eye = find(ICA_components(:,3)>0.80 & ICA_components(:,1)<0.05);%if component has 80% eye and 5% or less brain - bad_components_Channel_Noise = find(ICA_components(:,6)>0.80 & ICA_components(:,1)<0.05);%if component has 80% channel noise and 5% or less brain - BC = [ bad_components_muscle; bad_components_eye; bad_components_Channel_Noise];%combining the bad components - EEG = pop_subcomp( EEG, BC, 0); %excluding the bad components - EEG = pop_saveset( EEG, 'filename',[subject_list{s} '_excom.set'],'filepath', data_path);%save - eeglab redraw; -end; diff --git a/src/G_epoching - needs to be changes.m b/src/G_epoching - needs to be changes.m deleted file mode 100644 index 3ded0b7..0000000 --- a/src/G_epoching - needs to be changes.m +++ /dev/null @@ -1,43 +0,0 @@ -clear all -eeglab - -% This defines the set of subjects -subject_list = {'2201','2202','2204','2207','2208','2212','2216','2217','2220','2221','2222','2223','2229','2231','2236','2237','2238','2243','2247','2250','2252','2254','2256','2257','2261','2262','2267','2274','2281','2284','2285','2286','2292','2295','2297','7003','7007','7019','7025','7046','7048','7049','7051','7054','7058','7059','7061','7063','7064','7073','7074','7075','7078','7089','7092','7123','7556','7808','10092','10130','10149','10172','10214','10360','10394','10446','10463','10476','10581','10585','10590','10640','10748','10780','10784','10862','10888','10915','10967','12004','12005','12006','12007','12012','12038','12139','12177','12188','12197','12203','12206','12215','12230','12272','12313','12328','12329','12413','12433','12449','12482','12512','12549','12588','12648','12666','12707','12727','12746','12750','12755','12770','12815','12852','12858','12870'};% -name_paradigm = 'Visual_Gating' % this is needed for saving the table at the end -nsubj = length(subject_list); % number of subjects -participant_info = []; % needed for creating matrix at the end -% Path to the parent folder, which contains the data folders for all subjects -home_path = '\\data.einsteinmed.org\users\Ana and Douwe\22Q\Visual gating\Data\'; - - -% Loop through all subjects -for s=1:nsubj - fprintf('\n******\nProcessing subject %s\n******\n\n', subject_list{s}); - - % Path to the folder containing the current subject's data - data_path = [home_path subject_list{s} '/']; - - % Load original dataset - fprintf('\n\n\n**** %s: Loading dataset ****\n\n\n', subject_list{s}); - EEG = pop_loadset('filename', [subject_list{s} '_inter.set'], 'filepath', data_path); - EEG = eeg_checkset( EEG ); - EEG = pop_editeventlist( EEG , 'AlphanumericCleaning', 'on', 'BoundaryNumeric', { -99}, 'BoundaryString', { 'boundary' }, 'List', '\\data.einsteinmed.org\users\Ana and Douwe\22Q\Visual gating\scripts\eventlist.txt', 'SendEL2', 'EEG', 'UpdateEEG', 'on', 'Warning', 'off' ); - EEG = eeg_checkset( EEG ); - EEG = pop_epochbin( EEG , [-50 400], [-50 0]); - EEG = eeg_checkset( EEG ); - EEG= pop_artmwppth( EEG , 'Channel', 1:64, 'Flag', 1, 'Threshold', 120, 'Twindow', [ -50 400], 'Windowsize', 200, 'Windowstep', 200 );% to flag bad epochs - percent_deleted = (length(nonzeros(EEG.reject.rejmanual))/(length(EEG.reject.rejmanual)))*100 %looks for the length of all the epochs that should be deleted / length of all epochs * 100 - EEG = pop_rejepoch( EEG, [EEG.reject.rejmanual] ,0);%this deletes the flaged epoches - ERP = pop_averager( EEG , 'Criterion', 1, 'DSindex',1, 'ExcludeBoundary', 'on', 'SEM', 'on' ); - EEG = pop_saveset( EEG, 'filename',[subject_list{s} '_all.set'],'filepath', data_path); - ERP = pop_savemyerp(ERP, 'erpname', [subject_list{s} '_all.erp'], 'filename', [subject_list{s} '_all.erp'], 'filepath', data_path); - values = pop_rt2text(ERP, 'eventlist',1, 'filename', ['\\data.einsteinmed.org\users\Ana and Douwe\22Q\Visual gating\Data\All RT files\' subject_list{s} '_all_rt.xls'], 'header', 'on', 'listformat', 'basic' ); - ID = string(subject_list{s}); - data_subj = []; - data_subj = [ID, percent_deleted]; - participant_info = [participant_info; data_subj]; -end; -save([home_path name_paradigm '_participant_epoching_cleaing_info'], 'participant_info'); - - - diff --git a/src/G_epoching.m b/src/G_epoching.m deleted file mode 100644 index da06a48..0000000 --- a/src/G_epoching.m +++ /dev/null @@ -1,45 +0,0 @@ -clear all -eeglab - -% This defines the set of subjects -subject_list = {'12329' '2252' '2261' '2243' '12707' '2254' '12512' '2217' '2256' '2247' '2262' '10214'}; % {'2201','2202','2204','2207','2208','2212','2216','2217','2220','2221','2222','2223','2229','2231','2236','2237','2238','2243','2247','2250','2252','2254','2256','2257','2261','2262','2267','2274','2281','2284','2285','2286','2292','2295','2297','7003','7007','7019','7025','7046','7048','7049','7051','7054','7058','7059','7061','7063','7064','7073','7074','7075','7078','7089','7092','7123','7556','7808','10092','10130','10149','10172','10214','10360','10394','10446','10463','10476','10581','10585','10590','10640','10748','10780','10784','10862','10888','10915','10967','12004','12005','12006','12007','12012','12038','12139','12177','12188','12197','12203','12206','12215','12230','12272','12313','12328','12329','12413','12433','12449','12482','12512','12549','12588','12648','12666','12707','12727','12746','12750','12755','12770','12815','12852','12858','12870'};% -name_paradigm = 'Visual_Gating' % this is needed for saving the table at the end -nsubj = length(subject_list); % number of subjects -participant_info_temp = []; % needed for creating matrix at the end -% Path to the parent folder, which contains the data folders for all subjects -home_path = '\\data.einsteinmed.org\users\Ana and Douwe\22Q\Visual gating\Data\'; - - -% Loop through all subjects -for s=1:nsubj - fprintf('\n******\nProcessing subject %s\n******\n\n', subject_list{s}); - - % Path to the folder containing the current subject's data - data_path = [home_path subject_list{s} '/']; - - % Load original dataset - fprintf('\n\n\n**** %s: Loading dataset ****\n\n\n', subject_list{s}); - EEG = pop_loadset('filename', [subject_list{s} '_inter_2.set'], 'filepath', data_path); - EEG = eeg_checkset( EEG ); - EEG = pop_editeventlist( EEG , 'AlphanumericCleaning', 'on', 'BoundaryNumeric', { -99}, 'BoundaryString', { 'boundary' }, 'List', '\\data.einsteinmed.org\users\Ana and Douwe\22Q\Visual gating\scripts\events.txt', 'SendEL2', 'EEG', 'UpdateEEG', 'codelabel', 'Warning', 'off' ); - EEG = eeg_checkset( EEG ); - EEG = pop_epochbin( EEG , [-50 400], [-50 0]); - EEG = eeg_checkset( EEG ); - EEG= pop_artmwppth( EEG , 'Channel', 1:64, 'Flag', 1, 'Threshold', 120, 'Twindow', [ -50 400], 'Windowsize', 200, 'Windowstep', 200 );% to flag bad epochs - percent_deleted = (length(nonzeros(EEG.reject.rejmanual))/(length(EEG.reject.rejmanual)))*100 %looks for the length of all the epochs that should be deleted / length of all epochs * 100 - EEG = pop_rejepoch( EEG, [EEG.reject.rejmanual] ,0);%this deletes the flaged epoches - ERP = pop_averager( EEG , 'Criterion', 1, 'DSindex',1, 'ExcludeBoundary', 'on', 'SEM', 'on' ); - EEG = pop_saveset( EEG, 'filename',[subject_list{s} '_all.set'],'filepath', data_path); - ERP = pop_savemyerp(ERP, 'erpname', [subject_list{s} '_all.erp'], 'filename', [subject_list{s} '_all.erp'], 'filepath', data_path); - %values = pop_rt2text(ERP, 'eventlist',1, 'filename', ['\\data.einsteinmed.org\users\Ana and Douwe\22Q\Visual gating\Data\All RT files\' subject_list{s} '_all_rt.xls'], 'header', 'on', 'listformat', 'basic' ); - ID = string(subject_list{s}); - data_subj = []; - data_subj = [ID, percent_deleted]; - participant_info_temp = [participant_info_temp; data_subj]; -end; -colNames = {'ID','%data deleted'}; %adding names for columns -participant_info = array2table( participant_info_temp,'VariableNames',colNames); %creating table with column names -save([home_path name_paradigm '_participant_epoching_cleaing_info_extra_clean'], 'participant_info'); - - - diff --git a/src/G_individual_trials_export.m b/src/G_individual_trials_export.m new file mode 100644 index 0000000..f3e5c4a --- /dev/null +++ b/src/G_individual_trials_export.m @@ -0,0 +1,186 @@ +% Created on 8/27/2018 By Douwe Horsthuis +% Last update 6/22/2021 +% Script will take the pre-proccesed and epoched data and transfer for each trial a mean for time window of interest to a non matlab file (to be loaded in different softwares (such as R studio) +% 1)create the means of the epoched data, for a defined time window, for a selected channel +% 2)asign a number to the condition (can have up to 3 conditions) +% 3)assign a trial number to every individual mean +% 4)assign a number for what group the participants belong to (can have up to 4 group) +% 5)transfers this to an txt, dat, csv, xls, xlsm, xlsx or xlsb + +clear EEG +eeglab +close all + +group = 1; %Add here how many groups of participant you have, 4 is max +load_path = 'C:\data\'; +save_path= 'C:\results\'; +typefile= '.xlsx';% final file can be saved as mat, txt, dat, csv, xls, xlsm, xlsx or xlsb +time_window = [];%specify the begin and end points of the time window of interest in ms either a specific point for N1/MMN/P2 +name_timewindow= '';%name timewindow of intresset +chan = ''; %channel of interest +name_file = '_epoched'; %the name after the IDnumber (excluding .set) +events_in_epoch_cond1 = {}; % what bins you want see EEG.EVENTLIST.eventinfo.binlabel or EEG.EVENTLIST.eventinfo.code +events_in_epoch_cond2 = {}; % +events_in_epoch_cond3 = {}; % +%% variables and matrices that need to exist %% +prev_subjects = 0; %needs this to calculate how many subjects existed in previous groups +data_subj = []; +data_subj_small = []; +prompt1 = 'are your individual data files in a subject folder or in one main folder? (1-individual folders 2-main folder)'; +data_folders = input(prompt1); +prompt2 = 'How many conditions have you defined? (1,2 or 3)'; +n_conditions = input(prompt2); +for j=1:group %running it per group + if group > 4 + disp('you can have a maximum of 4 groups') + return + end + if j==1 %group 1 + subj = {'subjID1' 'subjID2' };% + if isempty(subj) + disp('you forgot to input subject IDs for group 1'); + return + end + elseif j==2 %group 2 + subj = {'subjID1' 'subjID2'}; + if isempty(subj) && group > 1 + disp('you forgot to input subject IDs for group 2'); + return + end + elseif j==3 + subj = {}; %group 3 + if isempty(subj) && group > 2 + disp('you forgot to input subject IDs for group 3'); + return + end + elseif j==4 + subj = {}; % group 4 + if isempty(subj) && group > 3 + disp('you forgot to input subject IDs for group 3'); + return + end + end + data_temp = []; + for subj_count = 1:length(subj) + %% loading data and separating the epochs + % Path to the folder containing the current Subject's data + if data_folders == 1 + data_path = [load_path subj{subj_count} '\']; + elseif data_folders == 2 + data_path = load_path; + end + %loading data set + EEG = pop_loadset('filename', [subj{subj_count} name_file '.set'], 'filepath', data_path , 'loadmode', 'all'); + % separating the epochs + if n_conditions == 1 + EEGcond1 = pop_selectevent( EEG, 'type',events_in_epoch_cond1,'deleteevents','on','deleteepochs','on','invertepochs','off'); + if subj_count==1 && j ==1 + pop_eegplot( EEGcond1, 1, 1, 1); + disp('press a button to continue') + pause + end + EEGcond2 = []; + EEGcond3 = []; + elseif n_conditions == 2 + disp('define epoch info for condition 1') + EEGcond1 = pop_selectevent( EEG, 'type',events_in_epoch_cond1,'deleteevents','on','deleteepochs','on','invertepochs','off'); + if subj_count==1 && j ==1 + pop_eegplot( EEGcond1, 1, 1, 1); + disp('press a button to continue') + pause + end + disp('define epoch info for condition 2') + EEGcond2 = pop_selectevent( EEG, 'type',events_in_epoch_cond2,'deleteevents','on','deleteepochs','on','invertepochs','off'); + EEGcond3 = []; + elseif n_conditions == 3 + disp('define epoch info for condition 1') + EEGcond1 = pop_selectevent( EEG, 'type',events_in_epoch_cond1,'deleteevents','on','deleteepochs','on','invertepochs','off'); + if subj_count==1 && j ==1 + pop_eegplot( EEGcond1, 1, 1, 1); + disp('press a button to continue') + pause + end + disp('define epoch info for condition 2') + EEGcond2 = pop_selectevent( EEG, 'type',events_in_epoch_cond2,'deleteevents','on','deleteepochs','on','invertepochs','off'); + disp('define epoch info for condition 3') + EEGcond3 = pop_selectevent( EEG, 'type',events_in_epoch_cond3,'deleteevents','on','deleteepochs','on','invertepochs','off'); + end + %% looking for the channel of intressed + for i= 1:length(EEG.chanlocs) + if strcmp(chan,EEG.chanlocs(i).labels) + chan= EEG.chanlocs(i).urchan; %changes the name of the chan to the index number + end + end + clear cond1_tr cond2_tr cond3_tr Trial = []; % + %% creating means for amplitude for a specific channel + % find the samples within this time window for condition 1 + samplecond1 = find( EEGcond1.times>=time_window(1) & EEGcond1.times<=time_window(2) ); + % pull out the data from this range of samples, and average over samples for condition 1 (creating the ERP) + meanscond1 = squeeze( mean( EEGcond1.data( chan, samplecond1, : ), 2 ) ); + con1 = 0; con1(1:length(meanscond1))= 1; %so we can find what samples are condition 1 + cond1_tr = (1:length(meanscond1)); %this creates an index for each trial + + %do the same condition 2, but first check if it exists + if isempty(EEGcond2)~= 1 + samplescond2 = find( EEGcond2.times>=time_window(1) & EEGcond2.times<=time_window(2) ); + meanscond2 = squeeze( mean( EEGcond2.data( chan, samplescond2, : ), 2 ) ); + cond2 = 0; cond2(1:length(meanscond2)) = 2; + cond2_tr = (1:length(meanscond2)); + else + cond2= []; cond2_tr = []; meanscond2=[]; + end + %do the same for condition 3, but first check if it exists + if isempty(EEGcond3)~= 1 + samplescond3 = find( EEGcond3.times>=time_window(1) & EEGcond3.times<=time_window(2) ); + meanscond3 = squeeze( mean( EEGcond3.data( chan, samplescond3, : ), 2 ) ); + cond3 = 0; cond3(1:length(meanscond3)) = 3; + cond3_tr = (1:length(meanscond3)) ; + else + cond3= []; cond3_tr = []; meanscond3 = []; + end + Condition= [con1, cond2, cond3]; %combining the conditions into 1 matrix + if isrow(Condition); Condition = Condition'; end + Trial = [cond1_tr, cond2_tr, cond3_tr]; %combining the trials into 1 matrix + if isrow(Trial); Trial = Trial'; end + Erp = [meanscond1; meanscond2; meanscond3]; %combining the ERPs of each condition into 1 matrix + %% Subject - calls all of them the total n of subjects not individ ID + clear subject + subject =1:length(Erp); + subject(1:length(Erp)) = subj_count; + if isrow(subject); subject = subject'; end + prev_subjects= length(subj)+prev_subjects; + %% combining + clear data_subj_small + data_subj_small = [subject, Condition, Trial, Erp]; + data_temp = [data_temp; data_subj_small]; + end + + %% group + disp(['Completing group ' num2str(group)]) + clear Group + Group(1:length(data_temp)) = j; + if isrow(Group) + Group = Group'; + end + data = [Group, data_temp]; + data_subj = [data_subj; data]; % + clear data data_temp Group +end + +Group = (data_subj(:,1)); +Subject = (data_subj(:,2)); +Trial = (data_subj(:,4)); +Condition = (data_subj(:,3)); +Erp = (data_subj(:,5)); + +T = table(Subject, Group, Condition, Trial, Erp); +%saving +if contains(typefile,'.') + filename_table = [save_path 'matlab_data_for_export_' name_timewindow typefile]; + writetable(T, filename_table); + disp(['saved matlab_data_for_export_' name_timewindow typefile ' in ' save_path]) +else + filename_table = [save_path 'matlab_data_for_export_' name_timewindow '.' typefile]; + writetable(T, filename_table); + disp(['saved matlab_data_for_export_' name_timewindow '.' typefile ' in ' save_path]) +end \ No newline at end of file diff --git a/src/G_vg_excom.m b/src/G_vg_excom.m deleted file mode 100644 index bd0fc61..0000000 --- a/src/G_vg_excom.m +++ /dev/null @@ -1,48 +0,0 @@ -%auto excom script, uses data pre-proccessed in EEGLAB that has been run -%through the runica function. selects bad components, takes in -%consideration brain data<5%. Created on 5/21/2020 by Douwe Horsthuis - -clear all -eeglab - -% This defines the set of subjects -subject_list = {}; -nsubj = length(subject_list); % number of subjects - -% Path to the parent folder, which contains the data folders for all subjects -home_path = '\\data.einsteinmed.org\users\Ana and Douwe\22Q\Visual gating\Data\'; -participant_info_temp = []; -% Loop through all subjects -for s=1:nsubj - fprintf('\n******\nProcessing subject %s\n******\n\n', subject_list{s}); - - % Path to the folder containing the current subject's data - data_path = [home_path subject_list{s} '\\']; - - % Load original dataset - fprintf('\n\n\n**** %s: Loading dataset ****\n\n\n', subject_list{s}); - EEG = pop_loadset('filename', [subject_list{s} '_ica.set'], 'filepath', data_path);%load - EEG = iclabel(EEG); %Labels all ICA components into categories - ICA_components = EEG.etc.ic_classification.ICLabel.classifications ; %creates a new matrix with ICA components - bad_components_muscle = find(ICA_components(:,2)>0.80 & ICA_components(:,1)<0.05); %if component has 80% muscle and 5% or less brain - bad_components_eye = find(ICA_components(:,3)>0.80 & ICA_components(:,1)<0.05);%if component has 80% eye and 5% or less brain - bad_components_Channel_Noise = find(ICA_components(:,6)>0.80 & ICA_components(:,1)<0.05);%if component has 80% channel noise and 5% or less brain - BC = [ bad_components_muscle; bad_components_eye; bad_components_Channel_Noise];%combining the bad components - EEG = pop_subcomp( EEG, BC, 0); %excluding the bad components - EEG = pop_saveset( EEG, 'filename',[subject_list{s} '_excom.set'],'filepath', data_path);%save - - bad_eye = length(bad_components_eye); % creating a - bad_muscle = length(bad_components_muscle); % matrix that - bad_channel = length(bad_components_Channel_Noise); % keeps all - ID = string(subject_list{s}); % the info - colNames = {'ID','N Eye Comp','N Muscle Comp','N Chan_noise'}; % of deleted - data_subj = [ID, bad_eye, bad_muscle, bad_channel]; % ICA components - bad_ICA_components_temp = [bad_ICA_components_temp; data_subj]; - bad_ICA_components = array2table( bad_ICA_components_temp,'VariableNames',colNames); - - eeglab redraw; -end - -save([home_path name_paradigm '_bad_ICA_components'], 'bad_ICA_components'); - - diff --git a/src/G_vg_interpolate.m b/src/G_vg_interpolate.m deleted file mode 100644 index 186a685..0000000 --- a/src/G_vg_interpolate.m +++ /dev/null @@ -1,52 +0,0 @@ -% this scripts interpolates using the exext.set file and the excom file. It -% creates a matrix with all the deleted channels. Created by Douwe Horsthuis on 5/7/2020 -clear all -eeglab - -% This defines the set of subjects -subject_list = {'12329' '2252' '2261' '2243' '12707' '2254' '12512' '2217' '2256' '2247' '2262' '10214'}; %'2201','2202','2204','2207','2208','2212','2216','2217','2220','2221','2222','2223','2229','2231','2236','2237','2238','2243','2247','2250','2252','2254','2256','2257','2261','2262','2267','2274','2281','2284','2285','2286','2292','2295','2297','7003','7007','7019','7025','7046','7048','7049','7051','7054','7058','7059','7061','7063','7064','7073','7074','7075','7078','7089','7092','7123','7556','7808','10092','10130','10149','10172','10214','10360','10394','10446','10463','10476','10581','10585','10590','10640','10748','10780','10784','10862','10888','10915','10967','12004','12005','12006','12007','12012','12038','12139','12177','12188','12197','12203','12206','12215','12230','12272','12313','12328','12329','12413','12433','12449','12482','12512','12549','12588','12648','12666','12707','12727','12746','12750','12755','12770','12815','12852','12858','12870'};% -name_paradigm = 'Visual_Gating' % this is needed for saving the table at the end -nsubj = length(subject_list); % number of subjects -participant_info = []; % needed for creating matrix at the end -% Path to the parent folder, which contains the data folders for all subjects -home_path = '\\data.einsteinmed.org\users\Ana and Douwe\22Q\Visual gating\Data\'; - - -% Loop through all subjects -for s=1:nsubj - fprintf('\n******\nProcessing subject %s\n******\n\n', subject_list{s}); - - % Path to the folder containing the current subject's data - data_path = [home_path subject_list{s} '']; - - % Load original dataset - fprintf('\n\n\n**** %s: Loading dataset ****\n\n\n', subject_list{s}); - EEG = pop_loadset('filename', [subject_list{s} '_exext.set'], 'filepath', data_path);%loading participant file with 64 channels - labels_all = []; - labels_all = {EEG.chanlocs.labels}.'; %stores all the labels in a new matrix - [ALLEEG EEG index] = eeg_store( ALLEEG, EEG, 1); %store specified EEG dataset(s) in the ALLEG variable - index = index +1; %creates new index (it might overwrite it otherwise, but not sure) - EEG = pop_loadset('filename', [subject_list{s} '_excom.set'], 'filepath', data_path); %loads latest pre-proc file - labels_good = []; - labels_good = {EEG.chanlocs.labels}.'; %saves all the channels that are in the excom file - disp(EEG.nbchan); %writes down how many channels are there - EEG = eeg_checkset( EEG ); - [ALLEEG EEG index] = eeg_store( ALLEEG, EEG, index); %store specified EEG dataset(s) in the ALLEG variable - EEG = pop_interp(EEG, ALLEEG(1).chanlocs, 'spherical');%interpolates the data - EEG = eeg_checkset( EEG ); - EEG = pop_saveset( EEG, 'filename', [subject_list{s} '_inter.set'], 'filepath', data_path); %saves data - disp(EEG.nbchan) %should print 64 - - %this part saves all the bad channels + ID numbers - lables_del = []; - lables_del = setdiff(labels_all,labels_good); %only stores the deleted channels - All_bad_chan = strjoin(lables_del); %puts them in one string rather than individual strings - ID = string(subject_list{s});%keeps all the IDs - data_subj = []; - data_subj = [ID, All_bad_chan]; %combines IDs and Bad channels - participant_info = [participant_info; data_subj];%combine new data with old data -end; -save([home_path name_paradigm '_participant_interpolation_info'], 'participant_info'); - - - diff --git a/src/RT_bin.m b/src/RT_bin.m deleted file mode 100644 index 431214a..0000000 --- a/src/RT_bin.m +++ /dev/null @@ -1,46 +0,0 @@ -clear all -eeglab - -% This defines the set of subjects -subject_list = {'2201','2202','2204','2207','2208','2212','2216','2217','2220','2221','2222','2223','2229','2231','2236','2237','2238','2243','2247','2250','2252','2254','2256','2257','2261','2262','2267','2274','2281','2284','2285','2286','2292','2295','2297','7003','7007','7019','7025','7046','7048','7049','7051','7054','7058','7059','7061','7063','7064','7073','7074','7075','7078','7089','7092','7123','7556','7808','10092','10130','10149','10172','10214','10360','10394','10446','10463','10476','10581','10585','10590','10640','10748','10780','10784','10862','10888','10915','10967','12004','12005','12006','12007','12012','12038','12139','12177','12188','12197','12203','12206','12215','12230','12272','12313','12328','12329','12413','12433','12449','12482','12512','12549','12588','12648','12666','12707','12727','12746','12750','12755','12770','12815','12852','12858','12870'};% -name_paradigm = 'Visual_Gating' % this is needed for saving the table at the end -nsubj = length(subject_list); % number of subjects -participant_info = []; % needed for creating matrix at the end -% Path to the parent folder, which contains the data folders for all subjects -home_path = '\\data.einsteinmed.org\users\Ana and Douwe\22Q\Visual gating\Data\'; - - -% Loop through all subjects -for s=1:nsubj - fprintf('\n******\nProcessing subject %s\n******\n\n', subject_list{s}); - - % Path to the folder containing the current subject's data - data_path = [home_path subject_list{s} '/']; - - % Load original dataset - fprintf('\n\n\n**** %s: Loading dataset ****\n\n\n', subject_list{s}); - EEG = pop_loadset('filename', [subject_list{s} '_inter.set'], 'filepath', data_path); - EEG = eeg_checkset( EEG ); - EEG = pop_selectevent( EEG, 'type',{'1' '101' '102' '103' '104' '105' '175' '254' '45'},'select','inverse','deleteevents','on','deleteepochs','on','invertepochs','off'); - EEG = pop_creabasiceventlist( EEG , 'AlphanumericCleaning', 'on', 'BoundaryNumeric', { -99 }, 'BoundaryString', { 'boundary' } ); - EEG = pop_binlister( EEG , 'BDF', '\\data.einsteinmed.org\users\Ana and Douwe\22Q\Visual gating\scripts\binlist_all_rt.txt', 'IndexEL', 1, 'SendEL2', 'EEG', 'Voutput', 'EEG' ); - EEG = pop_epochbin( EEG , [-50 2000], [-50 0]); - EEG = eeg_checkset( EEG ); - EEG = pop_saveset( EEG, 'filename', [subject_list{s} '_rt.set'], 'filepath', data_path); %saves data - indv_bins = EEG.trials - - - ID = string(subject_list{s});%keeps all the IDs - indv_bins = EEG.trials - data_subj = []; - data_subj = [ID, indv_bins]; %combines IDs and Bad channels - participant_info = [participant_info; data_subj];%combine new data with old data -end; - - -colNames = {'ID','amount of clicks after 145'}; %adding names for columns -responses = array2table( participant_info,'VariableNames',colNames); %creating table with column names -save([home_path name_paradigm 'info_if_responded'], 'responses'); %saving table - - - diff --git a/src/binlist.txt b/src/binlist.txt new file mode 100644 index 0000000..f44d08a --- /dev/null +++ b/src/binlist.txt @@ -0,0 +1,12 @@ +bin 1 +hit +{75;76}{1}.{75;76}{1:rt<"hit">} + +bin 2 +false alarm +{75;76}{1}.{85;86}{1:rt<"false_alarm">} + +bin 3 +aft false alarm +{85;86}{1}.{75;76}{1:rt<"aft_false_alarm">} + diff --git a/src/binlist_all_rt.txt b/src/binlist_all_rt.txt deleted file mode 100644 index 63e63a8..0000000 --- a/src/binlist_all_rt.txt +++ /dev/null @@ -1,8 +0,0 @@ -bin 1 -Reaction -.{145}{2} - - - - - diff --git a/src/eventlist.txt b/src/eventlist.txt deleted file mode 100644 index ef7b678..0000000 --- a/src/eventlist.txt +++ /dev/null @@ -1,3 +0,0 @@ -101 "145" 1 "145" 102 "245" 2 "245" 103 "495" 3 "495" -104 "995" 4 "995" 105 "2495" 5 "2495" -new line \ No newline at end of file diff --git a/src/events.txt b/src/events.txt deleted file mode 100644 index 00838d7..0000000 --- a/src/events.txt +++ /dev/null @@ -1,5 +0,0 @@ - 101 "145" 1 "145" - 102 "245" 2 "245" - 103 "495" 3 "495" - 104 "995" 4 "995" - 105 "2495" 5 "2495" diff --git a/src/rt_events.txt b/src/rt_events.txt deleted file mode 100644 index 610ca09..0000000 --- a/src/rt_events.txt +++ /dev/null @@ -1,2 +0,0 @@ - 145 "cross" 1 "cross" - 2 "click" 2 "click" diff --git a/src/vg_trail_to_excel_all_1.m b/src/vg_trail_to_excel_all_1.m deleted file mode 100644 index 8455f67..0000000 --- a/src/vg_trail_to_excel_all_1.m +++ /dev/null @@ -1,207 +0,0 @@ -%b995eated on 8/27/2018 By Douwe For Ana -%Sb995ipt will take -%1) the means of paradigm epoched data, in a defined time window, for a selected channel -%2)asign a number to the condition -%3)assign a trail number to every individual mean -%4)assign a number for what group the participants belong to -%5)put this in a matlab table -% use the script called trail_to_excel_2 to transfer this to an excel sheet - -close all -clear all -eeglab -group = 'TD1'; -path = '\\data.einsteinmed.org\users\Ana and Douwe\22Q\Visual gating\Data\'; - - - -switch group - case 'TD1' %TD1 = 22q controls - subj = {'10092' '10130' '10149' '10172' '10214' '10394' '10476' '10581' '10585' '10590' '10640' '10748' '10780' '10784' '10862' '10888' '10915' '12004' '12005' '12006' '12012' '12215' '12313' '12328' '12512' '12313' '12328' '12512' '12549' '12648' '12666' '12727' '12746' '12750' '12755' '12770' '12815' '12852' '12858'};% - case 'TD2' %TD2 = sz controls - subj = {'10967' '12004' '12012' '12139' '12177' '12188' '12197' '12203' '12206' '12215' '12230' '12272' '12313' '12329' '12433' '12449' '12482' '12588' '12666' '12707' '12770' '12852' '12870'}; - case '22q' - subj = {'2201' '2202' '2204' '2207' '2208' '2212' '2216' '2217' '2220' '2221' '2222' '2223' '2229' '2231' '2236' '2237' '2238' '2243' '2247' '2250' '2254' '2256' '2257' '2261' '2262' '2267' '2274' '2281' '2284' '2285' '2286' '2292' '2295' '2297'}; % - case 'SZ' - subj = {'7003' '7007' '7019' '7025' '7046' '7048' '7049' '7051' '7054' '7058' '7059' '7061' '7063' '7064' '7073' '7074' '7075' '7078' '7089' '7092' '7123' '7556' '7808'}; - -end - -data_temp = []; -for subj_count = 1:length(subj) - %% loading data and separating the epochs - % Path to the folder containing the current Subject's data - data_path = [path subj{subj_count} '/']; - %loading data set - EEG = pop_loadset('filename', [subj{subj_count} '_all.set'], 'filepath', data_path , 'loadmode', 'all'); - % separating the epochs - EEG145 = pop_selectevent( EEG, 'type',{'B1(145)'},'deleteevents','on','deleteepochs','on','invertepochs','off'); - EEG245 = pop_selectevent( EEG, 'type',{'B2(245)'},'deleteevents','on','deleteepochs','on','invertepochs','off'); - EEG495 = pop_selectevent( EEG, 'type',{'B3(495)'},'deleteevents','on','deleteepochs','on','invertepochs','off'); - EEG995 = pop_selectevent( EEG, 'type',{'B4(995)'},'deleteevents','on','deleteepochs','on','invertepochs','off'); - EEG2495 = pop_selectevent( EEG, 'type',{'B5(2495)'},'deleteevents','on','deleteepochs','on','invertepochs','off'); - %% b995eating means for amplitude for a specific channel - - %Fp1 = 1; - %AF7 = 2; - %AF3 = 3; - %F1 = 4; - %F3 = 5; - %F5 = 6; - %F7 = 7; - %FT7 = 8; - %FC5 = 9; - %FC3 = 10; - %FC1 = 11; - %C1 = 12; - %C3 = 13; - %C5 = 14; - %T7 = 15; - %TP7 = 16; - %CP5 = 17; - %CP3 = 18; - %CP1 = 19; - %P1 = 20; - %P3 = 21; - %P5 = 22; - %P7 = 23; - %P9 = 24; - %PO7 = 25; - %PO3 = 26; - %O1 = 27; - %Iz = 28; - Oz = 29; - %POz = 30; - %Pz = 31; - %CPz = 32; - %Fpz = 33; - %Fp2 = 34; - %AF8 = 35; - %AF4 = 36; - %AFz = 37; - %Fz = 38; - %F2 = 39; - %F4 = 40; - %F6 = 41; - %F8 = 42; - %FT8 = 43; - %FC6 = 44; - %FC4 = 45; - %FC2 = 46; - %FCz = 47; - %Cz = 48; - %C2 = 49; - %C4 = 50; - %C6 = 51; - %T8 = 52; - %TP8 = 53; - %CP6 = 54; - %CP4 = 55; - %CP2 = 56; - %P2 = 57; - %P4 = 58; - %P6 = 59; - %P8 = 60; - %P10 = 61; - %PO8 = 62; - %PO4 = 63; - %O2 = 64; - %specify the begin and end points of the time window of interest - time_window = [165 205]; - - % find the samples within this time window for Hit condition - samples145 = find( EEG145.times>=time_window(1) & EEG145.times<=time_window(2) ); - % pull out the data from this range of samples, and average over samples - % for 145 condition - means145 = squeeze( mean( EEG145.data( Oz, samples145, : ), 2 ) ); - %do the same for other conditions - sampels245 = find( EEG245.times>=time_window(1) & EEG245.times<=time_window(2) ); - means245 = squeeze( mean( EEG245.data( Oz, sampels245, : ), 2 ) ); - - samples495 = find( EEG495.times>=time_window(1) & EEG495.times<=time_window(2) ); - means495 = squeeze( mean( EEG495.data( Oz, samples495, : ), 2 ) ); - - samples995 = find( EEG995.times>=time_window(1) & EEG995.times<=time_window(2) ); - means995 = squeeze( mean( EEG995.data( Oz, samples995, : ), 2 ) ); - - samples2495 = find( EEG2495.times>=time_window(1) & EEG2495.times<=time_window(2) ); - means2495 = squeeze( mean( EEG2495.data( Oz, samples2495, : ), 2 ) ); - - - %% Condition - b145 = 0; b245 = 0; b495 = 0; b995 = 0; b2495 = 0; - b145(1:length(means145)) = 1; - b245(1:length(means245)) = 2; - b495(1:length(means495)) = 3; - b995(1:length(means995)) = 4; - b2495(1:length(means2495)) = 5; - Condition = [b145, b245, b495, b995, b2495]; - if isrow(Condition); Condition = Condition'; end - - %% Trial creating a counter for every trial - - - b145_tr = (1:length(means145)); - b245_tr = (1:length(means245)); - b495_tr = (1:length(means495)); - b995_tr = (1:length(means995)); - b2495_tr= (1:length(means2495)); - Trial = [b145_tr, b245_tr, b495_tr, b995_tr, b2495_tr]; % - if isrow(Trial); Trial = Trial'; end - %% ERP data -here we can combine the means of diff conditions - Erp = [means145; means245; means495; means995; means2495]; - %% Subject - calls all of them the total n of subjects not individ ID - - subject =1:length(Erp); - - if strcmp(group,'TD1') - subject(1:length(Erp)) = subj_count; - elseif strcmp(group,'22q') - %+27 to go after first group of TD1 - subject(1:length(Erp)) = subj_count+27; - elseif strcmp(group,'TD2') - %+54 to go after first 2 groups - subject(1:length(Erp)) = subj_count+54; - else - %+69 to go after first 3 groups - subject(1:length(Erp)) = subj_count+69; - end - if isrow(subject); subject = subject'; end - %% combining - - data_subj = [subject, Condition, Trial, Erp]; - data_temp = [data_temp; data_subj]; -end - -%% group - -if strcmp(group,'TD1') - Group(1:length(data_temp)) = 1; -elseif strcmp(group,'22q') - Group(1:length(data_temp)) = 2; -elseif strcmp(group,'TD2') - Group(1:length(data_temp)) = 3; -else %sz group - Group(1:length(data_temp)) = 4; -end -if isrow(Group); Group = Group'; end - -data = [Group, data_temp]; -%% saving the tables files -if strcmp(group,'TD1') - data_TD1 = data; - save('\\data.einsteinmed.org\users\Ana and Douwe\22Q\Visual gating\Data\data_TD1') -elseif strcmp(group,'22q') - data_22q = data; - save('\\data.einsteinmed.org\users\Ana and Douwe\22Q\Visual gating\Data\data_22q') -elseif strcmp(group,'TD2') - data_TD2 = data; - save('\\data.einsteinmed.org\users\Ana and Douwe\22Q\Visual gating\Data\data_TD2') -else - data_SZ = data; - save('\\data.einsteinmed.org\users\Ana and Douwe\22Q\Visual gating\Data\\data_SZ') - -end - - -