Skip to content

Commit

Permalink
preproc functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaneMcKeon committed Oct 28, 2024
1 parent a37995b commit d622408
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ sEEG/
choice-landscape/
0c43526d20387f01a0f149d0888f1f5d27d85850
preprocessed_data/
Signal_Complexity/
15 changes: 12 additions & 3 deletions Preprocessing_Functions/epochlean.m
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
function [revisar] = epochlean(inputfile,epoch_folder,epoch_rj_marked_folder)
function [revisar] = epochlean(inputfile,epoch_folder,epoch_rj_marked_folder,task,taskdirectory)
revisar = {};
% what file are we using

locs = file_locs(inputfile);
% locs = file_locs(inputfile,epoch_folder,task);
locs = file_locs(inputfile,taskdirectory,task);
if exist(locs.epochClean, 'file')
OUTEEG = [];
fprintf('skipping; already created %s\n', locs.epochClean);
Expand Down Expand Up @@ -34,7 +35,15 @@

%% epoching: -0.500 to 2 seconds
%extract epochs
EEG = pop_epoch( EEG, {'-5' '-3' '0' '1' '2' '3' '4' '5'}, [-0.5 2], 'newname', [currentName '_epochs'], 'epochinfo', 'yes');
if task == "MGS"
EEG = pop_epoch( EEG, {'-5' '-3' '0' '1' '2' '3' '4' '5'}, [-0.5 2], 'newname', [currentName '_epochs'], 'epochinfo', 'yes');

elseif task == "anti"

EEG = pop_epoch( EEG, {'1' '2' '3'}, [0 0.5], 'newname', [currentName '_epochs'], 'epochinfo', 'yes');


end

% %remove baseline
% EEG = pop_rmbase( EEG, [-400 0]);
Expand Down
2 changes: 1 addition & 1 deletion Preprocessing_Functions/preprocessing_pipeline.m
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
else
[ALLEEG EEG] = eeg_store(ALLEEG, EEG, CURRENTSET);

if ~any(find(cellfun (@any,regexpi (fieldnames(EEG.etc), 'clean_channel_mask'))));
if ~any(find(cellfun (@any,regexpi (fieldnames(EEG.etc), 'clean_channel_mask'))))
EEG.etc.clean_channel_mask=42;
else
end
Expand Down
1 change: 0 additions & 1 deletion Preprocessing_Functions/runICAs.m
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
% fprintf('saving %s\n', fullfile(outpath, [name '_SAS.set']))
% EEG = pop_saveset( EEG, 'filename',[name,'_SAS.set'], 'filepath', outpath); %save final preprocessed output


EEG = pop_runica(EEG, 'extended',1,'interupt','on','PCA',30);

%create file name
Expand Down
14 changes: 8 additions & 6 deletions Preprocessing_Functions/run_preprocessing_pipeline.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
% load in paths to feildtrip and eeglab
addpath(genpath('/Volumes/Hera/Projects/7TBrainMech/scripts/eeg/Shane/Preprocessing_Functions/'));
addpath(genpath('/resources/Euge/'))
addpath('/Volumes/Hera/Projects/7TBrainMech/scripts/fieldtrip-20220104/')
% run('/Volumes/Hera/Projects/7TBrainMech/scripts/eeg/Shane/resources/eeglab2022.1/eeglab.m');
run('/Volumes/Hera/Abby/Resources/eeglab_current/eeglab2024.2/eeglab.m')


% Outpath
% maindir = hera('Projects/7TBrainMech/scripts/eeg/Shane/preprocessed_data');
maindir = hera('Abby/preprocessed_data');
Expand Down Expand Up @@ -101,20 +103,20 @@
end


if task == "MGS"
if task == "MGS" || task == "anti"
%% Clean epochs to remove

epoch_path = [outpath '/AfterWhole/ICAwholeClean/'];
epoch_folder = [outpath '/AfterWhole/epoch/'];
epoch_rj_marked_folder = [outpath '/AfterWhole/epochclean/'];
path_data = [taskdirectory '/AfterWhole/ICAwholeClean/'];
epoch_path = [taskdirectory '/AfterWhole/ICAwholeClean/'];
epoch_folder = [taskdirectory '/AfterWhole/epoch/'];
epoch_rj_marked_folder = [taskdirectory '/AfterWhole/epochclean/'];

EEGfileNames = dir([path_data, '/*_icapru.set']);

revisar = {};
for currentEEG = 1:size(EEGfileNames,1)
filename = [EEGfileNames(currentEEG).name];
inputfile = [epoch_path,filename];
revisar{currentEEG} = epochlean(inputfile,epoch_folder,epoch_rj_marked_folder);
revisar{currentEEG} = epochlean(inputfile,epoch_folder,epoch_rj_marked_folder,task,taskdirectory);
end
end

Expand Down

0 comments on commit d622408

Please sign in to comment.