Import matlab workspace variable using matlab command line

Hi Yagna,

Yes, you can use the db_add function, but you have to define carefully the inputs of the function. Particularly the data structure must be the structure used in the recordings .mat files in Brainstorm database. Here is an example script:

% Create subject
db_add_subject('SubjectXX');
% Create condition
iStudy = db_add_condition('SubjectXX', 'ConditionXX');
% Define data structure to import
nChannel = 302;
nTime    = 200;
DataMat = db_template('DataMat');
DataMat.F           = 1e-6 .* rand(nChannel, nTime);
DataMat.Time        = 1e-3 .* (0:(nTime-1));
DataMat.ChannelFlag = ones(nChannel, 1);
DataMat.DataType    = 'recordings';
DataMat.Comment     = 'What is shown in the tree';
DataMat.nAvg        = 1;
% Add it to the database
db_add(iStudy, DataMat);

Francois