Comments (4)
Sending and receiving data are decoupled. The inlet doesn't care about the outlet's chunk size, and vice versa. The inlet's pull_chunk
will pull as many samples as are available. You may be wondering, if your outlet only pushes 256-sample chunks at a time then why are you able to pull less than 256 samples? It's because push_chunk
is just an optimized loop of push_sample
. Your inlet happens to be asking for samples in the middle of this loop.
You can try playing around with the chunk_size
parameter on the outlet, or max_chunklen
on the inlet.
However, this isn't really what we'd consider "best practice". Your approach is adding an artificial 1.0-second delay from the time of the first sample in a chunk until the time that sample is sent. The preferred way is to send samples as fast as possible then let the receiving applications decide how to deal with them.
If you're accumulating 1-second's worth of samples because you want to do an FFT on them, a better thing to do is maintain a FIFO buffer of 256 samples. Whenever a new chunk comes in, whether that chunk has 2 samples or 172 samples, you discard the oldest samples, add the new samples to the buffer,and then calculate the fft on the entire buffer. This will allow you to update your spectra as fast as possible. If you want the spectral updates to be at a constant step-size, then you can do something similar but you need a slightly more complicated buffering strategy (e.g., "full" buffer and "on deck" buffer).
If you can tell me more about why you need exactly 256 samples then I might be able to help you come up with a different strategy.
from labstreaminglayer.
Thank you so much for answering my question. I want to start by giving brief information about my work.In our study, we want to detect the visual discomfort of VR users by using EEG signals. We trained a model using raw EEG data from the participants. In our real-time application, we plan to collect simultaneous EEG data while users are exposed to the VR environment and offer a more comfortable scene if discomfort is detected.
Therefore, when the user is exposed to the VR environment, we intend to collect 1-second data(256 samples) and then pass the collected data through the bandpass filter, then scaling and input it into the prediction function. In our study, we use 14 channel Emotiv Epoc + device to collect EEG data. So I need to collect a total of 256 samples from 14 channels to use in preprocessing and prediction. I need to do this in certain steps in my real-time application.
Your suggestions are very valuable to me. Thank you so much.
from labstreaminglayer.
There's no reason for the 1-second windows you're analyzing to be non-overlapping, right?
For the bandpass filtering step, you can do that on as few samples as you want, you just have to save the filter state after every iteration then pass it to the next iteration. See the zi
argument in scipy's sosfilt
, and sosfilt_zi
for the very beginning, before it's seen any data.
(Note that you should use an FIR filter design so you can compensate for the constant filter delay if you need to merge the filter output with other parallel processing steps, but if you are not doing so then I think IIR filters are better).
I would then take the output of the filter and add it to a FIFO buffer as described above, and run the entire buffer through the rest of the model, even though the buffer has only been updated by N samples. In this way, you'll be updating your output as fast as your signal processing speed allows, which should lead to a better user experience.
from labstreaminglayer.
the data must be 1 second to make predictions and it can be overlapped. Can I continue to store new data in the buffer while using the 1-second data I've collected for prediction? If I can't add instant data to the buffer while I'm processing the last 1 second data, will I get the wrong data if I continue adding to the FIFO buffer after the processing is finished?
from labstreaminglayer.
Related Issues (20)
- How do I find device name that is being streamed through LSL? HOT 1
- Synch Xsens + TCD/IP cameras HOT 2
- time stamp jump bug HOT 6
- Submitting new app fails HOT 6
- building for android fails HOT 5
- "Error trying to send a time packet: Invalid argument" when accessing a new stream HOT 8
- empty folders HOT 1
- Screen Capture as an LSL Inlet HOT 4
- Single PC clock offset meaning vs. latency and jitter HOT 1
- Time synchronization between multiple OS HOT 4
- Data from udp HOT 1
- Is it possible to compile liblsl to .frameworks or other format which callable in labview?
- Unable to record multiple audio streams HOT 1
- Bluetooth version HOT 1
- what happened to your forum, formerly at https://mailman.ucsd.edu/mailman/listinfo/lsl-l ? HOT 5
- Record data by SCAN4.5 and labrecorder is different? HOT 4
- LSL connection between Windows and Ubuntu HOT 3
- Documentation for maintaining various distributions. HOT 1
- Best way to send data from a device to the web HOT 5
- Streams with manual timestamps sent by LSL to Labrecorder are incorrectly loaded from .xdf HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from labstreaminglayer.