2016-08-05 3 views
0

Новичок для Python и игр. Существует ли оболочка LSL (лабораторный потоковый слой) для pygame? Я хочу создать игру с использованием сигналов ЭЭГ для создания приложения для компьютерного интерфейса мозга. Любая помощь будет глубоко оценена. благодаря! :)LSL Wrapper for pygame

ответ

0

Существует модуль LSL для Python, называемый pylsl. Вы должны включить это в свой игровой цикл.

Следующий код был адаптирован из this example:

from pylsl import StreamInlet, resolve_stream 
import pygame 

# first resolve an EEG stream on the lab network 
streams = resolve_stream('type', 'EEG') 

# create a new inlet to read from the stream 
inlet = StreamInlet(streams[0]) 


# Pygame setup 
pygame.init() 
size = width, height = 320, 240 

screen = pygame.display.set_mode(size) 

samples = [] 
while True: 
    # get a new sample (you can also omit the timestamp part if you're not 
    # interested in it) 

    # Get a sample from the inlet stream 
    sample, timestamp = inlet.pull_sample() 
    samples.push(sample) 

    #TODO: interperate stream and update game objects accordingly. 
    # You'll probably need to keep a few samples to interpret this data. 


    #TODO: draw game 
    ... 
    pygame.display.flip() 
+0

Совершенные спасибо :) –