I'm using the BCI2000 Automation Remote to instantiate and configure a session using a MATLAB script, however, I'm running into a fairly odd error. Whenever I run the script, I generate the following error:
Error: [module1] NIDAQ_mx_Source: Next module's IP/Port parameters not available.
Error: [module2] DummySignalProcessing: Next module's IP/Port parameters not available.
Error: [module3] DummyApplication: Next module's IP/Port parameters not available.
The really odd part about this is that if I simply start the session using the BCI2000Launcher, I do not run into the same error. This is using the same parameter files and everything. This leads me to believe that the issue is with my script, specifically. I've attached the MATLAB script as reference. Any help would be greatly appreciated.
Christopher Hunt
Code: Select all
%BCI2000 Interfacing with MATLAB
sensorFlags = [1 0 0]; %determines what is being collected
%(1) EMG, (2) CyberGlove, (3) IMU
maxTime = 5; %record data for how long
hand = 0; %hand being recorded (0 = right, 1 = left)
%data formatting variables
subject = 'TEST'; %subject name
session = '001'; %session number
run = 'R01'; %run number
%dataStore = 'E:/thakor_phd_research/Matlab/Agarwal_Hunt - Finger Decoding'; %directory where the data is to be stored
bci = actxserver('BCI2000Automation.BCI2000Remote'); %instantiates a BCI2000 remote
try
bci.WindowVisible = 0; %hide the window
ok = bci.Connect; %connect to operator module
if ~ok
error(bci.Result);
end
signalModule = 'NIDAQ_mx_Source'; %always collect EMG data
if sensorFlags(2) %if collecting CyberGlove
handFlag = sprintf(' --CyberGloveHand=%d', hand);
signalModule = strcat(signalModule, ' --LogCyberGlove=1', handFlag);
end
if sensorFlags(3) %if collecting IMU
signalModule = strcat(signalModule, ' --LogIMU=1');
end
%add more as hardware becomes supported
totalModules = {signalModule, 'DummySignalProcessing', 'DummyApplication'};
ok = bci.StartupModules(totalModules); %loading data acquisition
if ~ok
error(bci.Result);
end
ok = bci.LoadParametersRemote('../data/testNIDAQ.prm'); %load config parameters
if ~ok
error(bci.Result);
end
bci.SubjectID = subject; %overwrite subject name
bci.SessionID = session; %overwrite session number
%bci.DataDirectory = dataStore; %overwrite where to store data
bciState = 'Running';
imuOutput = zeros(12, 1, 'double'); %will hold BCI2000 state data
ok = bci.Start(); %start recording
if ~ok
error(bci.Result);
end
tstart = tic;
while ok && strcmp(state, 'Running') && toc(tstart) < maxTime
%allow data to be collected
for i = 1:12
bci.GetStateVariable(sprintf('IMUData%02d', i), imuOutput(i));
end
disp(imuOutput); %show IMU data
[ok, state] = bci.GetSystemState(state); %check if running still
end
if ~ok
error(bci.Result);
end
ok = bci.Stop(); %stop recording, not deleting anything
if ~ok
error(bci.Result);
end
catch exception
%delete the BCI2000 remote if error
bci.delete;
throw(exception);
end
bci.delete; %delete the remote to shut down the operator module
%load produced data file to view data offline
loadOutput = strcat('load ', subject, session, run, '.dat');
eval(loadOutput);