2016-02-02 48 views
-1

使用Python/Psychopy/numpy我創建了一個包含6組不同圖像的數組。我試圖通過訪問數組的元素來顯示圖像。這是我的理解,[0] [0](我也嘗試[0,0])將訪問第1集中的第一個圖像,但我收到以下錯誤消息:無法使用python/psychopy/numpy訪問圖像數組中的元素

AttributeError:'numpy.ndarray '對象沒有屬性'畫'

這是我的代碼,任何幫助,將不勝感激。

imgList1 = glob.glob(os.path.join('C:\Users\Steve\Desktop\stim','*.png')) 

set1 = [visual.ImageStim(window, img) for img in imgList1[:5]] #group stims into smaller lists 
set2 = [visual.ImageStim(window, img) for img in imgList1[5:10]] 
set3 = [visual.ImageStim(window, img) for img in imgList1[10:17]] 
set4 = [visual.ImageStim(window, img) for img in imgList1[17:23]] 
set5 = [visual.ImageStim(window, img) for img in imgList1[23:29]] 
set6 = [visual.ImageStim(window, img) for img in imgList1[29:35]] 

array1 = numpy.array([[set1],[set2],[set3],[set4],[set5],[set6]]) 

running = True 
while running: 
    array1[0][0].draw() 
    window.flip() 
    core.wait(1) 

    window.close() 

乾杯 小號

+0

請閱讀[MCVE]的指導原則(http://stackoverflow.com/help/mcve)。我無法弄清楚它是如何工作的。 – MSeifert

+1

這裏不需要使用numpy。只要做''array1 = [set1,set2,set3,set4,set5,set6]'' –

回答

1

這僅僅是邏輯。

  • ARRAY1是numpy的陣列
  • 數組[0]實際上[SET1]
  • 數組[0] [0]是SET1 - >一個numpy的陣列

所以你需要以這種方式更改array1聲明:

array1 = numpy.array([set1,set2,set3,set4,set5,set6])