function SekulerExp2(InputDataStruct)

% M-script to realize an experiment based on crossmodal perception
% The experiment first performed by Sekuler, Sekuler, and Lau (1997)
% Author: Borgo, Soranzo, Grassi 2009
% EXPERIMENT`S SETTINGS
% get input data from the structure passed through the interface

nsub = InputDataStruct.nsub;
subname = InputDataStruct.subname;
subsex = InputDataStruct.subsex;
subage = InputDataStruct.subage;
nblock = InputDataStruct.nblock;
subnote = InputDataStruct.subnote;
isfixed = InputDataStruct.isfixed;
filename = InputDataStruct.filename;

% set the experiment details
conditions = [1, 1; 1, 2; 2, 1; 2, 2];
repetitions = 10;
if nsub == 0
    repetitions = 1;
end

% set the keys we use in the experiment
bKey = KbName('b');
sKey = KbName('s');
EventTable = GenerateEventTable(conditions, repetitions, isfixed);
TotalNumberOfTrials = length(EventTable(:, 1));
response = zeros(TotalNumberOfTrials, 1);

% opening operations for the screen function
try
    whichscreen = max(Screen('Screens'));
    [w, rect] =Screen('Openwindow', whichscreen, 0);
    refreshrate = Screen('FrameRate', w);
    % interrogate the OS about the maximal priority
    priorityLevel = MaxPriority(w);
    InitializePsychSound;
    pahandle = PsychPortAudio('Open', [], [], 0, 44100, 1);
    HideCursor;
    for trial = 1:TotalNumberOfTrials
        % STIMULI (SELECTION)
        VideoStimulusToPlay = EventTable(trial, 2);
        SoundStimulusToPlay = EventTable(trial, 3);
        % STIMULI (CREATION)
        % STIMULI (PRESENTATION)
        % set the priority at maximum level
        Priority(priorityLevel);
        SoundToPlay = GenerateSound(SoundStimulusToPlay, w);
        PsychPortAudio('FillBuffer', pahandle, SoundToPlay);
        PsychPortAudio('Start', pahandle);
        MakeVideoStimulus
        % set the priority back to minimum level
        Priority(0);
        % COLLECT SUBJECT?S ANSWER
        [secs, keyCode] = KbWait;
        while keyCode(bKey)==0 && keyCode(sKey)==0
            [secs, keyCode] = KbWait;
        end
        if keyCode(bKey) == 1
            pbounce = 1;
        else
            pbounce = 0;
        end
        response(trial) = pbounce;
    end
    % closing operation
    Screen('CloseAll'); % close all
    PsychPortAudio('Close', pahandle);
    ShowCursor;
    % STORE RESULTS
    results = [EventTable, response];
    % WRITE THE DATA FILE
    if nsub>0
        if ~exist(filename,'file');
            fid = fopen(filename,'a');
            fprintf(fid, 'name\tsex\tnote\tnsub\tsubage\tblock\ttrial\tmotioncond\tsoundcond\tpbounce\n');
        else
            fid = fopen(filename,'a');
        end
        [row,col]=size(results);
        for i=1:row
            fprintf(fid, '%s\t%s\t%s\t%2.0f\t%2.0f\t%2.0f\t', subname, subsex, subnote, nsub, subage, nblock);
            for j=1:col
                fprintf(fid,'%2.4f\t',results(i,j));
            end
            fprintf(fid,'\n');
        end
        fclose(fid);
    end
catch
    Screen( 'Close',w)
    rethrow(lasterror)
end