diff --git a/src/pspm_dcm.m b/src/pspm_dcm.m index 732368585..8050dedc5 100644 --- a/src/pspm_dcm.m +++ b/src/pspm_dcm.m @@ -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 diff --git a/src/pspm_get_timing.m b/src/pspm_get_timing.m index 9571ee819..896ff7aee 100644 --- a/src/pspm_get_timing.m +++ b/src/pspm_get_timing.m @@ -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 @@ -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 -- @@ -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 % ------------------------------------------------------------------------ diff --git a/src/pspm_glm.m b/src/pspm_glm.m index 3cf10d500..4728731bb 100644 --- a/src/pspm_glm.m +++ b/src/pspm_glm.m @@ -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 diff --git a/src/pspm_sf.m b/src/pspm_sf.m index 48c7d426f..9cf580075 100644 --- a/src/pspm_sf.m +++ b/src/pspm_sf.m @@ -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