Skip to content

Commit

Permalink
fix issue 499
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominik Bach committed Aug 11, 2023
1 parent 0d635bf commit 5e7f250
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 29 deletions.
14 changes: 1 addition & 13 deletions src/pspm_dcm.m
Original file line number Diff line number Diff line change
Expand Up @@ -339,20 +339,8 @@

% load and check existing missing data (if defined)
if ~isempty(model.missing{iSn})
[~, missing{iSn}] = pspm_get_timing('epochs', ...
[~, missing{iSn}] = pspm_get_timing('missing', ...
model.missing{iSn}, 'seconds');
% sort missing epochs
if size(missing{iSn}, 1) > 0
[~, sortindx] = sort(missing{iSn}(:, 1));
missing{iSn} = missing{iSn}(sortindx,:);
% check for overlap and merge
for k = 2:size(missing{iSn}, 1)
if missing{iSn}(k, 1) <= missing{iSn}(k - 1, 2)
missing{iSn}(k, 1) = missing{iSn}(k - 1, 1);
missing{iSn}(k - 1, :) = [];
end
end
end
else
missing{iSn} = [];
end
Expand Down
21 changes: 20 additions & 1 deletion src/pspm_get_timing.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
% [sts, multi] = pspm_get_timing('onsets', intiming, timeunits)
% [sts, epochs] = pspm_get_timing('epochs', epochs, timeunits)
% [sts, events] = pspm_get_timing('events', events)
% [sts, epochs] = pspm_get_timing('missing', epochs, timeunits)
% for recursive calls also:
% [sts, epochs] = pspm_get_timing('file', filename)
% ● Arguments
Expand Down Expand Up @@ -352,7 +353,7 @@
end


% Epoch information for SF and GLM (model.missing)
% Epoch information for SF and recursive call from option "missing"
% ------------------------------------------------------------------------
case 'epochs'
% get epoch information from file or from input --
Expand Down Expand Up @@ -408,6 +409,24 @@
'time units are ''%s'''], timeunits); return;
end

% Missing epoch information for GLM and DCM
% ------------------------------------------------------------------------
case 'missing'
[sts, missepochs] = pspm_get_timing('epochs', intiming, timeunits);
if sts < 1, return; end
% sort & merge missing epochs
if size(missepochs, 1) > 0
[~, sortindx] = sort(missepochs(:, 1));
missepochs = missepochs(sortindx,:);
% check for overlap and merge
for k = 2:size(missepochs, 1)
if missepochs(k, 1) <= missepochs(k - 1, 2)
missepochs(k, 1) = missepochs(k - 1, 1);
missepochs(k - 1, :) = [];
end
end
end
outtiming = missepochs;

% Event information for DCM
% ------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/pspm_glm.m
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@
if isempty(model.missing{iSn})
sts = 1; missing{iSn} = [];
else
[sts, missing{iSn}] = pspm_get_timing('epochs', model.missing{iSn}, 'seconds');
[sts, missing{iSn}] = pspm_get_timing('missing', model.missing{iSn}, 'seconds');
end
if sts == -1, warning('ID:invalid_input',...
'Failed to call pspm_get_timing'); return; end
Expand Down
15 changes: 1 addition & 14 deletions src/pspm_sf.m
Original file line number Diff line number Diff line change
Expand Up @@ -223,21 +223,8 @@
data{1}.header.units);
end
% 3.5 Get missing epochs --
% 3.5.1 Load missing epochs --
if ~isempty(model.missing{iFile})
[~, missing{iFile}] = pspm_get_timing('epochs', model.missing{iFile}, 'seconds');
% 3.5.2 sort missing epochs --
if size(missing{iFile}, 1) > 0
[~, sortindx] = sort(missing{iFile}(:, 1));
missing{iFile} = missing{iFile}(sortindx,:);
% check for overlap and merge
for k = 2:size(missing{iFile}, 1)
if missing{iFile}(k, 1) <= missing{iFile}(k - 1, 2)
missing{iFile}(k, 1) = missing{iFile}(k - 1, 1);
missing{iFile}(k - 1, :) = [];
end
end
end
[~, missing{iFile}] = pspm_get_timing('missing', model.missing{iFile}, 'seconds');
else
missing{iFile} = [];
end
Expand Down

0 comments on commit 5e7f250

Please sign in to comment.