[FieldTrip] EEG beamformer source analyses

Schoffelen, J.M. (Jan Mathijs) jan.schoffelen at donders.ru.nl
Tue Sep 15 11:15:38 CEST 2020


Dear Patrick,

Just to be sure: can you get the latest release version of the code and try whether this error persists (e.g. http://github.com/fieldtrip/fieldtrip/releases/tag/20200911)? The reason I ask is that your reported line number (i.e. line 217 in ft_sourcenalasysis) that throws the error does not match the current state of the code. I’d like to be sure that this is a genuine error, or that you happen to have stumbled upon a dysfunctional version (for which we humbly apologize :) ).

Best wishes,
Jan-Mathijs


On 15 Sep 2020, at 10:55, Patrick Wiegel <patrick.wiegel at sport.uni-freiburg.de<mailto:patrick.wiegel at sport.uni-freiburg.de>> wrote:

Dear Fieldtrip community,

I am a PhD student from Germany and I am working with EEG data. I would like to do Beamformer source analyses on power data.

I don’t have individual MRIs or related electrode positions available, so I am taking the standard MRI and BEM headmodel from the fieldtrip templates. Doing the source_analyses, I am getting an error message. Can anyone tell me if I missed something and what the reason for that error is? The error appears when running the last part of the script ft_sourceanalyses:



the input is freq data with 64 channels, 1 frequencybins and no timebins
Undefined function or variable 'fieldname'.

Error in ft_checkconfig (line 307)
    for i=1:length(fieldname)

Error in ft_sourceanalysis (line 217)
cfg = ft_checkconfig(cfg, 'createtopcfg', cfg.method);

Error in BEAMformer (line 116)
sourceAll = ft_sourceanalysis(cfg, frequ_all);


I added my code below. I would appreciate any help. I added information on my existing variables below the code.

Best, Patrick

%% import EEG data
EEG_Data = eeglab2fieldtrip( EEG, 'raw', 'none' );

%% define trials for frequency analyses
cfg = [];
cfg.trials = Indexes_correct{1, 1};
cfg.toilim = [0.25 0.55];
data_fed_correct = ft_redefinetrial(cfg, EEG_Data);


cfg = [];
cfg.trials = Indexes_incorrect{1, 1};
cfg.toilim = [0.25 0.55];
data_fed_incorrect = ft_redefinetrial(cfg, EEG_Data);

%% run frequenc analyses
cfg = [];
cfg.method    = 'mtmfft';
cfg.output    = 'powandcsd';
cfg.tapsmofrq = 4;
cfg.foilim    = [25 25];
frequ_correct = ft_freqanalysis(cfg, data_fed_correct);

cfg = [];
cfg.method    = 'mtmfft';
cfg.output    = 'powandcsd';
cfg.tapsmofrq = 4;
cfg.foilim    = [25 25];
frequ_incorrect = ft_freqanalysis(cfg, data_fed_incorrect);

cfg = [];
cfg.method    = 'mtmfft';
cfg.output    = 'powandcsd';
cfg.tapsmofrq = 4;
cfg.foilim    = [25 25];
frequ_all = ft_freqanalysis(cfg,EEG_Data);


%% load MRI and BEM templates
load('/Users/patrickwiegel/Documents/MATLAB/Scripts/2020/TF_Data/fieldtrip-20200603/template/headmodel/standard_bem.mat')
load('/Users/patrickwiegel/Documents/MATLAB/Scripts/2020/TF_Data/fieldtrip-20200603/template/headmodel/standard_mri.mat')

%% segment mri
cfg = [];
cfg.write      = 'no';
[segmentedmri] = ft_volumesegment(cfg, mri);

disp(segmentedmri)
%%
mri = ft_volumereslice(cfg, segmentedmri);
display(mri)


%% align electrodes
load('elec_aligned')
elec_aligned = ft_convert_units(elec_aligned, 'cm');
vol = ft_convert_units(vol, 'cm'); % Convert the vol to cm, because the CTF convenction is to express everything in cm.

%%
[headmodel, elec_aligned]=ft_prepare_vol_sens (vol,elec_aligned);

cfg           = [];
cfg.method    = 'interactive';
cfg.elec      = elec_aligned;
cfg.headshape = headmodel.bnd(1);
elec_aligned  = ft_electroderealign(cfg);

%%
% construct the dipole grid in the template brain coordinates
% the negative inwardshift means an outward shift of the brain surface for inside/outside detection
cfg              = [];
cfg.resolution   = 1;
cfg.tight        = 'yes';
cfg.inwardshift  = -1.5;
cfg.headmodel    = headmodel;
sourcemodel    = ft_prepare_sourcemodel(cfg);

%%
cfg              = [];
cfg.method       = 'dics';
cfg.frequency    = 25;
cfg.sourcemodel  = sourcemodel;
cfg.headmodel    = headmodel;
cfg.elec         = elec_aligned;
cfg.dics.projectnoise = 'yes';
cfg.dics.lambda       = '5%';
cfg.dics.keepfilter   = 'yes';
cfg.dics.realfilter   = 'yes';
sourceAll = ft_sourceanalysis(cfg, frequ_all);





sourcemodel =

  struct with fields:

       dim: [17 22 18]
       pos: [6732×3 double]
      unit: 'cm'
    inside: [6732×1 logical]
       cfg: [1×1 struct]





elec_aligned =

  struct with fields:

        chanpos: [64×3 double]
       chantype: {64×1 cell}
       chanunit: {64×1 cell}
        elecpos: [64×3 double]
    homogeneous: [4×4 double]
          label: {1×64 cell}
            tra: [64×64 double]
           type: 'eeg1010'
           unit: 'cm'
            cfg: [1×1 struct]





headmodel =

  struct with fields:

                    bnd: [1×3 struct]
                   cond: [0.3300 0.0041 0.3300]
                    mat: [64×3000 double]
                   type: 'dipoli'
                   unit: 'cm'
           skin_surface: 1
    inner_skull_surface: 3
                 source: 3


Patrick Wiegel
Department of Sport and Sport Science

University of Freiburg
Sandfangweg 4
79117 Freiburg i. Br .

phone: +49 (0)761/ 203-4550
email: patrick.wiegel at sport.uni-freiburg.de<mailto:patrick.wiegel at sport.uni-freiburg.de>
web: www.sport.uni-freiburg.de<http://www.sport.uni-freiburg.de>

_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202

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


More information about the fieldtrip mailing list