2016-07-20 23 views
0

正如你們中的一些人可能知道的那樣,psychopy在新版本中播放聲音文件時出現錯誤,所以我現在安裝了最舊的版本,並且正在嘗試製作音頻糾正反饋行爲測試意味着在fMRI掃描儀中。需要反饋以保持參與者清醒。我很難找到正確的代碼,因爲我沒有嘗試過(我得到了很多錯誤,主要是無效的語法),因爲我沒有使用構建器。我在編碼方面很新穎。這是我到目前爲止:關於psychopy的音頻糾正反饋(支持聲音的舊版本)

cue = visual.TextStim(myWin, pos = [0.0,0.0],color = -1) 
fix = visual.TextStim(myWin,text = '+',height = 1.0,color = -1) 
begin_text = ('Press the space bar to begin') 
hit_sound = sound.Sound(value='G', secs=0.5, octave=4, sampleRate=44100, bits=16) 
miss_sound = sound.Sound(value='G', secs=0.5, octave=3, sampleRate=44100, bits=16) 
cue_type = ['either_color', 'either_shape', 'either_nochange', 'either_nochange', 'color', 'color_nochange', 'shape', 'shape_nochange']#trial types 
cue_type*=num_trials #number of trials 
random.shuffle(cue_type) #randomizing trials 
if key_resp.corr 
feedback= hit_sound.play 
else: 
feedback= miss_sound.play 

在此先感謝您。

回答

1

你是從頭編碼還是從編譯器轉到編碼器視圖和編輯?如果您在編碼器視圖中進行編輯,請確保縮進和標點保持不變。

從你分享的內容,我可以看到

if key_resp.corr 
    feedback= hit_sound.play 
    else: 
    feedback= miss_sound.play 

應該是:

if key_resp.corr: 
     hit_sound.play() 
    else: 
     miss_sound.play() 
+1

感謝@邁克爾MacAskill。 – pyne

+0

謝謝!明天我回去工作時我會嘗試。我們從頭編碼它。 – boxcar44