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
3724a792
Commit
3724a792
authored
May 22, 2020
by
Marios Fanourakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
start of adding ability to select channels per outlet
parent
6b211afc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
33 deletions
+44
-33
visualize_streams.py
visualize_streams.py
+44
-33
No files found.
visualize_streams.py
View file @
3724a792
...
...
@@ -45,6 +45,7 @@ class Inlet:
self
.
name
=
info
.
name
()
self
.
channel_count
=
info
.
channel_count
()
self
.
uid
=
info
.
uid
()
self
.
channel_enabled
=
np
.
ones
(
self
.
channel_count
)
self
.
plt_ixs
:
List
[
int
]
=
[]
self
.
curves
=
None
self
.
enabled
=
False
...
...
@@ -84,14 +85,15 @@ class DataInlet(Inlet):
self
.
curves
=
[
pg
.
PlotCurveItem
(
x
=
empty
,
y
=
empty
,
autoDownsample
=
True
)
for
_
in
range
(
self
.
channel_count
)]
ch_ix
=
0
for
curve
in
self
.
curves
:
gl
.
nextRow
()
plts
.
append
(
gl
.
addPlot
())
plts
[
-
1
].
addItem
(
curve
)
plts
[
-
1
].
setXLink
(
plts
[
0
])
plts
[
-
2
].
hideAxis
(
'bottom'
)
plts
[
-
1
].
hideAxis
(
'top'
)
plts
[
-
1
].
setTitle
(
title
=
self
.
name
+
' channel '
+
str
(
ch_ix
))
self
.
plt_ixs
.
append
(
len
(
plts
)
-
1
)
if
(
self
.
channel_enabled
[
ch_ix
]):
gl
.
nextRow
()
plts
.
append
(
gl
.
addPlot
())
plts
[
-
1
].
addItem
(
curve
)
plts
[
-
1
].
setXLink
(
plts
[
0
])
plts
[
-
2
].
hideAxis
(
'bottom'
)
plts
[
-
1
].
hideAxis
(
'top'
)
plts
[
-
1
].
setTitle
(
title
=
self
.
name
+
' channel '
+
str
(
ch_ix
))
self
.
plt_ixs
.
append
(
len
(
plts
)
-
1
)
ch_ix
=
ch_ix
+
1
# pull the data
...
...
@@ -106,25 +108,26 @@ class DataInlet(Inlet):
old_offset
=
0
new_offset
=
0
for
ch_ix
in
range
(
self
.
channel_count
):
# we don't pull an entire screen's worth of data, so we have to
# trim the old data and append the new data to it
old_x
,
old_y
=
self
.
curves
[
ch_ix
].
getData
()
# the timestamps are identical for all channels, so we need to do
# this calculation only once
if
ch_ix
==
0
:
# find the index of the first sample that's still visible,
# i.e. newer than the left border of the plot
old_offset
=
old_x
.
searchsorted
(
plot_time
)
# same for the new data, in case we pulled more data than
# can be shown at once
new_offset
=
ts
.
searchsorted
(
plot_time
)
# append new timestamps to the trimmed old timestamps
this_x
=
np
.
hstack
((
old_x
[
old_offset
:],
ts
[
new_offset
:]))
# append new data to the trimmed old data
this_y
=
np
.
hstack
((
old_y
[
old_offset
:],
y
[
new_offset
:,
ch_ix
]
-
ch_ix
))
# replace the old data
# FIXME with temp fix for curves not showing if there are nan values
self
.
curves
[
ch_ix
].
setData
(
this_x
,
np
.
nan_to_num
(
this_y
),
connect
=
'finite'
)
if
self
.
channel_enabled
[
ch_ix
]:
# we don't pull an entire screen's worth of data, so we have to
# trim the old data and append the new data to it
old_x
,
old_y
=
self
.
curves
[
ch_ix
].
getData
()
# the timestamps are identical for all channels, so we need to do
# this calculation only once
if
ch_ix
==
0
:
# find the index of the first sample that's still visible,
# i.e. newer than the left border of the plot
old_offset
=
old_x
.
searchsorted
(
plot_time
)
# same for the new data, in case we pulled more data than
# can be shown at once
new_offset
=
ts
.
searchsorted
(
plot_time
)
# append new timestamps to the trimmed old timestamps
this_x
=
np
.
hstack
((
old_x
[
old_offset
:],
ts
[
new_offset
:]))
# append new data to the trimmed old data
this_y
=
np
.
hstack
((
old_y
[
old_offset
:],
y
[
new_offset
:,
ch_ix
]
-
ch_ix
))
# replace the old data
# FIXME with temp fix for curves not showing if there are nan values
self
.
curves
[
ch_ix
].
setData
(
this_x
,
np
.
nan_to_num
(
this_y
),
connect
=
'finite'
)
class
MarkerInlet
(
Inlet
):
...
...
@@ -154,12 +157,14 @@ class MainWindow(QtWidgets.QMainWindow):
self
.
plots
=
pg
.
GraphicsLayoutWidget
()
self
.
selectAllButton
=
QtGui
.
QPushButton
(
'select/deselect all'
)
self
.
checkTable
=
pg
.
CheckTable
([
''
])
self
.
chanTable
=
pg
.
TableWidget
(
editable
=
True
,
sortable
=
False
)
self
.
updateButton
=
QtGui
.
QPushButton
(
'Update inlets'
)
self
.
layout
.
addWidget
(
self
.
selectAllButton
,
0
,
0
)
self
.
layout
.
addWidget
(
self
.
checkTable
,
1
,
0
)
self
.
layout
.
addWidget
(
self
.
chanTable
,
1
,
1
)
self
.
layout
.
addWidget
(
self
.
updateButton
,
2
,
0
)
self
.
layout
.
addWidget
(
self
.
plots
,
1
,
1
)
self
.
layout
.
addWidget
(
self
.
plots
,
1
,
2
)
self
.
setCentralWidget
(
self
.
mainWidget
)
...
...
@@ -177,27 +182,32 @@ def main():
inlets
:
List
[
Inlet
]
=
[]
def
remove_plots
(
inlet
=
None
):
def
remove_plots
(
inlet
=
None
,
channel
=
None
):
if
inlet
is
None
:
nonlocal
inlets
for
inlet
in
inlets
:
for
plt_ix
in
inlet
.
plt_ixs
:
win
.
plots
.
removeItem
(
plts
[
plt_ix
])
inlet
.
plt_ixs
=
[]
else
:
for
plt_ix
in
inlet
.
plt_ixs
:
win
.
plots
.
removeItem
(
plts
[
plt_ix
])
if
channel
is
None
:
win
.
plots
.
removeItem
(
plts
[
plt_ix
])
elif
plt_ix
==
channel
:
win
.
plots
.
removeItem
(
plts
[
plt_ix
])
inlet
.
plt_ixs
=
[]
def
update_inlets
():
# clear old inlet stuff
nonlocal
inlets
for
inlet
in
inlets
:
remove_plots
(
inlet
)
remove_plots
(
None
)
rows
=
win
.
checkTable
.
rowNames
.
copy
()
for
row
in
rows
:
win
.
checkTable
.
removeRow
(
row
)
nonlocal
inlets
inlets
=
[]
# firstly resolve all streams that could be shown
...
...
@@ -223,6 +233,7 @@ def main():
# 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
)
win
.
chanTable
.
setData
([
"1;2;8"
])
else
:
print
(
'Don
\'
t know what to do with stream '
+
info
.
name
())
return
...
...
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