Skip to content

Commit

Permalink
Merge branch 'develop' into 509-eyes-observed-incorrectly-inherit-eye…
Browse files Browse the repository at this point in the history
…-marker
  • Loading branch information
teddychao authored Aug 11, 2023
2 parents 164a2e4 + b6d5a8d commit 1959871
Show file tree
Hide file tree
Showing 17 changed files with 451 additions and 460 deletions.
16 changes: 8 additions & 8 deletions src/ext/matlabbatch/cfg_ui.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
%
% See also: GUIDE, GUIDATA, GUIHANDLES
%
% This code is part of a batch job configuration system for MATLAB. See
% This code is part of a batch job configuration system for MATLAB. See
% help matlabbatch
% for a general overview.
%_______________________________________________________________________
Expand Down Expand Up @@ -309,7 +309,7 @@ function local_showjob(obj,cjob)
set(findobj(handles.cfg_ui,'-regexp', 'Tag','.*File(Run)|(RunSerial)$'),'Enable','on');
else
set(findobj(handles.cfg_ui,'-regexp', 'Tag','.*File(Run)|(RunSerial)$'),'Enable','off');
end
end
local_showmod(obj);

% --------------------------------------------------------------------
Expand Down Expand Up @@ -378,7 +378,7 @@ function local_showvaledit(obj)
ciid = {udmodlist.cjob udmodlist.id{cmod} udmodule.id{citem}};
end;
contents = cellfun(@(c)subsref(c, substruct('{}',{citem})), udmodule.contents, 'UniformOutput', false);
sout = cat(2, udmodlist.sout(1:cmod-1));
sout = cat(2, udmodlist.sout{1:cmod-1});
cfg_ui_util('showvaledit', fig, ciid, contents, sout, dflag, [], @()local_valedit_update(obj));
drawnow;

Expand Down Expand Up @@ -564,7 +564,7 @@ function cfg_ui_CloseRequestFcn(hObject, eventdata, handles)
end;

% --- Outputs from this function are returned to the command line.
function varargout = cfg_ui_OutputFcn(hObject, eventdata, handles)
function varargout = cfg_ui_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
Expand Down Expand Up @@ -612,7 +612,7 @@ function MenuFileLoad_Callback(hObject, eventdata, handles)
catch
l = lasterror;
errordlg(l.message,'Error loading job', 'modal');
end
end
set(handles.modlist, 'userdata', udmodlist);
set(handles.module, 'userdata', []);
local_showjob(hObject);
Expand Down Expand Up @@ -815,7 +815,7 @@ function MenuViewUpdateView_Callback(hObject, eventdata, handles)

% This function seems to be called on startup without guidata - do nothing
% there
if ~isempty(handles)
if ~isempty(handles)
local_setmenu(handles.cfg_ui, [], @local_AddMod, true);
udmodlist = get(handles.modlist,'Userdata');
if isstruct(udmodlist)
Expand Down Expand Up @@ -872,7 +872,7 @@ function MenuViewShowCode_Callback(hObject, eventdata, handles)
ctxt = uicontrol('Parent',fg, 'Style','listbox', 'Units','normalized', 'Position',[0 0 1 1], 'FontName','FixedWidth','Tag',[mfilename 'ShowCodeList']);
else
figure(fg);
ctxt = findobj(fg,'Tag',[mfilename 'ShowCodeList']);
ctxt = findobj(fg,'Tag',[mfilename 'ShowCodeList']);
end
um = uicontextmenu;
um1 = uimenu('Label','Copy', 'Callback',@(ob,ev)local_ShowCode_Copy(ob,ev,ctxt), 'Parent',um);
Expand Down Expand Up @@ -1044,7 +1044,7 @@ function MenuFileMultiBatch_Callback(hObject, eventdata, handles)

udmodlist = get(handles.modlist,'userdata');
cjob = udmodlist.cjob;
if cfg_util('isjob_id', cjob)
if cfg_util('isjob_id', cjob)
njob = cfg_util('clonejob', cjob);
cfg_ui_multibatch(njob);
end
Expand Down
35 changes: 4 additions & 31 deletions src/ext/matlabbatch/cfg_ui_util.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
% module or data summary. It also handles all value display and editing for
% a particular item.
%
% This code is part of a batch job configuration system for MATLAB. See
% This code is part of a batch job configuration system for MATLAB. See
% help matlabbatch
% for a general overview.
%_______________________________________________________________________
Expand Down Expand Up @@ -102,21 +102,12 @@
case {'showitem'}
% [contents, namestr, datastr] = cfg_ui_util('showitem', ciid, dflag)
[ciid, dflag] = deal(varargin{1:2});
if isstruct(ciid)
[id, stop, contents] = ...
cfg_util('listmod', ciid(:),...
cfg_findspec({{'hidden',false}}), ...
cfg_tropts({{'hidden', true}},1,1,1,1,dflag), ...
{'name','val','labels','values','class','level', ...
'all_set','all_set_item','num','preview'});
else
[id, stop, contents] = ...
[id, stop, contents] = ...
cfg_util('listmod', ciid{:},...
cfg_findspec({{'hidden',false}}), ...
cfg_tropts({{'hidden', true}},1,1,1,1,dflag), ...
{'name','val','labels','values','class','level', ...
'all_set','all_set_item','num','preview'});
end
contents = cellfun(@(c)subsref(c, substruct('{}',{1})), contents, 'UniformOutput', false);
[namestr, datastr] = cfg_ui_util('showitemstr', contents, dflag);
varargout{1} = contents;
Expand All @@ -125,39 +116,21 @@
case {'showmod'}
% [id, namestr, datastr, contents] = cfg_ui_util('showmod', cmid, dflag)
[cmid, dflag] = deal(varargin{1:2});
if isstruct(cmid)
[id, stop, contents] = ...
cfg_util('listmod', cmid(:), [],...
cfg_findspec({{'hidden',false}}), ...
cfg_tropts({{'hidden', true}},1,Inf,1,Inf,dflag), ...
{'name','val','labels','values','class','level', ...
'all_set','all_set_item','num','preview'});
else
[id, stop, contents] = ...
[id, stop, contents] = ...
cfg_util('listmod', cmid{:}, [],...
cfg_findspec({{'hidden',false}}), ...
cfg_tropts({{'hidden', true}},1,Inf,1,Inf,dflag), ...
{'name','val','labels','values','class','level', ...
'all_set','all_set_item','num','preview'});
end
if isempty(id) || ~cfg_util('isitem_mod_id', id{1})
% Module not found without hidden flag
% Try to list top level entry of module anyway, but not module items.
if isstruct(cmid)
[id, stop, contents] = ...
cfg_util('listmod', cmid(:), [],...
cfg_findspec({}), ...
cfg_tropts({{'hidden', true}},1,1,1,1,dflag), ...
{'name','val','labels','values','class','level', ...
'all_set','all_set_item','preview'});
else
[id, stop, contents] = ...
[id, stop, contents] = ...
cfg_util('listmod', cmid{:}, [],...
cfg_findspec({}), ...
cfg_tropts({{'hidden', true}},1,1,1,1,dflag), ...
{'name','val','labels','values','class','level', ...
'all_set','all_set_item','preview'});
end
end;
namestr = cell(1,numel(id));
datastr = cell(1,numel(id));
Expand Down
4 changes: 2 additions & 2 deletions src/pspm_cfg/pspm_cfg_glm.m
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,9 @@
mrk_chan.strtype = 'i';
mrk_chan.val = {0};
mrk_chan.num = [1 1];
mrk_chan.help = {['Indicate the marker channel. By default the last marker channel is ' ...
mrk_chan.help = {['Indicate the marker channel. By default (value 0) the first marker channel is ' ...
'assumed to contain the relevant markers.'], ['Markers are only used if you have ' ...
'specified the time units as markers.']};
'specified the time units as "markers".']};

% Timeunits
seconds = cfg_const;
Expand Down
4 changes: 3 additions & 1 deletion src/pspm_cfg/pspm_cfg_run_sf.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@
options.fresp = job.fresp;
end
if ~isempty(job.missing)
options.missing = job.missing;
if ischar(job.missing.missingdata)
options.missing = job.missing;
end
end
options.dispwin = job.dispwin;
options.dispsmallwin = job.dispsmallwin;
Expand Down
31 changes: 24 additions & 7 deletions src/pspm_cfg/pspm_cfg_sf.m
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@
filter.values = {filter_def, filter_edit};
filter.help = {'Specify how you want filter the SCR data.'};



%% Epochs
epochfile = cfg_files;
epochfile.name = 'Epoch File';
Expand Down Expand Up @@ -193,7 +195,7 @@
mrk_chan.strtype = 'i';
mrk_chan.val = {0};
mrk_chan.num = [1 1];
mrk_chan.help = {['Indicate the marker channel. By default the first marker channel is ' ...
mrk_chan.help = {['Indicate the marker channel. By default (value 0) the first marker channel is ' ...
'assumed to contain the relevant markers.'], ['Markers are only used if you have ' ...
'specified the time units as "markers".']};

Expand Down Expand Up @@ -292,14 +294,29 @@
fresp.help = {'Frequency of responses to model.'};
fresp.hidden = true;

missing = cfg_files;
missing.name = 'Missing epoch file';
missing.tag = 'missingfile';
missing.num = [1 1];
missing.filter = '.*\.(mat|MAT)$';
missing.help = {['Missing (e.g. artefact) epochs in the data file, where ',...


missingepoch_none = cfg_const;
missingepoch_none.name = 'Not added';
missingepoch_none.tag = 'missingdata';
missingepoch_none.val = {0};
missingepoch_none.help = {'Do not add missing epochs.'};

missingepoch_file = cfg_files;
missingepoch_file.name = 'Missing epoch file';
missingepoch_file.tag = 'missingdata';
missingepoch_file.num = [1 1];
missingepoch_file.filter = '.*\.(mat|MAT)$';
missingepoch_file.help = {['Missing (e.g. artefact) epochs in the data file, where ',...
'data must always be specified in seconds.']};

missing = cfg_choice;
missing.name = 'Missing Epoch Settings';
missing.tag = 'missing';
missing.val = {missingepoch_none};
missing.values = {missingepoch_none, missingepoch_file};
missing.help = {'Specify whether you would like to include missing epochs.'};

% Show figures
dispwin = cfg_menu;
dispwin.name = 'Display Progress Window';
Expand Down
22 changes: 13 additions & 9 deletions src/pspm_dcm.m
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,16 @@
else
missing{iSn} = [];
end
model.filter.sr = data{iSn}{1}.header.sr;
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(data{iSn}{1}.data,1);
n_data = size(y{iSn},1);
if isempty(missing{iSn})
nan_epochs = isnan(data{iSn}{1}.data);
nan_epochs = isnan(y{iSn});

d_nan_ep = transpose(diff(nan_epochs));
nan_ep_start = find(d_nan_ep == 1);
Expand All @@ -388,19 +392,19 @@

% classify if epoch should be considered
% true for duration > substhresh and for missing epochs
ignore_epochs = diff(miss_epochs, 1, 2)/data{iSn}{1}.header.sr > ...
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},data{iSn}{1}.header.sr);
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)
flanks = round(miss_epochs(k,:));
data{iSn}{1}.data(flanks(1):flanks(2)) = NaN;
y{iSn}(flanks(1):flanks(2)) = NaN;
end
end

Expand Down Expand Up @@ -436,17 +440,17 @@
n_sbs = numel(se_start);
% enabled subsessions
subsessions(end+(1:n_sbs), 1:4) = [ones(n_sbs,1)*iSn, ...
[se_start, se_stop]/data{iSn}{1}.header.sr, ...
[se_start, se_stop]/sr{iSn}, ...
zeros(n_sbs,1)];

% missing epochs
n_miss = sum(ignore_epochs);
subsessions(end+(1:n_miss), 1:4) = [ones(n_miss,1)*iSn, ...
miss_epochs(i_e,:)/data{iSn}{1}.header.sr, ...
miss_epochs(i_e,:)/sr{iSn}, ...
ones(n_miss,1)];
else
subsessions(end+1,1:4) = [iSn, ...
[1, numel(data{iSn}{1}.data)]/data{iSn}{1}.header.sr, 0];
[1, numel(y{iSn})]/sr{iSn}, 0];


end
Expand Down
7 changes: 4 additions & 3 deletions src/pspm_dcm_inv.m
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,10 @@
priors.SigmaX0 = zeros(7);
priors.muX0 = zeros(7, 1);
if trl == 1
priors.muX0(1) = mean(y(1:3));%) - min(y);
priors.muX0(2) = mean(diff(y(1:3)));
priors.muX0(3) = diff(diff(y(1:3)));
y_non_nan = y(~isnan(y));
priors.muX0(1) = mean(y_non_nan(1:3));%) - min(y);
priors.muX0(2) = mean(diff(y_non_nan(1:3)));
priors.muX0(3) = diff(diff(y_non_nan(1:3)));
priors.muX0(7) = 0;%min(y);
for n = [1:3 7]
priors.SigmaX0(n, n) = 1e-2;
Expand Down
Loading

0 comments on commit 1959871

Please sign in to comment.