The purpose of this page is just to serve as todo or scratch pad for the development project and to list and share some ideas.
The code development project mentioned on this page has been finished by now. Chances are that this page is considerably outdated and irrelevant. The notes here might not reflect the current state of the code, and you should not use this as serious documentation.
Consistent implementation of option for trial selection in all relevant functions (such as plotting functions, functions that handle raw data, etc.).
How it's currently implemented in these functions:
% cfg.trials = 'all' or a selection like 1:10 (default = 'all')
% set the defaults if ~isfield(cfg, 'trials'), cfg.trials = 'all'; end
% select trials of interest
if ~strcmp(cfg.trials, 'all')
fprintf('selecting %d trials\n', length(cfg.trials));
data.trial = data.trial(cfg.trials);
data.time = data.time(cfg.trials);
end
For raw data input functions (implement before 'Ntrials=…' or equivalent):
% set the defaults if ~isfield(cfg, 'trials'), cfg.trials = 'all'; end
% select trials of interest
if ~strcmp(cfg.trials, 'all')
fprintf('selecting %d trials\n', length(cfg.trials));
data.trial = data.trial(cfg.trials);
data.time = data.time(cfg.trials);
end
For rpt data input functions:
% set the defaults if ~isfield(cfg, 'trials'), cfg.trials = 'all'; end
elseif strcmp(data.dimord, 'rpt_chan_time')
tmpcfg = [];
tmpcfg.trials = cfg.trials;
data = timelockanalysis(tmpcfg, data);
if ~isfield(cfg, 'xparam'), cfg.xparam='time'; end
if ~isfield(cfg, 'yparam'), cfg.yparam=''; end
if ~isfield(cfg, 'zparam'), cfg.zparam='avg'; end
elseif strcmp(varargin{1}.dimord, 'rpt_chan_time')
tmpcfg = [];
tmpcfg.trials = cfg.trials;
for i=1:(nargin-1)
varargin{i} = timelockanalysis(tmpcfg, varargin{i});
end
if ~isfield(cfg, 'xparam'), cfg.xparam='time'; end
if ~isfield(cfg, 'zparam'), cfg.zparam='avg'; end
elseif strcmp(data.dimord, 'rpt_chan_freq_time')
tmpcfg = [];
tmpcfg.trials = cfg.trials;
tmpcfg.jackknife= 'no';
data = freqdescriptives(tmpcfg, data);
if ~isfield(cfg, 'xparam'), cfg.xparam='time'; end
if ~isfield(cfg, 'yparam'), cfg.yparam='freq'; end
if ~isfield(cfg, 'zparam'), cfg.zparam='powspctrm'; end
(note: when cfg.trials='all' this doesn't apply)
the code for adjusting the trl should look something like this:
finding the trl (see e.g. appenddata.m):
% adjust the trial definition (trl) in case of trial selection
if ~strcmp(cfg.trials, 'all')
% try to locate the trial definition (trl) in the nested configuration
if isfield(data, 'cfg')
trl = findcfg(data.cfg, 'trl');
else
trl = [];
end
if isempty(trl)
% a trial definition is expected in each continuous data set
warning('could not locate the trial definition ''trl'' in the data structure');
else
cfg.trl=trl(cfg.trials,:);
end
end
adjusting the trl:
% adjust the trial definition (trl) if ~isempty(trl) && ~strcmp(cfg.trials, 'all') cfg.trl=trl(cfg.trials,:); end
% cfg.trials = 'all' or a selection given as a 1xN vector (default = 'all')
Find functions that use raw data:
grep -n datatype.*raw *.m
Find functions that already have cfg.trials option:
grep -n cfg.trials *.m
Share this page: