Skip to content

Commit

Permalink
Merge pull request #5 from AyaKabbara/main
Browse files Browse the repository at this point in the history
BS code changes
  • Loading branch information
cmaumet authored Mar 15, 2023
2 parents 218002b + 4d7e9b7 commit 435a2b4
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 22 deletions.
34 changes: 14 additions & 20 deletions src/BST/bsPreprocessing.m
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
% % --- This is the preprocessing workflow reproduced by Brainstorm functions---
% % For contact: [email protected]

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;
Expand All @@ -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
Expand All @@ -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)

Expand Down Expand Up @@ -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);
Expand All @@ -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])
Expand All @@ -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;
Expand All @@ -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
Expand Down
40 changes: 38 additions & 2 deletions src/BST/toset.m
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 435a2b4

Please sign in to comment.