首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >pygame的LSL包装器

pygame的LSL包装器
EN

Stack Overflow用户
提问于 2016-08-05 18:48:43
回答 2查看 260关注 0票数 0

Python和游戏的新手。pygame有没有LSL (实验室流媒体层)的包装器?我想创建一个使用EEG信号的游戏来创建一个脑机接口应用程序。任何帮助都将深表感谢。谢谢!:)

EN

回答 2

Stack Overflow用户

发布于 2016-08-08 23:32:33

Python有一个名为pylsl的LSL模块。您应该能够将其合并到您的游戏循环中。

以下代码改编自this example

代码语言:javascript
运行
复制
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: interpolate streamed samples and update game objects accordingly. 
    # You'll probably need to keep a few samples to interpolate this data.


    #TODO: draw game
    ...
    pygame.display.flip()
票数 1
EN

Stack Overflow用户

发布于 2021-07-16 23:13:37

增加了另一种可能性:日内瓦基础校园生物技术的工程师使用LSL创建了一个图书馆,用于使用脑电图的在线范例,称为NeuroDecode。它依赖于pylsl并提供更高级别的实现。

在我的fork版本中,我放弃了(旧的)解码功能,转而支持对低级功能的改进,例如信号采集/可视化。

https://github.com/mscheltienne/NeuroDecode

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38787395

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档