Repository navigation
Create neurofeedback protocols
HOW TO CREATE NEUROFEEDBACK PROTOCOLS WITH LLAMAS
LLAMAS allows you to create your own neurofeedback protocols and implement them during your recordings from the settings dialog. This serves as a primer for how to do this. An example of this is the MakeMusic.m file in the 'Postprocessing Functions' folder.
You should save your function to the 'Postprocessing functions' folder, if you want it to be available during a recording. The header of your neurofeedback function should follow this pattern:
function [vars, Graph, EEG] = MakeMusic(EEG, vars, Graph)
The inputs(EEG, vars, Graph) and outputs [vars, Graph, EEG] of your functions should always be the same, although the name of the function will always necessarily be different.
EEG is a struct containing front-end EEG info, such as the EEG data, channel names, and other information that is pertinent to an end-user (see LLAMAS Data Structure). EEG can obviously be edited in your function, and fields added or removed, but for performance reasons, it may be best to think of this variable as 'read only' unless there is a pressing reason to write to it.
vars is a struct that contains a variety of backend variables, and is where you should add your variables, if you want them to persist between calls to your function.
Graph is struct that contains handles for any visualizations, such as the streaming data window. If you want to create your own visuals, you should add the handles for those figures to the Graph struct so that they persist between calls.
Your function will be called every time a non-empty chunk is received through LSL, after gradient artifact correction (if used) and downsampling (if used) have been performed.
Your function body should contain instructions for what you wish to do with each chunk of data. It may often be prudent to have an 'if' statement to initialize some fields the first time your function is called, for example:
if ~isfield(vars, 'MusicVar')
vars.MusicVar.MusicFlag = 1;
What goes on in the body of your function beyond that is really up to you! You can set it up so it only performs and action every so-many samples, you can use PsychToolbox or PyschPortAudio to provide feedback, you can implement filters or neural networks. The MakeMusic function is designed to play different tones based on the peak frequency of the spectrum of a chosen channel.
To use your function during a recording, Please see the postprocessing function menu in the Settings Window.