[FieldTrip] how to transform cfg.headmodel to an atlas in MNI space
Evan Hutcheon
evan_hutcheon at sfu.ca
Mon Aug 29 00:11:06 CEST 2022
Hi everyone,
I was wondering if anyone could help me
perform a transformation from
cfg.headmodel = headmodel;
to an atlas in the MNI space?
%% create a head model || vol is standard bem from FT
load('/rcg/bcni/users/Evan/fieldtrip-20190912/template/headmodel/standard_bem.mat')
headmodel = vol;
headmodel = ft_convert_units(headmodel, 'm');
cfg=[];
cfg.resolution = .015; %headmodel resolution(was 0.008)
cfg.headmodel = headmodel;
source_model = ft_prepare_sourcemodel(cfg);
%% align electrodes to head model
elec = ft_read_sens('standard_1020.elc');
elec = ft_convert_units(elec, 'm');
scalp_index = 1; %scalp is 1
cfg = [];
cfg.method = 'project'; % onto scalp surface
cfg.headshape = headmodel.bnd(scalp_index); % scalp surface
elec_realigned = ft_electroderealign(cfg,elec);
% end
%% align electrodes
% for subject
[v, ix, ixx] = intersect(elec_realigned.label, interp.label);
elecICA = elec_realigned;
elecICA.chanpos = elecICA.chanpos(ix,:);
elecICA.chantype = elecICA.chantype(ix,:);
elecICA.chanunit = elecICA.chanunit(ix,:);
elecICA.elecpos = elecICA.elecpos(ix,:);
elecICA.label = elecICA.label(ix);
elecICA.tra = elecICA.tra(ix, ix); %cant find
%% leadfield
cfg = [];
cfg.sourcemodel = source_model; %% where are the sources?
cfg.headmodel = headmodel; %% how do currents spread?
cfg.elec = elecICA;% how do sources and sensors connect?
cfg.normalize = 'yes'; %was no
leadfield = ft_prepare_leadfield(cfg,interp);
%% source estimation via LCMV
cfg = [];
cfg.trials = 'all';
cfg.channel = 'eeg';
cfg.covariance = 'yes';
cfg.covariancewindow = 'all';
cfg.keeptrials = 'yes';
cfg.removemean = 'yes';
timelock = ft_timelockanalysis(cfg, interp);
%LCMV BEAMFORMER to create spatial filter
cfg = [];
cfg.method = 'lcmv';
cfg.grid = leadfield;
cfg.headmodel = headmodel;
cfg.elec = elecICA;
cfg.lcmv.lambda = '5%';
cfg.lcmv.projectmom = 'yes';
cfg.lcmv.keepfilter = 'yes';
cfg.lcmv.keepori = 'yes';
cfg.lcmv.projectnoise = 'yes';
sfilter = ft_sourceanalysis(cfg, timelock); % use this for your source reconstruction
%% Source analysis
cfg = [];
cfg.trials = 'all';
cfg.trials = any(interp.trialinfo == [5],2);%
cfg.covariance = 'yes';
cfg.covariancewindow = 'all';
cfg.keeptrials = 'yes';
cfg.removemean = 'yes';
timelock_trl_left = ft_timelockanalysis(cfg, interp);
cfg = [];
cfg.trials = 'all';
cfg.trials = any(interp.trialinfo == [6],2);%
cfg.covariance = 'yes';
cfg.covariancewindow = 'all';
cfg.keeptrials = 'yes';
cfg.removemean = 'yes';
timelock_trl_right = ft_timelockanalysis(cfg, interp);
% no need at this point to generate and save the time series
cfg = [];
cfg.method = 'lcmv';
cfg.grid = leadfield;
cfg.headmodel = headmodel;
cfg.elec = elecICA;
cfg.lcmv.lambda = '5%';
cfg.lcmv.projectmom = 'yes';
cfg.rawtrial = 'yes';
cfg.grid.filter = sfilter.avg.filter; %sfilter taken from before
cfg.lcmv.projectnoise = 'yes'; % noise estimation from the single value decomposition
cfg.lcmv.keepmom = 'yes'; % saves the time series
cfg.lcmv.fixedori = 'yes';
cfg.keeptrials = 'yes'; %'no' or 'yes
cfg.keepleadfield = 'yes';
cfg.keepfilter = 'no';
source_left = ft_sourceanalysis(cfg,timelock_trl_left);
source_right = ft_sourceanalysis(cfg,timelock_trl_right)
Cheers,
Evan
Evan Hutcheon
PhD Candidate|Dr. Doesburg laboratory
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20220828/0a4100ac/attachment.htm>
More information about the fieldtrip
mailing list