Differences

This shows you the differences between two versions of the page.

Link to this comparison view

development:trialselect [2009/10/27 15:08]
131.174.45.7
development:trialselect [2017/08/17 11:21]
Line 1: Line 1:
- 
-====== Implement trial selection option ====== 
- 
-Consistent implementation of option for trial selection in all relevant functions (such as plotting functions, functions that handle raw data, etc.). 
- 
-===== Objectives ===== 
- 
-  * implement configuration option for doing trial selection in all relevant functions 
-  * consistent implementation and documentation 
- 
- 
-===== Step 1: get an overview of all functions for which this is relevant ===== 
- 
-  * functions that use raw data 
-  * functions that (could) use data with an '​rpt'​ dimension 
-  * functions where this has already been implemented 
- 
----- 
-== Functions that use raw data: == 
- 
-  * preprocessing.m (when called with preprocessed data) -done- 
-  * combineplanar.m ​  ​-done- 
-  * megplanar.m ​  ​-done- 
-  * megrealign.m ​  ​-done- 
-  * megrepair.m ​  ​-done- 
-  * scalpcurrentdensity.m ​  ​-done- 
-  * rejectvisual.m ​  ​-done- 
-  * redefinetrial.m ​  ​-done- 
-  * resampledata.m ​  ​-done- 
-  * timelockanalysis.m ​  ​-done- 
-  * freqanalysis.m ​  ​-done- 
- 
- 
-== Functions that (could) use data with an '​rpt'​ dimension: == 
-  * freqdescriptives.m ​  ​-done- 
- 
-  * singleplotER.m ​  ​-done- 
-  * singleplotTFR.m ​  ​-done- 
-  * topoplotER.m ​  ​-done- 
-  * topoplotTFR.m ​  ​-done- 
-  * multiplotER.m ​  ​-done- 
-  * multiplotTFR.m ​  ​-done- 
- 
- 
-== Functions where this has already been implemented:​ == 
- 
-  * componentanalysis.m ​  ​-done- 
-  * nonlinearassociation.m ​  ​-done- 
- 
- 
-How it's currently implemented in these functions: 
- 
-<​code>​ 
-%   ​cfg.trials ​      = '​all'​ or a selection like 1:10 (default = '​all'​) 
-</​code>​ 
- 
-<​code>​ 
-% set the defaults 
-if ~isfield(cfg,​ '​trials'​), ​  ​cfg.trials = '​all'; ​ end 
-</​code>​ 
- 
-<​code>​ 
-% 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 
-</​code>​ 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
-===== Step 2: develop and implement solution ===== 
- 
-  * ensure consistency in solution 
-  * relevant fields (trl) should be adjusted accordingly 
-  * documentation 
- 
----- 
-== Ensure consistency in solution: == 
- 
-__For raw data input functions (implement before '​Ntrials=...'​ or equivalent):​__ 
- 
-<​code>​ 
-% set the defaults 
-if ~isfield(cfg,​ '​trials'​), ​  ​cfg.trials = '​all'; ​ end 
-</​code>​ 
-<​code>​ 
-% 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 
-</​code>​ 
- 
-__For rpt data input functions:​__ 
- 
-<​code>​ 
-% set the defaults 
-if ~isfield(cfg,​ '​trials'​), ​  ​cfg.trials = '​all'; ​ end 
-</​code>​ 
- 
-  * for topoplotER: 
-<​code>​ 
-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 
-</​code>​ 
- 
-  * for singleplotER,​ multiplotER (varargin): 
-<​code>​ 
-  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 
-</​code>​ 
- 
-  * for topoplotER, singleplotTFR,​ multiplotTFR:​ 
-<​code>​ 
-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 
-</​code>​ 
- 
-== Relevant fields (trl) should be adjusted accordingly:​ == 
- 
-(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):​ 
-<​code>​ 
-% 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 
-</​code>​ 
- 
-adjusting the trl: 
-<​code>​ 
-% adjust the trial definition (trl) 
-if ~isempty(trl) && ~strcmp(cfg.trials,​ '​all'​) 
-  cfg.trl=trl(cfg.trials,:​);​ 
-end 
-</​code>​ 
- 
-== Documentation:​ == 
- 
-<​code>​ 
-%   ​cfg.trials ​      = '​all'​ or a selection given as a 1xN vector (default = '​all'​) 
-</​code>​ 
- 
-===== Appendix: useful linux commands ===== 
- 
-Find functions that use raw data: 
-<​code>​ 
-grep -n datatype.*raw *.m 
-</​code>​ 
- 
-Find functions that already have cfg.trials option: 
-<​code>​ 
-grep -n cfg.trials *.m 
-</​code>​