/*
          __
         / /_______________  ____  ___
        / __/ ___/ ___/ __ \/ __ \/ _ \
       / /_(__  ) /__/ /_/ / /_/ /  __/
       \__/____/\___/\____/ .___/\___/
                         /_/

    timer4.c
    measuring stimulus duration (priming)
*/

#include <tscope.h>

#define FIXTM   mtt(500)
#define BLANKTM mtt(500)
#define PRETM   mtt(100)
#define PRTM    2               // prime: 2 syncs
#define MTM     4               // postmask: 4 syncs
#define MAXTM   mtt(1500)

struct {
    int pt, pe;                 // prime duration and error
    int mt, me;                 // postmask
    int rt, re;                 // reaction time
    int resp;
} data;

struct {
    __int64 junk;
    __int64 t1, e1;
    __int64 t2, e2;
    __int64 t3, e3;
    __int64 t4, e4;
} tmp;

void trial()
{
    // fixation
    ts_vsync(&tmp.junk, &tmp.junk);
    ts_printf_centre(0, 0, "+");
    ts_wait(FIXTM);

    // blank screen
    ts_vsync(&tmp.junk, &tmp.junk);
    ts_clrscr();
    ts_wait(BLANKTM);

    // premask
    ts_vsync(&tmp.junk, &tmp.junk);
    ts_clrscr();
    ts_printf_centre(0, 0, "######");
    ts_wait(PRETM);

    // prime - timing mark 1
    ts_vsync(&tmp.t1, &tmp.e1);
    ts_clrscr();
    ts_printf_centre(0, 0, "prime");

    // mask - timing mark 2
    ts_vsyncs(&tmp.t2, &tmp.e2, PRTM);
    ts_clrscr();
    ts_printf_centre(0, 0, "######");
    ts_wait(MTM);

    // stimulus - timing mark 3
    ts_vsyncs(&tmp.t3, &tmp.e3, MTM);
    ts_clrscr();
    ts_printf_centre(0, 0, "target");

    // response - timing mark 4
    data.resp = ts_resp(&tmp.t4, &tmp.e4, MAXTM);
    ts_clrscr();

    // compute rt
    data.pt = ttm(tmp.t2 - tmp.t1);
    data.mt = ttm(tmp.t3 - tmp.t2);
    data.rt = ttm(tmp.t4 - tmp.t3);

    // compute errors (microseconds)
    data.pe = ttmu(tmp.e1 + tmp.e2);
    data.me = ttmu(tmp.e2 + tmp.e3);
    data.re = ttmu(tmp.e3 + tmp.e4);
}

int main()
{
    // prepare the subject
    ts_printf_centre(0, 20, "press one of the mouse buttons");
    ts_printf_centre(0, 0, "within 1500ms after the appearance");
    ts_printf_centre(0, -20, "of the stimulus");
    ts_button(XMAX - 20, -YMAX + 20);
    ts_clrscr();

    // define reponse buttons
    ts_defkey(M1);
    ts_defkey(M2);
    ts_textmode(BLACK);

    // execute trial
    trial();

    // print some results
    ts_printf_centre(0, 40, "           time error", data.pt, data.pe);
    ts_printf_centre(0, 20, "prime    : %4d %4d", data.pt, data.pe);
    ts_printf_centre(0, 0, "target   : %4d %4d", data.mt, data.me);
    ts_printf_centre(0, -20, "response : %4d %4d", data.rt, data.re);
    ts_mousepos(0, 0);

    ts_button(XMAX - 20, -YMAX + 20);
    return 0;
}

END_OF_MAIN();


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