2017-08-16 101 views
1

我試圖顯示一組在大約25秒的過程中動態變化的數字,同時顯示視覺刺激作爲對象反饋的反饋。但是,看起來該腳本無法一次執行兩個任務。任何人都可以爲此想到任何形式的工作嗎?任何幫助非常感謝。我對python/psychopy很陌生,所以如果代碼有點混亂,我很抱歉。任何方式來爲連續的幀同時繪製單獨的動態刺激? (psychopy)

這裏是我當前的代碼:

開始例行

if not countdownStartedIndie: 
    countdownClock = core.CountdownTimer(26) 
    countdownStartedIndie = True 

if not countupto: 
    timer = core.Clock() 
    avgtaps = 0 
    countupto = True 

每一幀

timeRemaining = countdownClock.getTime() 
ValueWin = visual.TextStim(win, text='+', font='', pos=(-0.5, -0.5), depth=0, rgb=None, color=('limegreen'), colorSpace='rgb', opacity=1, contrast=1.0, units='', ori=0.0, height=0.3, antialias=True, bold=False, italic=False, alignHoriz='center', alignVert='center', fontFiles=(), wrapWidth=None, flipHoriz=False, flipVert=False, name=None, autoLog=None) 

timetogo = timer.getTime()

if timetogo >= 25: 
    countupto = False 
else: 
    minutes2 = int(timetogo/60) 
    seconds2 = int(timetogo -(minutes2*60)) 

if timeRemaining <= 0.0: 
    s4.finished = True 
    continueRoutine = False 
    countdownStartedIndie = False 
else: 
    minutes = int(timeRemaining/60) # the integer number of minutes 
    seconds = int(timeRemaining -(minutes*60)) 
    timeText = str(minutes)+ ':' + str(seconds) #create a string of characters representing time 

if s4keys.corr: 
    ValueWin.draw #visual player feedback 

jitter = [10,11,12,13][randint(0,3)] 
groupcount = 'x' + str(jitter) 
for frameN in range (48): 
    s4count.draw() #a text stim using the 'groupcount' variable 
    win.flip() 
+0

嗨@aubrey歡迎來到StackOverflow。請準確地描述*您想要顯示的內容,以及*確切地說*顯示腳本不能同時執行兩個任務。 –

回答

0

我可以提供一個更通用的例子,您可以根據自己的情況適應。希望通過將其切割到骨頭上,總體原則更容易理解。

# Set up modules and stimuli 
from psychopy import visual, event 
win = visual.Window() 
stim = visual.TextStim(win, text='I\'m a stimulus!') 
feedback = visual.TextStim(win, text='') 

for frame in range(5*60): # Run for 5 seconds on a 60 Hz monitor 
    # Change stimulus dynamically 
    stim.pos += (0.001, 0.002) # Change position 
    stim.color -= 0.005 # Make darker 

    # Feedback based on response 
    key = event.getKeys() 
    if key: 
     feedback.text = 'Last key was %s' %key[0] 

    # Show it 
    stim.draw() 
    feedback.draw() 
    win.flip() 

當然,你可以有更多的刺激,做更詳細的反饋,改變更多的功能,等等。在你的情況,你可能會改變刺激文本,而不是位置和顏色。