psychopy-neuroplaypro-neurolab 0.0.9__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {psychopy_neuroplaypro_neurolab-0.0.9 → psychopy_neuroplaypro_neurolab-0.1.2}/PKG-INFO +3 -3
- psychopy_neuroplaypro_neurolab-0.1.2/psychopy_neuroplaypro_neurolab/__init__.py +7 -0
- psychopy_neuroplaypro_neurolab-0.1.2/psychopy_neuroplaypro_neurolab/neuroplay.py +46 -0
- psychopy_neuroplaypro_neurolab-0.1.2/psychopy_neuroplaypro_neurolab/neuroplay_record/__init__.py +100 -0
- psychopy_neuroplaypro_neurolab-0.1.2/psychopy_neuroplaypro_neurolab/neuroplay_record/classic/neuroplay_record.png +0 -0
- psychopy_neuroplaypro_neurolab-0.1.2/psychopy_neuroplaypro_neurolab/neuroplay_record/classic/neuroplay_record@2x.png +0 -0
- psychopy_neuroplaypro_neurolab-0.1.2/psychopy_neuroplaypro_neurolab/neuroplay_record/dark/neuroplay_record.png +0 -0
- psychopy_neuroplaypro_neurolab-0.1.2/psychopy_neuroplaypro_neurolab/neuroplay_record/dark/neuroplay_record@2x.png +0 -0
- psychopy_neuroplaypro_neurolab-0.1.2/psychopy_neuroplaypro_neurolab/neuroplay_record/light/neuroplay_record.png +0 -0
- psychopy_neuroplaypro_neurolab-0.1.2/psychopy_neuroplaypro_neurolab/neuroplay_record/light/neuroplay_record@2x.png +0 -0
- {psychopy_neuroplaypro_neurolab-0.0.9 → psychopy_neuroplaypro_neurolab-0.1.2}/psychopy_neuroplaypro_neurolab.egg-info/PKG-INFO +3 -3
- psychopy_neuroplaypro_neurolab-0.1.2/psychopy_neuroplaypro_neurolab.egg-info/SOURCES.txt +18 -0
- psychopy_neuroplaypro_neurolab-0.1.2/psychopy_neuroplaypro_neurolab.egg-info/entry_points.txt +2 -0
- psychopy_neuroplaypro_neurolab-0.1.2/psychopy_neuroplaypro_neurolab.egg-info/requires.txt +1 -0
- {psychopy_neuroplaypro_neurolab-0.0.9 → psychopy_neuroplaypro_neurolab-0.1.2}/psychopy_neuroplaypro_neurolab.egg-info/top_level.txt +2 -0
- psychopy_neuroplaypro_neurolab-0.1.2/pyproject.toml +21 -0
- psychopy_neuroplaypro_neurolab-0.0.9/psychopy_neuroplaypro_neurolab/__init__.py +0 -1
- psychopy_neuroplaypro_neurolab-0.0.9/psychopy_neuroplaypro_neurolab/plugin.py +0 -8
- psychopy_neuroplaypro_neurolab-0.0.9/psychopy_neuroplaypro_neurolab.egg-info/SOURCES.txt +0 -11
- psychopy_neuroplaypro_neurolab-0.0.9/psychopy_neuroplaypro_neurolab.egg-info/entry_points.txt +0 -5
- psychopy_neuroplaypro_neurolab-0.0.9/psychopy_neuroplaypro_neurolab.egg-info/requires.txt +0 -1
- psychopy_neuroplaypro_neurolab-0.0.9/pyproject.toml +0 -23
- {psychopy_neuroplaypro_neurolab-0.0.9 → psychopy_neuroplaypro_neurolab-0.1.2}/LICENSE +0 -0
- {psychopy_neuroplaypro_neurolab-0.0.9 → psychopy_neuroplaypro_neurolab-0.1.2}/README.md +0 -0
- {psychopy_neuroplaypro_neurolab-0.0.9 → psychopy_neuroplaypro_neurolab-0.1.2}/psychopy_neuroplaypro_neurolab.egg-info/dependency_links.txt +0 -0
- {psychopy_neuroplaypro_neurolab-0.0.9 → psychopy_neuroplaypro_neurolab-0.1.2}/setup.cfg +0 -0
@@ -1,12 +1,12 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: psychopy-neuroplaypro-neurolab
|
3
|
-
Version: 0.
|
4
|
-
Summary:
|
3
|
+
Version: 0.1.2
|
4
|
+
Summary: PsychoPy plugin to support NeuroPlayPro EEG triggers.
|
5
5
|
Author-email: Enicast <enicaster@gmail.com>
|
6
6
|
Requires-Python: >=3.8
|
7
7
|
Description-Content-Type: text/markdown
|
8
8
|
License-File: LICENSE
|
9
|
-
Requires-Dist:
|
9
|
+
Requires-Dist: websocket-client
|
10
10
|
Dynamic: license-file
|
11
11
|
|
12
12
|
# PsychoPy NeuroPlay Plugin
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# neuroplay.py (в корне плагина)
|
2
|
+
|
3
|
+
__all__ = ['NeuroPlayProClient']
|
4
|
+
|
5
|
+
import websocket
|
6
|
+
import threading
|
7
|
+
import json
|
8
|
+
import time
|
9
|
+
|
10
|
+
|
11
|
+
class NeuroPlayProClient:
|
12
|
+
def __init__(self, url="ws://localhost:11234"):
|
13
|
+
self.url = url
|
14
|
+
self.ws = None
|
15
|
+
self.running = False
|
16
|
+
self.listen_thread = None
|
17
|
+
self.messages = []
|
18
|
+
|
19
|
+
def connect(self):
|
20
|
+
self.ws = websocket.create_connection(self.url)
|
21
|
+
|
22
|
+
def send_marker(self, label="TRIGGER"):
|
23
|
+
self.ws.send(json.dumps({"marker": label}))
|
24
|
+
|
25
|
+
def close(self):
|
26
|
+
if self.ws:
|
27
|
+
self.ws.close()
|
28
|
+
|
29
|
+
def listen(self):
|
30
|
+
self.running = True
|
31
|
+
|
32
|
+
def loop():
|
33
|
+
while self.running:
|
34
|
+
try:
|
35
|
+
msg = self.ws.recv()
|
36
|
+
self.messages.append(msg)
|
37
|
+
except:
|
38
|
+
self.running = False
|
39
|
+
|
40
|
+
self.listen_thread = threading.Thread(target=loop)
|
41
|
+
self.listen_thread.start()
|
42
|
+
|
43
|
+
def stop(self):
|
44
|
+
self.running = False
|
45
|
+
if self.listen_thread:
|
46
|
+
self.listen_thread.join()
|
psychopy_neuroplaypro_neurolab-0.1.2/psychopy_neuroplaypro_neurolab/neuroplay_record/__init__.py
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
NeuroplayRecordingComponent
|
4
|
+
Инициализация и управление записью NeuroPlayPro через WebSocket из PsychoPy Builder
|
5
|
+
"""
|
6
|
+
|
7
|
+
__all__ = ['NeuroplayRecordingComponent']
|
8
|
+
|
9
|
+
from pathlib import Path
|
10
|
+
from psychopy.experiment.components import BaseComponent, Param, getInitVals
|
11
|
+
|
12
|
+
WS_OBJ = 'ws_neuro'
|
13
|
+
|
14
|
+
class NeuroplayRecordingComponent(BaseComponent):
|
15
|
+
categories = ['EEG']
|
16
|
+
targets = ['PsychoPy']
|
17
|
+
iconFile = Path(__file__).parent / 'neuroplay_record.png'
|
18
|
+
tooltip = 'Start/Stop EEG recording via NeuroPlayPro'
|
19
|
+
plugin = "psychopy-neuroplaypro-neurolab"
|
20
|
+
|
21
|
+
def __init__(self, exp, parentName, name='neuroplay_rec'):
|
22
|
+
super().__init__(
|
23
|
+
exp, parentName, name=name,
|
24
|
+
startType='time (s)', startVal=0,
|
25
|
+
stopType='duration (s)', stopVal=1.0,
|
26
|
+
startEstim='', durationEstim='',
|
27
|
+
saveStartStop=False
|
28
|
+
)
|
29
|
+
|
30
|
+
self.type = 'NeuroplayRecording'
|
31
|
+
self.exp.requireImport(importName='websocket')
|
32
|
+
self.exp.requireImport(importName='json')
|
33
|
+
|
34
|
+
self.params['wsURL'] = Param("ws://localhost:1336", valType='str', inputType='editable',
|
35
|
+
hint="WebSocket адрес NeuroPlayPro")
|
36
|
+
|
37
|
+
def writeInitCode(self, buff):
|
38
|
+
inits = getInitVals(self.params, 'PsychoPy')
|
39
|
+
code = (f'{inits["name"]} = visual.BaseVisualStim(' +
|
40
|
+
'win=win, name="{}")\n'.format(inits['name']))
|
41
|
+
buff.writeIndentedLines(code)
|
42
|
+
|
43
|
+
ws_url = inits['wsURL'].val
|
44
|
+
code = f"{WS_OBJ} = websocket.create_connection(\"{ws_url}\")"
|
45
|
+
buff.writeIndentedLines(code)
|
46
|
+
|
47
|
+
def writeRoutineStartCode(self, buff):
|
48
|
+
inits = getInitVals(self.params, 'PsychoPy')
|
49
|
+
buff.writeIndentedLines("# === Start EEG Recording ===")
|
50
|
+
buff.writeIndentedLines("try:")
|
51
|
+
buff.setIndentLevel(1, relative=True)
|
52
|
+
|
53
|
+
buff.writeIndentedLines('start_record_cmd = json.dumps({"command": "startRecord"})')
|
54
|
+
buff.writeIndentedLines(f"{WS_OBJ}.send(start_record_cmd)")
|
55
|
+
buff.writeIndentedLines(f"response = {WS_OBJ}.recv()")
|
56
|
+
buff.writeIndentedLines("print(f'Response from NeuroPlay: {response}')")
|
57
|
+
|
58
|
+
buff.setIndentLevel(-1, relative=True)
|
59
|
+
buff.writeIndentedLines("except Exception as e:")
|
60
|
+
buff.setIndentLevel(1, relative=True)
|
61
|
+
buff.writeIndentedLines('print(f"Ошибка при старте записи NeuroPlay: {e}")')
|
62
|
+
buff.setIndentLevel(-1, relative=True)
|
63
|
+
|
64
|
+
def writeRoutineEndCode(self, buff):
|
65
|
+
buff.writeIndentedLines("# === Stop EEG Recording ===")
|
66
|
+
buff.writeIndentedLines('print("Stopping NeuroPlay...")')
|
67
|
+
buff.writeIndentedLines("try:")
|
68
|
+
buff.setIndentLevel(1, relative=True)
|
69
|
+
buff.writeIndentedLines('stop_record_cmd = json.dumps({"command": "stopRecord"})')
|
70
|
+
buff.writeIndentedLines(f"{WS_OBJ}.send(stop_record_cmd)")
|
71
|
+
buff.writeIndentedLines(f"response = {WS_OBJ}.recv()")
|
72
|
+
buff.writeIndentedLines("print(f'Response from NeuroPlay: {response}')")
|
73
|
+
buff.setIndentLevel(-1, relative=True)
|
74
|
+
buff.writeIndentedLines("except Exception as e:")
|
75
|
+
buff.setIndentLevel(1, relative=True)
|
76
|
+
buff.writeIndentedLines('print(f"Ошибка при остановке записи NeuroPlay: {e}")')
|
77
|
+
buff.setIndentLevel(-1, relative=True)
|
78
|
+
|
79
|
+
def writeExperimentEndCode(self, buff):
|
80
|
+
buff.writeIndentedLines("# === Close WebSocket connection ===")
|
81
|
+
buff.writeIndentedLines("try:")
|
82
|
+
buff.setIndentLevel(1, relative=True)
|
83
|
+
buff.writeIndentedLines(f"{WS_OBJ}.close()")
|
84
|
+
buff.setIndentLevel(-1, relative=True)
|
85
|
+
buff.writeIndentedLines("except Exception as e:")
|
86
|
+
buff.setIndentLevel(1, relative=True)
|
87
|
+
buff.writeIndentedLines("print(f'Ошибка при закрытии WebSocket: {e}')")
|
88
|
+
buff.setIndentLevel(-1, relative=True)
|
89
|
+
|
90
|
+
def writeFrameCode(self, buff):
|
91
|
+
pass
|
92
|
+
|
93
|
+
def writeFrameCodeJS(self, buff):
|
94
|
+
pass
|
95
|
+
|
96
|
+
def writeExperimentEndCodeJS(self, buff):
|
97
|
+
pass
|
98
|
+
|
99
|
+
def writeInitCodeJS(self, buff):
|
100
|
+
pass
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,12 +1,12 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: psychopy-neuroplaypro-neurolab
|
3
|
-
Version: 0.
|
4
|
-
Summary:
|
3
|
+
Version: 0.1.2
|
4
|
+
Summary: PsychoPy plugin to support NeuroPlayPro EEG triggers.
|
5
5
|
Author-email: Enicast <enicaster@gmail.com>
|
6
6
|
Requires-Python: >=3.8
|
7
7
|
Description-Content-Type: text/markdown
|
8
8
|
License-File: LICENSE
|
9
|
-
Requires-Dist:
|
9
|
+
Requires-Dist: websocket-client
|
10
10
|
Dynamic: license-file
|
11
11
|
|
12
12
|
# PsychoPy NeuroPlay Plugin
|
@@ -0,0 +1,18 @@
|
|
1
|
+
LICENSE
|
2
|
+
README.md
|
3
|
+
pyproject.toml
|
4
|
+
psychopy_neuroplaypro_neurolab/__init__.py
|
5
|
+
psychopy_neuroplaypro_neurolab/neuroplay.py
|
6
|
+
psychopy_neuroplaypro_neurolab.egg-info/PKG-INFO
|
7
|
+
psychopy_neuroplaypro_neurolab.egg-info/SOURCES.txt
|
8
|
+
psychopy_neuroplaypro_neurolab.egg-info/dependency_links.txt
|
9
|
+
psychopy_neuroplaypro_neurolab.egg-info/entry_points.txt
|
10
|
+
psychopy_neuroplaypro_neurolab.egg-info/requires.txt
|
11
|
+
psychopy_neuroplaypro_neurolab.egg-info/top_level.txt
|
12
|
+
psychopy_neuroplaypro_neurolab/neuroplay_record/__init__.py
|
13
|
+
psychopy_neuroplaypro_neurolab/neuroplay_record/classic/neuroplay_record.png
|
14
|
+
psychopy_neuroplaypro_neurolab/neuroplay_record/classic/neuroplay_record@2x.png
|
15
|
+
psychopy_neuroplaypro_neurolab/neuroplay_record/dark/neuroplay_record.png
|
16
|
+
psychopy_neuroplaypro_neurolab/neuroplay_record/dark/neuroplay_record@2x.png
|
17
|
+
psychopy_neuroplaypro_neurolab/neuroplay_record/light/neuroplay_record.png
|
18
|
+
psychopy_neuroplaypro_neurolab/neuroplay_record/light/neuroplay_record@2x.png
|
@@ -0,0 +1 @@
|
|
1
|
+
websocket-client
|
@@ -0,0 +1,21 @@
|
|
1
|
+
[build-system]
|
2
|
+
requires = ["setuptools>=40.8.0", "wheel"]
|
3
|
+
build-backend = "setuptools.build_meta"
|
4
|
+
|
5
|
+
[project]
|
6
|
+
name = "psychopy-neuroplaypro-neurolab"
|
7
|
+
version = "0.1.2"
|
8
|
+
description = "PsychoPy plugin to support NeuroPlayPro EEG triggers."
|
9
|
+
requires-python = ">=3.8"
|
10
|
+
authors = [{ name = "Enicast", email = "enicaster@gmail.com" }]
|
11
|
+
readme = "README.md"
|
12
|
+
dependencies = ["websocket-client"]
|
13
|
+
|
14
|
+
[project.entry-points."psychopy.experiment.components"]
|
15
|
+
NeuroplayRecordingComponent = "psychopy_neuroplaypro_neurolab:NeuroplayRecordingComponent"
|
16
|
+
|
17
|
+
[tool.setuptools.packages.find]
|
18
|
+
where = [""]
|
19
|
+
|
20
|
+
[tool.setuptools.package-data]
|
21
|
+
"*" = ["*.png"]
|
@@ -1 +0,0 @@
|
|
1
|
-
# Инициализация пакета — можно оставить пустым
|
@@ -1,8 +0,0 @@
|
|
1
|
-
from psychopy.plugins import Plugin
|
2
|
-
from psychopy.experiment.components import registerComponent
|
3
|
-
from psychopy_neuroplaypro_neurolab.components.neuroplay import NeuroPlayComponent
|
4
|
-
|
5
|
-
class NeuroPlayPlugin(Plugin):
|
6
|
-
def onLoad(self):
|
7
|
-
registerComponent("NeuroPlay", NeuroPlayComponent)
|
8
|
-
print("✅ NeuroPlay component registered")
|
@@ -1,11 +0,0 @@
|
|
1
|
-
LICENSE
|
2
|
-
README.md
|
3
|
-
pyproject.toml
|
4
|
-
psychopy_neuroplaypro_neurolab/__init__.py
|
5
|
-
psychopy_neuroplaypro_neurolab/plugin.py
|
6
|
-
psychopy_neuroplaypro_neurolab.egg-info/PKG-INFO
|
7
|
-
psychopy_neuroplaypro_neurolab.egg-info/SOURCES.txt
|
8
|
-
psychopy_neuroplaypro_neurolab.egg-info/dependency_links.txt
|
9
|
-
psychopy_neuroplaypro_neurolab.egg-info/entry_points.txt
|
10
|
-
psychopy_neuroplaypro_neurolab.egg-info/requires.txt
|
11
|
-
psychopy_neuroplaypro_neurolab.egg-info/top_level.txt
|
@@ -1 +0,0 @@
|
|
1
|
-
psychopy
|
@@ -1,23 +0,0 @@
|
|
1
|
-
[build-system]
|
2
|
-
requires = ["setuptools", "wheel"]
|
3
|
-
build-backend = "setuptools.build_meta"
|
4
|
-
|
5
|
-
[project]
|
6
|
-
name = "psychopy-neuroplaypro-neurolab"
|
7
|
-
version = "0.0.9"
|
8
|
-
description = "Plugin for integrating NeuroPlayPro EEG recording in PsychoPy Builder."
|
9
|
-
authors = [
|
10
|
-
{name = "Enicast", email = "enicaster@gmail.com"}
|
11
|
-
]
|
12
|
-
dependencies = ["psychopy"]
|
13
|
-
requires-python = ">=3.8"
|
14
|
-
readme = "README.md"
|
15
|
-
|
16
|
-
[project.entry-points."psychopy.plugins"]
|
17
|
-
neuroplay = "psychopy_neuroplaypro_neurolab.plugin:NeuroPlayPlugin"
|
18
|
-
|
19
|
-
[project.entry-points."psychopy.experiment.components"]
|
20
|
-
neuroplay = "psychopy_neuroplaypro_neurolab.components.neuroplay.neuroplay:NeuroPlayComponent"
|
21
|
-
|
22
|
-
[tool.setuptools]
|
23
|
-
packages = ["psychopy_neuroplaypro_neurolab"]
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|