Ejemplo n.º 1
0
def main():
    wdth = 1024
    hght = 768
    flds = ['Luminance']
    args = prsr.parse_args()
    flnm = open('results/' + args.flnm,'w')

    # Initializations
    hrl = HRL(wdth,hght,args.lm,coords=(0,1,0,1),flipcoords=False,dpx=True,ocal=True,rfl=flnm,rhds=flds,fs=True)

    sqrwv = lambda x: args.ctst * round((np.sin(2*np.pi*x) + 1)/2) + (0.5 - args.ctst/2)

    pwdth,phght = int(wdth*args.sz),int(hght*args.sz)
    ppos = ((wdth - pwdth)/2,(hght - phght)/2)

    sqrwv1 = np.array([ [sqrwv(x)] for x in
                       np.linspace(0,args.scyc,phght,endpoint=False) ])
    sqrwv2 = np.array([[ sqrwv(x) for x in
                        np.linspace(0,args.scyc,pwdth,endpoint=False) ]])

    ptch1 = hrl.newTexture(sqrwv1)
    ptch2 = hrl.newTexture(sqrwv2)

    slptm = int(1000.0 / args.tfrq)
    print slptm

    for i in range(args.ncyc):

        ptch1.draw(ppos,pwdth,phght)
        hrl.flip()
        hrl.rmtx['Luminance'] = hrl.readLuminance(phtm,1,0)
        hrl.writeResultLine()

        pg.time.wait(slptm)

        ptch2.draw(ppos,pwdth,phght)
        hrl.flip()
        hrl.rmtx['Luminance'] = hrl.readLuminance(phtm,1,0)
        hrl.writeResultLine()

        pg.time.wait(slptm)

        if hrl.checkEscape(): break

# Experiment is over!
    hrl.close()
Ejemplo n.º 2
0
def main():
    wdth = 1024
    hght = 768
    args = prsr.parse_args()

    # Initializations

    hrl = HRL(wdth,hght,0,dpx=True,ocal=True,fs=True)
    hrl = HRL(wdth,hght,0,coords=(0,1,0,1),flipcoords=False,dpx=True,ocal=True,fs=True)

    pwdth,phght = int(wdth*args.sz),int(hght*args.sz)
    ppos = ((wdth - pwdth)/2,(hght - phght)/2)

    wv1 = np.array([ [round((np.sin(x*np.pi*2) + 1)/2)] for x in
                       np.linspace(0,args.scyc,phght) ])

    wv2 = np.array([ [round((np.sin(x*np.pi*2 + np.pi) + 1)/2)] for x in
                       np.linspace(0,args.scyc,phght) ])

    ptch1 = hrl.newTexture(wv1)
    ptch2 = hrl.newTexture(wv2)

    slptm = int(1000.0 / args.tfrq)

    for i in range(args.ncyc):

        ptch1.draw(ppos,pwdth,phght)
        hrl.flip()

        pg.time.wait(slptm)

        ptch2.draw(ppos,pwdth,phght)
        hrl.flip()

        pg.time.wait(slptm)

        if hrl.checkEscape(): break

# Experiment is over!
    hrl.close()
Ejemplo n.º 3
0
def main():
    wdth = 1024
    hght = 768
    flds = ['Intensity','Luminance']
    args = prsr.parse_args()
    flnm = open('results/' + args.flnm,'w')

    hrl = HRL(wdth,hght,0,coords=(0,1,0,1),flipcoords=False,dpx=True,ocal=True,rfl=flnm,rhds=flds,fs=True)
    # Initializations

    ptch = hrl.newTexture(np.array([[args.lm]]))
    pwdth,phght = wdth*args.sz,hght*args.sz
    ppos = ((wdth - pwdth)/2,(hght - phght)/2)

    if args.rnd: rnd = round
    else: rnd = lambda x: x

    nitss = int(args.tmprs/args.bfrq)
    itss = [ args.bamp * rnd((1 + np.sin(2*np.pi*x)) / 2) + ((1-args.bamp)/2)
            for x in np.linspace(0,1,nitss) ]
    tsts = [ n % (nitss / args.sfrq) == 0 for n in range(nitss) ]
    cycl = zip(itss,tsts)
    slptm = int(1000.0 / args.tmprs)

    def opticalRead(its,phtm):
        print 'Current Intensity:', its
        lm = hrl.readLuminance(phtm,1,0)
        hrl.rmtx['Intensity'] = its
        hrl.rmtx['Luminance'] = lm
        hrl.writeResultLine()

    for (its,tst) in cycl * args.ncyc:

        hrl.changeBackground(its)
        ptch.draw(ppos,pwdth,phght)
        hrl.flip()

        pg.time.wait(slptm)

        if tst:
            prcs = Process(target=opticalRead,args=(its,fl,phtm))
            prcs.start()

        if hrl.checkEscape(): break

    # Experiment is over!
    hrl.close