Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New #19

Merged
merged 2 commits into from
Mar 1, 2022
Merged

New #19

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,27 +177,24 @@ We delete a channel if

All of these settings are the standard settings and result in clean data, without losing excessive amount of channels.

**imporant for now**
**important for now**
Even though for now we cannot exclude externals from the cleaning process, and thus we need to delete them beforehand. [The EEGLAB people have said that they are working on a fix base on my request](https://github.com/sccn/clean_rawdata/issues/28). Currently (when manually updating the function) there are still errors when excluding externals from this cleaning, but hopefully quick this will be solved. So if you need to use externals, use the old cleaning functions, this one is still in the code.



These are the variables you NEED to change:
```matlab
subject_list = {'some sort of ID' 'a different id for a different particpant'};
eeglab_location = 'C:\Users\wherever\eeglab2019_1\'; %needed if using a 10-5-cap
eeglab_location = 'C:\Users\wherever\eeglab2021.1\'; %needed if using a 10-5-cap
scripts_location = 'C:\\Scripts\'; %needed if using 160channel data
home_path = 'the main folder where you store your data';
```

These you can change if you want to change settings
```matlab
EEG = pop_resample( EEG, 256); %downsampling
EEG = pop_eegfiltnew(EEG, [],1,1690,1,[],1); % High pass filter
EEG = pop_eegfiltnew(EEG, [],45,152,0,[],1); % Low pass filter
EEG = pop_chanedit(EEG, 'lookup',[eeglab_location 'plugins\dipfit\standard_BESA\standard-10-5-cap385.elp']);
EEG = pop_select( EEG,'nochannel',{'EXG1','EXG2','EXG3','EXG4','EXG5','EXG6','EXG7','EXG8'});% To delete different channels if needed
EEG = pop_rejchan(EEG,'elec', [1:64],'threshold',5,'norm','on','measure','kurt'); %the rejection threshold (standard is 5), [1:64 or 1:160 because you don't want to include the externals]
downsample_to=256; % what is the sample rate you want to downsample to
lowpass_filter_hz=45; %45hz filter
highpass_filter_hz=1; %1hz filter
```
[Back to top](#eeg-pipeline-using-eeglab)

Expand All @@ -216,7 +213,9 @@ This shows up in Matlab. Replace the filter number with the number 1. followed b
```matlab
EEG = pop_eegfiltnew(EEG, [],0.01,168960,1,[],1); %this 0.01hz filter changes like this:
EEG = pop_eegfiltnew(EEG, [],1,1690,0,[],1); %into a 1 hz filter
```
```

**3/1/2022 update, we won't need to add filter order anymore**. It is very important to know the filter order (which is [ the width of the sliding window in data points](https://sccn.ucsd.edu/wiki/Makoto's_preprocessing_pipeline#Dependency_across_the_preprocessing_stages_.2807.2F05.2F2019_updated.29) or [see this EEGLAB information about this](https://eeglab.org/others/Firfilt_FAQ.html#q-what-is-the-difference-between-filter-length-and-filter-order))

##### What filter should I choose
Choosing what filters to use will have a big impact on your data. There are a couple things to consider because filters will have impact in several different ways on your data.
Expand Down
13 changes: 3 additions & 10 deletions src/A_merge_sets.m
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
% EEGLAB merge sets, and creates .set file
% by Douwe Horsthuis updated on 12/22/2021
% by Douwe Horsthuis updated on 6/21/2021
% ------------------------------------------------
clear variables
eeglab
%% Subject info for each script
% 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 your data';
%% info needed for this script specific
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
%% Loop through all subjects
for s = 1:length(subject_list)
clear ALLEEG
eeglab
Expand Down
29 changes: 12 additions & 17 deletions src/B_downs_filter_chaninfo_exclchan.m
Original file line number Diff line number Diff line change
@@ -1,45 +1,40 @@
% Combination of EEGLAB downsample and filter, and reject channel script by Ana on 2017-07-11
% Combined and updated by Douwe Horsthuis last updated on 2/14/2022
% Combined and updated by Douwe Horsthuis last update 11/5/2021
% ------------------------------------------------
clear variables
eeglab
%% Subject info for each script

% This defines the set of subjects
subject_list = {'some sort of ID' 'a different id for a different particpant'};
eeglab_location = 'C:\Users\wherever\eeglab2021.1\'; %needed if using a 10-5-cap
scripts_location = 'C:\\Scripts\'; %needed if using 160channel data
% Path to the parent folder, which contains the data folders for all subjects
home_path = 'the main folder where you store your data';
%% info needed for this script specific
%locations
eeglab_location = 'C:\Users\wherever\eeglab2021.1\'; %needed if using a 10-20
scripts_location = 'C:\\Scripts\'; %needed if using 160channel data
% filter info
downsample_to=256; % what is the sample rate you want to downsample to
lowpass_filter_hz=45; %45hz filter
lowpass_filter_order=152;%this is the suggested value produced by EEGlab
highpass_filter_hz=1; %1hz filter
highpass_filter_order=1690;%this is the suggested value produced by EEGlab
%% Loop through all subjects
% Loop through all subjects
for s=1:length(subject_list)
fprintf('\n******\nProcessing subject %s\n******\n\n', subject_list{s});
data_path = [home_path subject_list{s} '\\'];
% Load original dataset (created by previous script)
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 );
%getting some basic info before pre-processing (avg ampl 3x, length in sec, channels
EEG.info=table(mean(EEG.data(33,:)), mean(EEG.data(48,:)), mean(EEG.data(28,:)), EEG.xmax, {{EEG.chanlocs.labels}}, 'VariableNames',{'Avg Ampl FPz', 'Avg Ampl Cz', 'Avg Ampl Iz', 'full amount of time in sec', 'channels'},'RowNames',{'Before pre-processing'}); %creating table with column names);
EEG.subject = subject_list{s};
%downsample
EEG = pop_resample( EEG, downsample_to);
EEG = eeg_checkset( EEG );
%filtering
EEG.filter=table(lowpass_filter_hz,lowpass_filter_order,highpass_filter_hz,highpass_filter_order); %adding it to subject EEG file
EEG = pop_eegfiltnew(EEG, [],highpass_filter_hz,highpass_filter_order,1,[],1); % 1hz filter
EEG.filter=table(lowpass_filter_hz,highpass_filter_hz); %adding it to subject EEG file
EEG = pop_eegfiltnew(EEG, 'locutoff',highpass_filter_hz);
EEG = eeg_checkset( EEG );
EEG= pop_eegfiltnew(EEG, [],lowpass_filter_hz,lowpass_filter_order,0,[],1);
EEG = pop_eegfiltnew(EEG, 'hicutoff',lowpass_filter_hz);
EEG = eeg_checkset( EEG );
EEG = pop_saveset( EEG, 'filename',[subject_list{s} '_downft.set'],'filepath', data_path);
%adding channel location
if EEG.nbchan >63 && EEG.nbchan < 95 %64chan cap (can be a lot of externals, this makes sure that it includes a everything that is under 96 channels, which could be an extra ribbon)
%EEG=pop_chanedit(EEG, 'lookup',[eeglab_location 'plugins\dipfit\standard_BESA\standard-10-5-cap385.elp']); %make sure you put here the location of this file for your computer
EEG=pop_chanedit(EEG, 'lookup',[eeglab_location 'plugins\dipfit\standard_BEM\elec\standard_1020.elc']); %make sure you put here the location of this file for your computer
EEG=pop_chanedit(EEG, 'lookup',[eeglab_location 'plugins\dipfit\standard_BESA\standard-10-5-cap385.elp']); %make sure you put here the location of this file for your computer
EEG = pop_saveset( EEG, 'filename',[subject_list{s} '_info.set'],'filepath', data_path);
%deleting bad channels
%EEG = pop_rejchan(EEG,'elec', [1:64],'threshold',5,'norm','on','measure','kurt');
Expand Down
10 changes: 4 additions & 6 deletions src/D_reref_exclextrn_interp_avgref_ica_autoexcom.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@
% uses runica to do an Independent Component Analysis
% uses IClabel to define the eye component
% Deletes these and the components also get printed.
% by Douwe Horsthuis updated on 12/22/2021
% last edits done on by Douwe 11/5/2021
% ------------------------------------------------

clear variables
eeglab
%% Subject info for each script

% 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 your data';
%% info needed for this script specific
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'})
%% Loop through all subjects
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
Expand Down
10 changes: 4 additions & 6 deletions src/E_epoching.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,18 @@
% 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
%% Subject info for each script
% 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 your data';
%% info needed for this script specific
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
% Loop through all subjects
for s=1:length(subject_list)
fprintf('\n******\nProcessing subject %s\n******\n\n', subject_list{s});
clear data_subj
Expand Down
21 changes: 16 additions & 5 deletions testing/scripts/A_merge_sets.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
% Testing the scr code 6/21/2021
% EEGLAB merge sets, and creates .set file
% by Douwe Horsthuis updated on 2/22/2022
% ------------------------------------------------
subject_list = {'11' '14'}; %all the IDs for the indivual particpants
filename = 'IAPS'; % if your bdf file has a name besides the ID of the participant (e.g. oddball_paradigm)
home_path = 'C:\Users\dohorsth\Documents\GitHub\EEG_to_ERP_pipeline_stats_R\testing\data\'; %place data is (something like 'C:\data\')
blocks = 2; % the amount of BDF files. if different participant have different amounts of blocks, run those participant separate
clear variables
eeglab
%% Subject info for each script
% This defines the set of subjects
subject_list = {'12377' '12494' '12565' '12666' '12675'};
% Path to the parent folder, which contains the data folders for all subjects
home_path = 'D:\Restingstate_eyetracking\';
%% info needed for this script specific
filename = 'rest_et'; % if your bdf file has a name besides the ID of the participant (e.g. oddball_paradigm)
blocks = 3; % the amount of BDF files. if different participant have different amounts of blocks, run those participant separate
%% Loop through all subjects
for s = 1:length(subject_list)
clear ALLEEG
eeglab
Expand All @@ -23,6 +31,9 @@
%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
Loading