diff --git a/src/BST/bsPreprocessing.m b/src/BST/bsPreprocessing.m index ea66650..5e0cd10 100644 --- a/src/BST/bsPreprocessing.m +++ b/src/BST/bsPreprocessing.m @@ -1,21 +1,21 @@ % % --- This is the preprocessing workflow reproduced by Brainstorm functions--- % % For contact: aya.kabbara7@gmail.com -cd('../../tools/brainstorm'); +% cd('../../tools/brainstorm'); % ======= CREATE PROTOCOL ======= % The protocol name has to be a valid folder name (no spaces, no weird characters...) -ProtocolName = 'Protocol_PreProc'; +ProtocolName = 'Protocol_PreProc2'; % Start brainstorm without the GUI if ~brainstorm('status') brainstorm nogui end -% Delete existing protocol -gui_brainstorm('DeleteProtocol', ProtocolName); +% % Delete existing protocol +% gui_brainstorm('DeleteProtocol', ProtocolName); % Create new protocol gui_brainstorm('CreateProtocol', ProtocolName, 0, 0); % cd('data/Raw Data Part 1'); %Find and change working folder to raw EEG data -filenames = dir('../../data/*.dat') +filenames = dir('../../data/set/*.set') nb=500; trials_1=0; trials_2=0; @@ -30,7 +30,7 @@ disp(['Participant: ', num2str(participant)]) %Display current participant being processed participant_number = strsplit(filenames(participant).name(1:end-5),'_'); %Split filename into components - RawFile = ['/Users/ayakabbara/StageEEGpre/data/Raw Data Part 1/' filenames(participant).name]; + RawFile = ['/Users/ayakabbara/StageEEGpre/data/set/' filenames(participant).name]; SubjectName = ['participant_' participant_number{2}]; % Check if the folder contains the required files @@ -42,7 +42,7 @@ % Process: Create link to raw file sFiles = bst_process('CallProcess', 'process_import_data_raw', [], [], ... 'subjectname', SubjectName, ... - 'datafile', {RawFile,'EEG-BRAINAMP'} , ... + 'datafile', {RawFile,'EEGLAB'} , ... 'channelreplace', 0, ... 'channelalign', 0) @@ -72,10 +72,10 @@ catch end %% ==== Filtering ==== - % Process: Notch filter: 50Hz 100Hz 150Hz + % Process: Notch filter: sFiles = bst_process('CallProcess', 'process_notch', sFiles, [], ... 'sensortypes', 'EEG', ... - 'freqlist', [50, 100, 150], ... + 'freqlist', [60, 120, 180], ... 'cutoffW', 2, ... 'useold', 0, ... 'read_all', 0); @@ -99,15 +99,13 @@ 'subjectname', SubjectName, ... 'eventname', 'S110', ... 'timewindow', [], ... - 'epochtime', [-0.5, 1.3], ... - 'baseline', [-0.2, 0]); + 'epochtime', [-0.5, 1.3]); sFilesEpochs2 = bst_process('CallProcess', 'process_import_data_event', sFiles, [], ... 'subjectname', SubjectName, ... 'eventname', 'S111', ... 'timewindow', [], ... - 'epochtime', [-0.5, 1.3], ... - 'baseline', [-0.2, 0]); + 'epochtime', [-0.5, 1.3]); sFilesEpochs1 = bst_process('CallProcess', 'process_baseline', sFilesEpochs1, [],'baseline', [-0.2, 0]) sFilesEpochs2 = bst_process('CallProcess', 'process_baseline', sFilesEpochs2, [],'baseline', [-0.2, 0]) @@ -133,10 +131,8 @@ dirr=[BS_db ProtocolName '/data/' sFilesAvg(1).FileName]; FF=load(dirr); - if(size(FF,1)>32) + All_ERP_BS(1,:,:,participant) = FF.F(ChannelsTokeep(1:29),151:750); %Store all the ERP data into a single variable - else - All_ERP_BS(1,:,:,participant) = FF.F([1:9 11:20 22:31],151:750); %Store all the ERP data into a single variable end trials_1=trials_1+sFilesAvg(1).iStudy; @@ -146,11 +142,9 @@ try dirr=[BS_db ProtocolName '/data/' sFilesAvg(2).FileName]; FF=load(dirr); - if(size(FF,1)>32) + All_ERP_BS(2,:,:,participant) = FF.F(ChannelsTokeep(1:29),151:750); %Store all the ERP data into a single variable - else - All_ERP_BS(2,:,:,participant) = FF.F([1:9 11:20 22:31],151:750); %Store all the ERP data into a single variable - end + trials_2=trials_2+sFilesAvg(2).iStudy; catch diff --git a/src/BST/toset.m b/src/BST/toset.m index cd069af..1e4298e 100644 --- a/src/BST/toset.m +++ b/src/BST/toset.m @@ -11,7 +11,43 @@ participant_number = strsplit(filenames(participant).name(1:end-5),'_'); %Split filename into components participant_varname = ['set_',participant_number{2}]; %Create new file name EEG = pop_loadbv('/Raw Data Part 1/', filenames(participant).name); - %ajouter chanlocs + %add chanloc file EEG= pop_chanedit(EEG, 'lookup','/eeglab2021.1/functions/supportfiles/Standard-10-20-Cap81.ced'); - save(['/Raw Data Part 1/set/' participant_varname '.set'],'EEG'); + + EEG = pop_select(EEG, 'channel',{'Fp1' + 'Fz' + 'F3' + 'F7' + 'FC5' + 'FC1' + 'Cz' + 'C3' + 'T7' + 'CP5' + 'CP1' + 'Pz' + 'P3' + 'P7' + 'O1' + 'POz' + 'O2' + 'P4' + 'P8' + 'CP6' + 'CP2' + 'C4' + 'T8' + 'FC6' + 'FC2' + 'FCz' + 'F4' + 'F8' + 'Fp2' + 'TP10' + 'TP9'}); + end + + save(['/data/set/' participant_varname '.set'],'EEG'); + + end