Skip to content

Commit

Permalink
Bugfix: Export events to SPM .mat/.dat
Browse files Browse the repository at this point in the history
  • Loading branch information
ftadel committed Jan 31, 2022
1 parent 76746e7 commit 8170830
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions toolbox/io/out_fopen_spm.m
Expand Up @@ -19,7 +19,7 @@
% For more information type "brainstorm license" at command prompt.
% =============================================================================@
%
% Authors: Francois Tadel, 2017-2021
% Authors: Francois Tadel, 2017-2022

% Initialize SPM12+CAT12
[isInstalled, errMsg] = bst_plugin('Install', 'spm12');
Expand Down Expand Up @@ -48,12 +48,15 @@
for iEvt = 1:length(sFileIn.events)
for iOcc = 1:size(sFileIn.events(iEvt).times,2)
i = length(D.trials.events) + 1;
D.trials.events(i).type = sFileIn.events(iEvt).label;
D.trials.events(i).time = sFileIn.events(iEvt).times(1,iOcc);
D.trials.events(i).type = sFileIn.events(iEvt).label;
if ~isempty(sFileIn.events(iEvt).notes) && ~isempty(sFileIn.events(iEvt).notes{iOcc})
D.trials.events(i).type = [D.trials.events(i).type '-' sFileIn.events(iEvt).notes{iOcc}];
end
D.trials.events(i).time = sFileIn.events(iEvt).times(1,iOcc);
D.trials.events(i).value = iEvt;
D.trials.events(i).offset = 0;
if (size(sFileIn.events(iEvt).times,1) == 2)
D.trials.events(i).duration = sFileIn.events(iEvt).times(1,iOcc) - sFileIn.events(iEvt).times(2,iOcc);
D.trials.events(i).duration = sFileIn.events(iEvt).times(2,iOcc) - sFileIn.events(iEvt).times(1,iOcc);
else
D.trials.events(i).duration = [];
end
Expand Down

0 comments on commit 8170830

Please sign in to comment.