Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix 504 #522

Merged
merged 1 commit into from
Aug 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 16 additions & 19 deletions src/pspm_dcm.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
% ├────.filter: Filter settings.
% │ Modality specific default.
% ├───.channel: Channel number.
% │ Default: first SCR channel
% │ Default: last SCR channel
% ├──────.norm: Normalise data.
% │ i.e. Data are normalised during inversion but results
% │ transformed back into raw data units.
Expand Down Expand Up @@ -204,7 +204,7 @@
% 2.3 get further input or set defaults --
% check data channel --
if ~isfield(model, 'channel')
model.channel = 'scr'; % this returns the first SCR channel
model.channel = 'scr'; % this returns the last SCR channel
elseif ~isnumeric(model.channel) && ~strcmp(model.channel,'scr')
warning('ID:invalid_input', 'Channel number must be numeric.'); return;
end
Expand Down Expand Up @@ -343,19 +343,20 @@
return;
end

% use the last data channel, consistent with sf and glm
y{iSn} = data{iSn}{end}.data;
sr{iSn} = data{iSn}{end}.header.sr;
model.filter.sr = sr{iSn};


% load and check existing missing data (if defined)
if ~isempty(model.missing{iSn})
[~, missing{iSn}] = pspm_get_timing('missing', ...
model.missing{iSn}, 'seconds');
else
missing{iSn} = [];
end
y{iSn} = data{iSn}{end}.data;
% to use the last channel in data channels
% this is consistent to sf and glm
sr{iSn} = data{iSn}{end}.header.sr;
model.filter.sr = sr{iSn};


% try to find missing epochs according to subsession threshold
n_data = size(y{iSn},1);
if isempty(missing{iSn})
Expand Down Expand Up @@ -384,16 +385,10 @@
% put missing epochs together
miss_epochs = [nan_ep_start(:), nan_ep_stop(:)];

% classify if epoch should be considered
% true for duration > substhresh and for missing epochs
ignore_epochs = diff(miss_epochs, 1, 2)/sr{iSn} > ...
model.substhresh;

else
% use missing epochs as specified by file
miss_epochs = pspm_time2index(missing{iSn}, sr{iSn});
ignore_epochs = diff(missing{iSn}, 1, 2) > model.substhresh;


% and set data to NaN to enable later detection of `short` missing
% epochs
for k = 1:size(miss_epochs, 1)
Expand All @@ -402,6 +397,9 @@
end
end

% epoch should be ignored if duration > threshold
ignore_epochs = diff(miss_epochs, 1, 2)/sr{iSn} > model.substhresh;

if any(ignore_epochs)
i_e = find(ignore_epochs);

Expand Down Expand Up @@ -444,8 +442,7 @@
ones(n_miss,1)];
else
subsessions(end+1,1:4) = [iSn, ...
[1, numel(y{iSn})]/sr{iSn}, 0];

[0, numel(y{iSn})]/sr{iSn}, 0];

end
end
Expand Down Expand Up @@ -556,8 +553,8 @@

% assign trials to subsessions
trls = num2cell([sn_trlstart{iSn}, sn_trlstop{iSn}],2);
subs = cellfun(@(x) find(x(1) > subsessions(:,2) & ...
x(2) < (subsessions(:,3)) ...
subs = cellfun(@(x) find(x(1) >= subsessions(:,2) & ...
x(2) <= (subsessions(:,3)) ...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I was not aware of this situation when I check the code..

& subsessions(:, 1) == iSn), trls, 'UniformOutput', 0);

emp_subs = cellfun(@isempty, subs);
Expand Down