2016-10-10 61 views
1

我已經在Psychopy中創建了一個任務,其中從一個jar中繪製了一個珠子。要繪製50個不同的珠子,每個珠子之後要求參與者進行概率評定。該任務是從excel文件中循環的,但要做50個評分需要很長的時間。我希望能夠獲得前10個珠子的評分。然後爲第二個珠子繪製一個評級,直到繪製20個珠子。然後,對於接下來的30個珠子,直到第50個珠子只需要每5個珠子繪製一個評級(我對編碼真的很陌生,對不起,這可能會提前不正確)。 我已經寫了這樣的代碼,但不幸的是它不工作? (在沒有分級圈我試圖把鍵盤響應觸發下一個事情的順序出現) -我想在循環中的不同點觸發一個響應

for row_index, row in (beads_params_pinkbluegreyratingparamters.xlsx): 
if row(0:10) and t >= 0.0 and rating.status == NOT_STARTED: 
    break 
    rating.tStart = t # underestimates by a little under one frame 
    rating.frameNStart = frameN # exact frame index 
    rating.setAutoDraw(True) 
continueRoutine &= rating.noResponse # a response ends the trial 

elif row(12:20:2) and t >= 0.0 and rating.status == NOT_STARTED: 
    break 
    rating.tStart = t # underestimates by a little under one frame 
    rating.frameNStart = frameN # exact frame index 
    rating.setAutoDraw(True) 
continueRoutine &= rating.noResponse 

elif rows.event.getkeys, row(11:19:2): 
    elif len(theseKeys) > 0: 
     break 
     key_resp_2.keys = theseKeys [-1] 
     key_resp_2.rt = key_resp_2.clock.getTime() 
    continueRoutine = False 
elif row(20:50:5) and t >= 0.0 and rating.status == NOT_STARTED: 
    break 
    rating.tStart = t # underestimates by a little under one frame 
    rating.frameNStart = frameN # exact frame index 
    rating.setAutoDraw(True) 
continueRoutine &= rating.noResponse 
     rows.event.getKeys, row[21, 22, 23, 24, 26, 27, 28, 29, 31, 32, 33, 34, 36, 37, 38 ,39, 41, 42, 43, 44, 46, 47, 48, 49]: 
     elif len(theseKeys) > 0: 
      key_resp_2.Keys = theseKeys [-1] 
      key_resp_2.rt = key_resp_2.clock.getTtime() 
     continueRoutine = False 
+0

請修復您的代碼,這裏有很多錯別字! – MisterMiyagi

回答

1

你應該只循環一次,但執行中的所有檢查那一個循環:

for row_index, rows in (beads_params_pinkbluegreyratingparamters.xlsx): 
    if (row_index < 10): 
     rows.ratingscale(0:10) 
    elif (row_index >=10 and row_index <20): 
     rows.ratingscale(12:20:2) 
     rows.key_resp_2(11:19:2) 
    elif (row_index >=20): 
     rows.ratingscale(25:50:5) 
     rows.key_resp_2[21, 22, 23, 24, 26, 27, 28, 29, 31, 32, 33, 34, 36, 37, 38, 39, 41, 42, 43, 44, 46, 47, 48, 49] 

請注意,在您的代碼中有一些語法錯誤,例如rows.key_resp_2(11:19:2)沒有意義。

+0

非常感謝你的回覆MisterMiyagi。 –

+0

嘿!我試圖改進我的語法,但我認爲我已經變得更糟。當我運行它時,它說 –

+0

if row(0:10)and t> = 0.0 and rating.status == NOT_STARTED: ^ SyntaxError:invalid syntax –

相關問題