I wanted to show the change in source power in real time (0.5 second per cycle reading. mat format EEG data, 8-12Hz bandpass filtering, and source imaging), so I wrote the following script.
But I found that as time went on, the script processing got slower and slower, and then I realized that when I did the source image, I did the source image of all the signals that had been generated before.
I don't want that. I just want to source the current signal.
I don't know what the problem is.
Can someone help me?
Here is my code:
HISTORY = 0.5
SubjectNames = {...
'Subject03'};
for time_idx = 1:200
pause(5);
sFiles = [];
RawFiles = {...
['D:\ft\Matlab Project\SourceMapPlotOnlineFromTDTAndBs\ConfigFiles\BSTestMaterial\ChannelDataOfOnline',[num2str(time_idx),'.mat']]};
sFilesRaw = bst_process('CallProcess', 'process_import_data_time', sFiles, [], ...
'subjectname', SubjectNames{1}, ...
'condition', 'Test', ...
'datafile', {{RawFiles{1}}, 'EEG-MAT'}, ... % ['EEG-MAT' num2str(time_idx)]
'timewindow', [], ...
'split', 0, ...
'ignoreshort', 0, ...
'channelalign', 0, ...
'usectfcomp', 0, ...
'usessp', 0, ...
'freq', [], ...
'baseline', []);
% Process: Low-pass:30Hz
sFilesBandpass = bst_process('CallProcess', 'process_bandpass', sFilesRaw, [], ...
'sensortypes', 'EEG', ...
'highpass', 8, ...
'lowpass', 12, ...
'attenuation', 'strict', ... % 60dB
'mirror', 0, ...
'useold', 0, ...
'overwrite', 0);
% Process: Compute sources [2018]
sFilesSources = bst_process('CallProcess', 'process_inverse_2018', sFilesBandpass, [], ...
'output', 1, ...
'inverse', struct(...
'Comment', 'sLORETA: EEG', ...
'InverseMethod', 'minnorm', ...
'InverseMeasure', 'sloreta', ...
'SourceOrient', {{'fixed'}}, ...
'Loose', 0.2, ...
'UseDepth', 0, ...
'WeightExp', 0.5, ...
'WeightLimit', 10, ...
'NoiseMethod', 'reg', ...
'NoiseReg', 0.1, ...
'SnrMethod', 'fixed', ...
'SnrRms', 1e-06, ...
'SnrFixed', 3, ...
'ComputeKernel', 1, ...
'DataTypes', {{'EEG'}}));
% === DISPLAY ===
hFigTf1 = script_view_sources(sFilesSources.FileName,'cortex');
nFrame = 50;
display_time = 2.5;
frame_time = display_time/nFrame;
for i = 1:nFrame
pause(frame_time);
panel_time('SetCurrentTime', i*(HISTORY/nFrame));
end
close([hFigTf1]);
end