How to store streamed data and use it in real-time biofeedback

2 views (last 30 days)
I am streaming force data into MATLAB from Qualisys Track Manager (QTM - motion capture kinematic/kinetic software). I am using this funcitonality to pull force data from a set of force plates. This force data will be used to trigger specific visual stimuli (built in psychtoolbox (PTB)) in real time . QTM provides a command to query the data:
QCM('connect', '127.0.0.1', 'frameinfo', '3d force') % Data streaming command
[frameinfo, the3D, force] = QCM; % Data type specification
I created a button to start and continue pulling data from QTM:
% create user interface figure with button
f=uifigure;
button=uibutton(f,'state');
button.ValueChangedFcn=@(src,evt)ControlTimer(src,evt,QTM_timer);
QTM_timer=timer('period',0.001,'ExecutionMode','fixedrate','taskstoexecute',inf,'timerfcn',@(src,evt)pollQTM);
%control timer function (separate file)
function ControlTimer(~,evt,QTM_timer)
switch evt.Value
case 0 % button NOT clicked
stop(QTM_timer);
case 1 % button clicked
start(QTM_timer);
end
end
%pollQTM function (separate file)
function pollQTM(~,~)
a=QCM('event');
switch a
case 8 % capture started; use 8 for RT play; use 3 for streaming
% retrieve new frame of data from QTM
[frameinfo the3D force]=QCM;
disp(frameinfo(1)); % display frame number to confirm it is working
case 9 % capture stopped; use 9 for RT play; use 4 for streaming
stop(QTM_timer);
QCM('disconnect')
end
end
From here I am using "force" and doing various calculations with it to eventually get center of pressure data (CoP - x,y,z).
MY QUESTION IS: how do I store this data as each packet is retrieved? I would like to store the data, do the CoP calculations, and then use the stored data in my psychtoolbox code to trigger the visual stimuli in real time.
  1 Comment
Sachin
Sachin on 14 Mar 2023
Could you please provide more information about 'how do I store this data as each packet is retrieved?' like which data you want to store ?

Sign in to comment.

Answers (0)

Products


Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!