

ds = sprintf('c:/MEG/HM_HiN_CueLInvNT-fEOG.ds');

f1 = 8.; f2=14.0;
smo = 2.;
r = .75;


cfg = [];
cfg.dataset = ds;
cfg.trialdef.trigger  = 4;
cfg.trialdef.prestim  = -0.0;
cfg.trialdef.poststim = 0.35;
cfg.blc = 'yes';
data = preprocessing(cfg);

%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cfg.channel            = 'all';

cfg.latency            = [-0.0 0.25]
cfg.covariance         = 'yes'
%cfg.covariancewindow   = [-0.0 0.25]
cfg.keeptrials         = 'yes'
cfg.vartrllength       = 2;
cfg.blc                = 'no'
cfg.blcwindow          = [-0.0 0.25]
cfg.bpfilter           = 'yes'
cfg.bpfreq             = [8 14]
fg.bpfiltord          = 4
cfg.bpfilttype         = 'fir'
[timelock] = timelockanalysis(cfg,data)
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


cfg = [];
cfg.method   = 'lcmv';
cfg.grid.pos = [1 4 1; 6 1 2];
%cfg.singletrial = 'yes';
cfg.rawtrial    = 'yes'
cfg.keepfilter    = 'yes'
cfg.hdmfile = strcat(ds, '/localSpheres.hdm');
[source] = sourceanalysis(cfg, timelock)


cfg = [];
cfg.method = 'fft';
cfg.output = 'powandcsd';
cfg.tapsmofrq = smo;
cfg.foilim = [f1 f2];
%cfg.pad = 2.;
%cfg.keeptrials = 'yes';
cfg.sgncmb = 'all';
[freq] = freqanalysis(cfg, source);

[source] = sourcedescriptives([], source);
%[source] = source2full(source);

% cfg = [];
% cfg.xgrid = -10:r:10;
% cfg.ygrid = -10:r:10;
% cfg.zgrid = -2:r:14;
% [mri] = read_fcdc_mri('c:/MEG/ucsf_hm_orig_axial.mri');
% cfg.downsample = 1;
% cfg.parameter = 'coh';
% cfg.funparameter = 'coh';
% sourceInterp = sourceinterpolate(cfg, source, mri);
% figure; sliceinterp(cfg, sourceInterp);
%
%