Small Matlab Framework for running Custom Neurofeedback Protocols on LSL Streams
- Windows 10/11
- Matlab 2020a
- Open this folder in Matlab
- Open and start
main.m
in Matlab
- Select your device
- [Optional] Adjust
TYPE
of LSL input stream - Click
OPEN
to connect with LSL input stream - Configure
SETTINGS
,ID
andEPOCHS
- Click
START
to run a session
- Select your device type and model from the available options.
- Add a device by creating a
.json
file for it in subfolderdevices
- Take a look at the existing
nirs_nirx_nirsport2.json
- The most important part is defining the LSL channels sent by the device
- Take a look at the existing
Setting | Description |
---|---|
TYPE |
LSL type of input stream to open. This is device specific. |
CHANNELS |
Number of channels found in LSL stream |
SAMPLE RATE |
Measured Samplerate / Reported Samplerate by Device |
Important
The measured samplerate should (almost) equal the reported samplerate.
Otherwise this turns from green to red and you're likely suffering
from packet loss (e.g. due to bad or overloaded wifi).
Setting | Description |
---|---|
PROTOCOL |
The Matlab file from folder protocols with algorithm executed on each window. |
CHANNELS |
Select LSL channels to use in the selected protocol |
WINDOW SIZE (S) |
Size of the sliding window in seconds. The window always contains last n seconds of samples. |
SESSION LENGTH (S) |
The session will automatically stop after this time. |
Setting | Description |
---|---|
STUDY |
Name of Study |
SUBJECT |
Number of Subject |
RUN |
Number of Run |
The session will be automatically saved in subfolder sessions
with name STUDY-SUBJECT-RUN.mat
An epoch is a configurable timespan within a session.
Setting | Description |
---|---|
START (S) |
Start of Epoch (in seconds) |
END (S) |
End of Epoch (in seconds) |
MARKER |
Marker Value (1-99 ) of Epoch (also sent on LSL) |
VISIBLE |
Visibility of Bar in Feedback Window during Epoch |
COLOR |
Background Color in Feedback Window during Epoch |
- Add epoch by clicking
+
- Remove last or selected epoch(s) by clicking
-
- Chose background color of selected epoch(s) by clicking
COLOR
- Sends triggers on LSL with stream type and name set to
Trigger
- Sends trigger with value
100
on session start - Sends trigger with value
101
on session end - Sends trigger with custom value from column
MARKER
on each epoch start
- Sends markers on LSL with stream type and name set to
Marker
- Sends markers with same samplerate as LSL input (one marker for each LSL input sample)
- Default value is
0
(if no active epoch)
- A protocol calculates a feedback value from an input window
- To add a protocol put the Matlab file in subfolder
protocols
- The
Gauss.m
example requires a NIRS device that sends at least oneHbO
channel withμmol/L
unit - The
RecordOnly.m
works with any device type and model and just records data
DRIFT
shows current offset in playback schedule (where we are
vs.where we should be
)- It typically occurs if the average runtime of your protocol is larger than
1s/samplerate
- If your protocol requires more time then skip some windows and repeat the previous feedback for them (see
example1.m
)
Shows a centered bar with feedback values <= 0.5
visualized in blue and values > 0.5
visualized in red.