Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pyLSL Streams Visualization
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SIMS
LSL Modules
pyLSL Streams Visualization
Commits
bb34643c
Commit
bb34643c
authored
Jan 30, 2020
by
Marios Fanourakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added functionality of updating inlets
parent
77986e3f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
38 deletions
+71
-38
visualize_streams.py
visualize_streams.py
+71
-38
No files found.
visualize_streams.py
View file @
bb34643c
...
...
@@ -145,8 +145,10 @@ class MainWindow(QtWidgets.QMainWindow):
self
.
plots
=
pg
.
GraphicsLayoutWidget
()
self
.
checkTable
=
pg
.
CheckTable
([
''
])
self
.
updateButton
=
QtGui
.
QPushButton
(
'update inlets'
)
self
.
layout
.
addWidget
(
self
.
checkTable
,
0
,
0
)
self
.
layout
.
addWidget
(
self
.
updateButton
,
1
,
0
)
self
.
layout
.
addWidget
(
self
.
plots
,
0
,
1
)
self
.
setCentralWidget
(
self
.
mainWidget
)
...
...
@@ -161,51 +163,50 @@ def main():
plts
:
List
[
pg
.
PlotItem
]
=
[
win
.
plots
.
addPlot
()]
plts
[
-
1
].
setLabel
(
'top'
,
text
=
'All Inlets Marker Data'
)
# firstly resolve all streams that could be shown
inlets
:
List
[
Inlet
]
=
[]
print
(
"looking for streams"
)
streams
=
pylsl
.
resolve_streams
()
def
on_check_change
(
row
,
col
,
state
):
print
(
"check changed: "
+
row
+
" "
+
str
(
state
))
inlet_ix
=
0
for
inlet
in
inlets
:
if
inlet
.
name
==
row
:
if
state
>
0
:
inlet
.
set_enabled
(
True
)
else
:
inlet
.
set_enabled
(
False
)
remove_plots_of_inlet
(
inlet
)
inlet_ix
+=
1
def
remove_plots_of_inlet
(
inlet
):
for
plt_ix
in
inlet
.
plt_ixs
:
win
.
plots
.
removeItem
(
plts
[
plt_ix
])
inlet
.
plt_ixs
=
[]
win
.
checkTable
.
sigStateChanged
.
connect
(
on_check_change
)
# iterate over found streams, creating specialized inlet objects that will
# handle plotting the data
for
info
in
streams
:
if
info
.
type
()
==
'Markers'
:
if
info
.
nominal_srate
()
!=
pylsl
.
IRREGULAR_RATE
\
or
info
.
channel_format
()
!=
pylsl
.
cf_string
:
print
(
'Invalid marker stream '
+
info
.
name
())
print
(
'Adding marker inlet: '
+
info
.
name
())
inlets
.
append
(
MarkerInlet
(
info
))
# give unique name to inlet and add to checkbox table
inlets
[
-
1
].
name
=
str
(
len
(
inlets
)
-
1
)
+
' '
+
inlets
[
-
1
].
name
win
.
checkTable
.
addRow
(
inlets
[
-
1
].
name
)
elif
info
.
nominal_srate
()
!=
pylsl
.
IRREGULAR_RATE
\
and
info
.
channel_format
()
!=
pylsl
.
cf_string
:
print
(
'Adding data inlet: '
+
info
.
name
())
inlets
.
append
(
DataInlet
(
info
))
# give unique name to inlet and add to checkbox table
inlets
[
-
1
].
name
=
str
(
len
(
inlets
)
-
1
)
+
' '
+
inlets
[
-
1
].
name
win
.
checkTable
.
addRow
(
inlets
[
-
1
].
name
)
else
:
print
(
'Don
\'
t know what to do with stream '
+
info
.
name
())
def
update_inlets
():
# clear old inlet stuff
nonlocal
inlets
for
inlet
in
inlets
:
remove_plots_of_inlet
(
inlet
)
rows
=
win
.
checkTable
.
rowNames
.
copy
()
for
row
in
rows
:
win
.
checkTable
.
removeRow
(
row
)
inlets
=
[]
# firstly resolve all streams that could be shown
print
(
"looking for streams"
)
streams
=
pylsl
.
resolve_streams
()
# iterate over found streams, creating specialized inlet objects that will
# handle plotting the data
for
info
in
streams
:
if
info
.
type
()
==
'Markers'
:
if
info
.
nominal_srate
()
!=
pylsl
.
IRREGULAR_RATE
\
or
info
.
channel_format
()
!=
pylsl
.
cf_string
:
print
(
'Invalid marker stream '
+
info
.
name
())
print
(
'Adding marker inlet: '
+
info
.
name
())
inlets
.
append
(
MarkerInlet
(
info
))
# give unique name to inlet and add to checkbox table
inlets
[
-
1
].
name
=
str
(
len
(
inlets
)
-
1
)
+
' '
+
inlets
[
-
1
].
name
win
.
checkTable
.
addRow
(
inlets
[
-
1
].
name
)
elif
info
.
nominal_srate
()
!=
pylsl
.
IRREGULAR_RATE
\
and
info
.
channel_format
()
!=
pylsl
.
cf_string
:
print
(
'Adding data inlet: '
+
info
.
name
())
inlets
.
append
(
DataInlet
(
info
))
# give unique name to inlet and add to checkbox table
inlets
[
-
1
].
name
=
str
(
len
(
inlets
)
-
1
)
+
' '
+
inlets
[
-
1
].
name
win
.
checkTable
.
addRow
(
inlets
[
-
1
].
name
)
else
:
print
(
'Don
\'
t know what to do with stream '
+
info
.
name
())
return
def
scroll
():
"""Move the view so the data appears to scroll"""
...
...
@@ -224,6 +225,38 @@ def main():
for
inlet
in
inlets
:
inlet
.
pull_and_plot
(
mintime
,
win
.
plots
,
plts
)
def
on_check_change
(
row
,
col
,
state
):
if
type
(
state
)
is
int
:
if
state
>
0
:
state
=
True
else
:
state
=
False
elif
type
(
state
)
is
not
bool
:
print
(
'State is of unknown type!! '
)
return
print
(
"check changed: "
+
row
+
" "
+
str
(
state
))
inlet_ix
=
0
for
inlet
in
inlets
:
if
inlet
.
name
==
row
:
if
state
:
inlet
.
set_enabled
(
True
)
mintime
=
pylsl
.
local_clock
()
-
plot_duration
inlet
.
pull_and_plot
(
mintime
,
win
.
plots
,
plts
)
else
:
inlet
.
set_enabled
(
False
)
remove_plots_of_inlet
(
inlet
)
inlet_ix
+=
1
def
on_button_click
():
update_inlets
()
for
row
in
win
.
checkTable
.
saveState
()[
'rows'
]:
on_check_change
(
row
[
0
],
None
,
row
[
1
])
win
.
checkTable
.
sigStateChanged
.
connect
(
on_check_change
)
win
.
updateButton
.
clicked
.
connect
(
on_button_click
)
update_inlets
()
# create a timer that will move the view every update_interval ms
update_timer
=
QtCore
.
QTimer
()
update_timer
.
timeout
.
connect
(
scroll
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment