[FieldTrip] ft_virtualchannel question

Schoffelen, J.M. (Jan Mathijs) janmathijs.schoffelen at donders.ru.nl
Thu Aug 24 08:33:31 CEST 2023


Hi Michael,

Yes, this sounds correct.

If I do sum(atlas.tissue(:)~=0)./prod(atlas.dim), I get ~0.15, i.e. 15%. This means that 15% of the voxels in the original volume are labelled.
Best wishes,
Jan-Mathijs


On 23 Aug 2023, at 22:58, Michael Glassen via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>> wrote:

Hi all,

I am using the template atlas for the brainetome atlas included with fieldtrip, and using it along with ft_virtualchannel to parcellate my source data(for eeg). My steps are below:


  1.  import eeg, project electrodes onto default headmodel
  2.  create leadfield with 4mm resolution
  3.  compute average sources, save filters
  4.  interpolate brainetome atlas onto computed leadfield using ft_sourceinterpolate
  5.  compute trial by trial source data using ft_virutal channel with eeg data, source filters, and interpolated atlas.

I believe I have everything working, but ft_virtualchannel shows that I am only segmenting ~15% of the total volume, with each roi ranging from .01 to .15% of total volume(246 rois total).

Does this seem correct, or did I make a mistake with interpolating the atlas onto my leadfield?

Thank you!

Best,
Michael Glassen

Source code below:

headmodel = vol;
atlas = ft_read_atlas(atlasLoc);
EEG = pop_loadset(eegLoc);
%
EEG  = pop_basicfilter( EEG,  1:size(EEG.data,1) , 'Boundary', 'boundary', 'Cutoff', [ 1 100],'Design', 'butter', 'Filter', 'bandpass', 'Order',  2, 'RemoveDC', 'on' );
EEG = eeg_regepochs(EEG,'recurrence',1,'limits',[0 1],'rmbase',NaN);
EEG = pop_iclabel(EEG,'default');
EEG = pop_icflag(EEG, [NaN NaN;0.75 1;0.75 1;NaN NaN;NaN NaN;NaN NaN;NaN NaN]);
EEG = pop_subcomp(EEG,[],0,0);
header = eeglab2fieldtrip(EEG,'preprocessing','none');
header.hdr.chanunit = repmat({'uV'},[size(EEG.data,1),1]);
%% Seperate EEG and EMG data
eegChans = {};
for i = 1:size(EEG.data,1)
    eegChans = [eegChans header.label{i}];
end
%
% emgChans = {};
% for i = 65:EEG.nbchan
%     emgChans = [emgChans header.label{i}];
% end
cfg = [];
cfg.channel = eegChans;
eegData = ft_selectdata(cfg,header);
% cfg = [];
% cfg.channel = emgChans;
% %
% emgData = ft_selectdata(cfg,header);
tempElec = ft_read_sens(electrodePos);
newElec = tempElec;
for i = 1:length(eegData.label)
    checker = 0;
    for i2 = 1:length(tempElec.label)
        if strcmpi(eegData.label{i},tempElec.label{i2})
            checker = 1;
            newElec.chanpos(i,:) = tempElec.chanpos(i2,:);
            newElec.chantype{i} = tempElec.chantype{i2};
            newElec.chanunit{i} = tempElec.chanunit{i2};
            newElec.elecpos(i,:) = tempElec.elecpos(i2,:);
            newElec.label{i} = tempElec.label{i2};
        end
    end
    if checker == 0
        eegData.elec.label{i}
    end
end
newElec.chanpos(length(eegData.label)+1:end,:) = [];
newElec.chantype(length(eegData.label)+1:end) = [];
newElec.chanunit(length(eegData.label)+1:end) = [];
newElec.elecpos(length(eegData.label)+1:end,:) = [];
newElec.label(length(eegData.label)+1:end) = [];
eegData.elec = newElec;
%% Project electrodes to scalp
if strcmp(headmodel.type, 'bemcp')
    scalp_index = 3;
elseif strcmp(headmodel.type, 'dipoli')
    scalp_index = 1;
end
cfg = [];
cfg.method = 'project'; % onto scalp surface
cfg.headshape = headmodel.bnd(scalp_index); % scalp surface
eegData.elec = ft_electroderealign(cfg, eegData.elec);
cfg = [];
cfg.headmodel = headmodel;
cfg.elec = eegData.elec;
cfg.grid.resolution = 4;
cfg.grid.unit       = 'mm';
cfg.channel = 'all';
grid = ft_prepare_leadfield(cfg);
cfg = [];
cfg.covariance = 'yes';
cfg.covariancewindow = 'all';
timelock_allexp = ft_timelockanalysis(cfg, eegData);
cfg = [];
cfg.covariance = 'yes';
cfg.covariancewindow = 'all';
cfg.keeptrials  = 'yes';
timelock_allexp_all = ft_timelockanalysis(cfg, eegData);
%General source localisation
cfg = [];
cfg.headmodel = vol;
cfg.elec = timelock_allexp.elec;
cfg.grid = grid;
cfg.method = 'lcmv';
cfg.lcmv.fixedori = 'yes';  %Project onto largest variance orientation
cfg.lcmv.keepfilter = 'yes'; %Keep the beamformer weights
cfg.lcmv.lambda = '5%'; %Regularise a little
source_allexp = ft_sourceanalysis(cfg, timelock_allexp);
cfg = [];
cfg.method        = 'nearest';
cfg.parameter = 'tissue';
grid2 = ft_sourceinterpolate(cfg,atlas,grid);
grid2.tissue = fix(grid2.tissue);
grid2.tissuelabel = atlas.tissuelabel;
cfg = [];
cfg.parcellation = 'tissue';
cfg.method = 'svd';
roiData = ft_virtualchannel(cfg,timelock_allexp_all,source_allexp,grid2);

_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!8MfiFIKtdQjMkyMZdUcN7LmshWPRfmD4iH9-ablz_WARh4VUTy1Q4Z6Rf5hkNoxCt_1GwDE6GE75pQLjQVrBaYw5Gq8tPGnJtl-UkA$ 

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


More information about the fieldtrip mailing list