[FieldTrip] DICS for EEG

Konstantinos Tsilimparis konstantinos.tsilimparis at outlook.com
Fri Sep 6 02:10:45 CEST 2024


Hi Anwar,

To apply the neural activity index (NAI) and avoid center-of-head bias, you'll need to introduce noise into your data. Use cfg.relnoise in ft_dipolesimulation to add noise.


Additionally, your sourcemodel (standard_sourcemodel3d5mm.mat) doesn't ''fit'' your headmodel. You can check this with:
figure;
ft_plot_sens(elec, 'label', 'label');
ft_plot_headmodel(headmodel);
ft_plot_mesh(sourcemodel);

So, I recommend creating your own sourcemodel and subsequently computing the forward model. For example:
cfg = [];
cfg.grad = elec;
cfg.headmodel = headmodel;
cfg.reducerank = 2;
cfg.resolution = 5; % automatic sourcemodel generation
cfg.sourcemodel.unit = 'mm';
leadfield = ft_prepare_leadfield(cfg);


Lastly, for better visualization of the source activity, you can set a lower limit on your colorbar:
maxval = max(sourceNAIInt.pow, [], 'all');

cfg = [];
cfg.method = 'ortho';
cfg.funparameter = 'pow';
cfg.maskparameter = cfg.funparameter;
cfg.funcolorlim = [<> maxval]; % adjust as needed
cfg.opacitylim = [<> maxval];  % adjust as needed
ft_sourceplot(cfg, sourceNAIInt);

Have fun with your simulations!

Best,
Konstantinos


From: fieldtrip <fieldtrip-bounces at science.ru.nl> On Behalf Of Anwar, Abdul Rauf via fieldtrip
Sent: Tuesday, September 3, 2024 6:26 PM
To: fieldtrip at science.ru.nl
Cc: Anwar, Abdul Rauf <aanwar at ukaachen.de>
Subject: [FieldTrip] DICS for EEG


Hi
I am trying to use the DICS method on the simulated EEG data. I have used template head model and source model. However, I am still unable to find the source in the correct position. I have also ensured that electrodes are well aligned with the head model. Below given is the script. Any further directions to pursue will be appreciated.
Thanks

% Add FieldTrip path and set defaults
addpath('C:\ToolBoxes\fieldtrip-20240110');
ft_defaults;
frequency =  10; % Frequency of interest
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Create template head model and source model and lead field matrix
mri = ft_read_mri('C:\ToolBoxes\fieldtrip-20240110\template\headmodel\standard_mri.mat');
cfg = [];
segmented_mri = ft_volumesegment(cfg, mri);

headmodel = load('C:\ToolBoxes\fieldtrip-20240110\template\headmodel\standard_bem.mat');  % Load a standard BEM model
headmodel=headmodel.vol;
sourcemodel=load('C:\ToolBoxes\fieldtrip-20240110\template\sourcemodel\standard_sourcemodel3d5mm.mat');
sourcemodel=sourcemodel.sourcemodel;
elec = ft_read_sens('C:\ToolBoxes\fieldtrip-20240110\template\electrode\standard_1020.elc');
cfg = [];
cfg.grid = sourcemodel;
cfg.elec = elec;            % Standard electrode positions (e.g., 10-20 system)
cfg.headmodel = headmodel;
cfg.reducerank = 2;         % Reduce rank for EEG
leadfield = ft_prepare_leadfield(cfg);

%%%%%%%%%%%%%%%%%%%
% Create simulated data
cfg = [];
cfg.ntrials = 10;
cfg.triallength = 10;
cfg.fsample = 1000;
cfg.dip.unit = 'mm';
cfg.dip.pos = [-40 -20 50]; % left motor cortex
cfg.dip.mom = cfg.dip.pos/norm(cfg.dip.pos); % radial
cfg.dip.frequency = frequency;
cfg.elec = elec;
cfg.headmodel = headmodel;
data = ft_dipolesimulation(cfg);

%figure
%ft_plot_dipole(cfg.dip.pos, cfg.dip.mom, 'unit', 'mm')
figure
ft_plot_sens(elec, 'label', 'label');
ft_plot_headmodel(headmodel);

%%%%%%%%%%%%%%%%%%%
% Create reference channel for coherence
trial = cell(size(data.trial));
for k = 1:numel(trial)
    trial{k} = sin(2.*pi.*frequency.*data.time{k});
end
refdata.trial = trial;
refdata.time  = data.time;
refdata.label = {'refchan'};
data          = ft_appenddata([], data, refdata);
%%%%%%%%%%%%%%%%%%%
% Time frequency analysis
cfg = [];
cfg.method    = 'mtmfft';
cfg.output    = 'powandcsd';
cfg.tapsmofrq = 4;
cfg.foilim    = [frequency frequency];
freq = ft_freqanalysis(cfg, data);
%%%%%%%%%%%%%%%%%%%%
% DICS source analysis
cfg = [];
cfg.method              = 'dics';
cfg.frequency           = frequency;
cfg.grid                = leadfield;
cfg.headmodel           = headmodel;
cfg.dics.projectnoise   = 'yes';
cfg.dics.lambda         = '10%';
cfg.dics.keepfilter     = 'yes';
cfg.dics.realfilter     = 'yes';
cfg.channel             = 'EEG';
cfg.senstype            = 'eeg';
cfg.refchan           = {'refchan'};
cfg.elec                = elec;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Plotting the source
source = ft_sourceanalysis(cfg, freq);
sourceNAI = source;
sourceNAI.avg.pow = source.avg.pow ./ source.avg.noise;

cfg = [];
cfg.downsample = 2;
cfg.parameter = 'pow';
sourceNAIInt = ft_sourceinterpolate(cfg, sourceNAI , mri);

maxval = max(sourceNAIInt.pow, [], 'all');
cfg = [];
cfg.method = 'ortho';
cfg.funparameter = 'pow';
cfg.funcolormap = 'cool';
ft_sourceplot(cfg, sourceNAIInt);

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20240906/f6f0df8a/attachment.htm>


More information about the fieldtrip mailing list