/*
    File:               ss_trial.c
    Author:             michael stevens
    Experiment:         Stroop vs Simon experiment
                        Simon & Berbaum 1990

        time course trial

            Fixation:   500ms           (circle)
            Blank:      500ms
            Stimulus:   100/400ms       color word left or right
            Maxrt:      5000ms          
            Iti:        2000ms
*/

// include functions from ss_data.c
#define SS_TRIAL_C
#include "ss_data.c"

// trial timing interval
#define FIXTM   mtt(500)
#define BLTM    mtt(500)
#define STM_SHORT   mtt(100)
#define STM_LONG    mtt(400)
#define MAXRT   mtt(5000)
#define FBTM    mtt(500)
#define ITI     mtt(2000)

// temporary data for response timing
struct {
    __int64 junk;
    __int64 t1, e1;
    __int64 t2, e2;
} rttmp;

// trial definition
void trial(int i)
{
// determine the parameters of the trial
    // stimulus duration
    __int64 stm;
    if (data[i].stimdur == SHORTD)
        stm = STM_SHORT;
    else
        stm = STM_LONG;

    // stimulus position
    int spos;
    if (data[i].stimpos == LEFT)
        spos = -ax(.5);
    else
        spos = ax(.5);

    // stimulus color
    int scol;
    if (data[i].cword == CRED)
        scol = RED;
    else
        scol = GREEN;

    // stimulus word
    char stim[20];
    if (data[i].mword == CRED)
        sprintf(stim, "RED");
    else
        sprintf(stim, "GREEN");

// present all fiels of the trial
    int oldcol, oldfill;

    // fixation
    oldcol = ts_fgcolor(WHITE);
    ts_vsync(&rttmp.junk, &rttmp.junk);
    oldfill = ts_fill(ON);
    ts_circle(0, 0, 3);
    ts_wait(FIXTM);

    // blank
    ts_vsync(&rttmp.junk, &rttmp.junk);
    ts_clrscr();
    ts_wait(BLTM);

    // stimulus
    ts_fgcolor(scol);
    ts_vsync(&rttmp.t1, &rttmp.e1);
    ts_printf_centre(spos, 0, stim);

    // remove stimulus after 100/400ms
    data[i].r = ts_resp(&rttmp.t2, &rttmp.e2, stm);
    ts_clrscr();

    // wait until response
    if (!data[i].r)
        data[i].r = ts_resp(&rttmp.t2, &rttmp.e2, MAXRT - stm);

    // compute rt and timing error
    data[i].rt = ttm(rttmp.t2 - rttmp.t1);
    data[i].re = ttm(rttmp.e2 + rttmp.e1);

    // abort on escape key
    if (data[i].r == 3) {
        writedata();
        ts_fatal("aborted by user");
    }
    // test whether response was correct
    if (data[i].r == data[i].xr)
        data[i].corr = C;
    else
        data[i].corr = E;

    // give some feedback
    if (data[i].corr == E) {
        ts_fgcolor(WHITE);
        ts_printf_centre(0, 0, "Wrong response!");
        ts_wait(FBTM);
        ts_clrscr();
    }
    // intertrial interval
    ts_wait(ITI);

    // reset graphics parameters
    ts_fgcolor(oldcol);
    ts_fill(oldfill);
}

// test-function that runs all trials
#ifndef SS_EXP_C
int main()
{
    // prepare data
    randomize(0, 0);

    // activate response buttons
    ts_defkey(M1);
    ts_defkey(M2);
    ts_defkey(KEY_ESC);

    // run the trials
    int i;
    for (i = 0; i < NTRIALS; i++)
        trial(i);

    // write the data
    writedata();
    return 0;
}

END_OF_MAIN();
#endif                          // SS_EXP_C


top
Persoonlijke pagina Universiteit GentTscope
Allegro | Cygwin | Gcc
© See license.html for copyright information