% ajout des event stim avec création du fichier txt d'arguments

clear all
close all
clc

%--------------------------------------------------------------------------------------
%Emplacement "Racine" des répertoires du Matériel

DirRootExe = 'G:\ExperimentSynchroEeg'; %% path for AddEventStim.exe
Session='EFED2';
ListeSujet = {'s01'; 's02'; 's03';'s04'; 's05';'s06';'s07';'s08';'s09';'s10';'s11';'s12';'s14'};%{'s01_sacc';'s02_sacc';'s03_sacc';'s04_sacc';'s05_sacc';'s06_sacc';'s07_sacc';'s08_sacc';'s09_sacc';'s10_sacc'};
% Task = {'exp','cat','rec','org'};
% Sujet = {'s28','s30','s33','s39','s40'};
%ListeTache = {'exp'};

TypeEventStim = 'fix';
referenceTrigger = '30';


    for s = 1: length(ListeSujet)
        NomSujet            = char(ListeSujet(s));
       
        disp(['---------------------- ' NomSujet ' ------------------------']);
      DirDataMat =['G:\ExperimentSynchroEeg\' Session '\data\' NomSujet ];
               
        % ouverture
        fileID = fopen([DirDataMat '\eventstim_' TypeEventStim '\' NomSujet '__addEventStim_' TypeEventStim '.txt'],'w');
   
        outputFullPath = [DirDataMat '\eventstim_' TypeEventStim];
        %eegRejectFileFullPath = [DirDataMat '\clean\synchro_ICA_clean_' NomSujet '.dat'];
        eegRejectFileFullPath = [DirDataMat '\clean\synchro_' NomSujet '_' Session '.asc_clean.dat'];
        cleanFileFullPath = [DirDataMat '\clean\clean.txt'];
        eventStimFileFullPath = [DirDataMat '\eventstim_' TypeEventStim '\synchro_' Session '_' NomSujet '_' TypeEventStim '.txt'];
        synchroFileFullPath = [DirDataMat '\raw\synchro_' NomSujet '_' Session '.asc.eeg'];
        
        fprintf(fileID,'outputFullPath = %s \neegRejectFileFullPath = %s \ncleanFileFullPath = %s \neventStimFileFullPath = %s \nsynchroFileFullPath = %s \nreferenceTrigger = %s \n' ...
            ,outputFullPath,eegRejectFileFullPath,cleanFileFullPath,eventStimFileFullPath,synchroFileFullPath,referenceTrigger);
        fclose(fileID);
        
        eval(['system (''' DirRootExe '\AddEventStim.exe ' DirDataMat '\eventstim_' TypeEventStim '\' NomSujet '__addEventStim_' TypeEventStim '.txt'' ); ']);
    end

