[FieldTrip] beamforming pipeline & comparing sources between groups of participants?

Ioanna Zioga i.zioga at qmul.ac.uk
Sat May 4 13:19:50 CEST 2019


Dear Vladimir and Mats (and fieldtrip community),

Thanks both so much for the insightful suggestions! As both of you noted, I need to convert the volume conduction model and the electrode model in the same unit. I feel I understand the analysis a bit better now (hopefully), and have improved the sourceanalysis code as per Mats's suggestions.

I have now managed to do the source analysis for one subject, but the source plots look a bit strange (see figure sourceanalysis.png attached). Therefore I have a few questions which could be relevant:

1) Does anyone have any idea why do the plots look so digitized? I used cfg.grid.resolution = 7 (units are mm). Is there any chance there is an incompatibility between my headmodel and the MRI template?
2) Is one contrasting method enough, i.e.: If I contrast the sources in the post-stimulus time window compared to a baseline, do I also need to do cfg.normalize in the calculation of the leadfield or calculate the Neural Activity Index?
3) Is it ok to compute the volume condution model in SPM, then use that to calculate the leadfield in fieldtrip, and then use a template MRI to just do the visualization of the sources (see pipeline below)?
4) Do I need to do cfg.reducerank when calculating the leadfield?

Here I'm adding my code, in case anyone could have a look and spot any mistakes/make suggestions! That would be extremely helpful.
Maybe it can also be of help to people who want to do the same analysis in the future.
After using SPM to create a volume conduction model in SPM, I moved to fieldtrip:

% Convert volume conduction model and electrodes from SPM
volsens = spm_eeg_inv_get_vol_sens(D, 1, 'MNI-aligned', 'inv', 'EEG');
vol1      = volsens.EEG.vol;
sens1   = volsens.EEG.sens;

% Calculate the cross-spectral density matrix of my EEG data, EEGft (after re-referencing to common average)
cfg = [];
cfg.method = 'mtmfft';
cfg.output = 'powandcsd';
cfg.foilim      = [22 22];
cfg.taper       = 'dpss';
cfg.tapsmofrq = 10;
cfg.keeptrials  = 'no';
cfg.keeptapers  = 'no';
cfg.toi = 0.6;
cfg.t_ftimwin = 0.4;
freq = ft_freqanalysis(cfg, EEGft);

% Convert all units to mm
sens1 = ft_convert_units(sens1, 'mm');
vol1    = ft_convert_units(vol1, 'mm');

% Plot brain, skull, and scalp [SEE FIGURE VOL_COND_MODEL ATTACHED]
figure; ft_plot_mesh(vol1.bnd(1), 'facecolor',[0.4 0.6 0.4], 'facealpha', 0.9, 'edgecolor', [1 1 1], 'edgealpha', 0.05); rotate3d on
hold on; ft_plot_mesh(vol1.bnd(2),'edgecolor','none','facealpha',0.4);
hold on; ft_plot_mesh(vol1.bnd(3),'edgecolor','none','facecolor',[0.2 0.2 0.2],'facealpha',0.3);

% Interactively aligned electrodes to head surface
cfg                    = [];
cfg.method       = 'interactive';
cfg.elec             = sens1;
cfg.headshape  = vol1.bnd(3); % scalp
sens1_aligned  = ft_electroderealign(cfg);

% plot scalp & sensors [SEE FIGURE ELEC_ALIGN ATTACHED]
figure; ft_plot_mesh(vol1.bnd,'edgecolor','none','facealpha',0.8,'facecolor',[0.6 0.6 0.8])
hold on; ft_plot_sens(sens1_aligned,'elecsize',30);
alpha 0.7; rotate3d on

% Calculate leadfield
cfg = [];
cfg.grid.resolution = 7;
cfg.inwardshift = -7;
cfg.unit = 'mm';
cfg.headmodel = vol1;
cfg.grad = sens1_aligned;
cfg.elec = sens1_aligned;
cfg.senstype = 'eeg';
grid = ft_prepare_leadfield(cfg, freq);

% plot leadfield and headmodel [SEE FIGURE LEADFIELD ATTACHED]
figure; hold on; ft_plot_mesh(grid.pos(grid.inside,:));
hold on; ft_plot_mesh(vol1.bnd(1));

% Beamforming
cfg = [];
cfg.headmodel = vol1;
cfg.grad      = sens1_aligned;
cfg.senstype  = 'eeg';
cfg.grid      = grid;
cfg.method    = 'dics';
cfg.frequency = [22 22];
cfg.dics.projectnoise   = 'yes';
cfg.dics.lambda         = '5%';
cfg.dics.keepfilter     = 'yes';
cfg.dics.realfilter     = 'yes';
sourceA = ft_sourceanalysis(cfg, freq);

% Plot results on an MRI template
load standard_mri;

% Interpolated sourceA to MRI
cfg                  = [];
cfg.parameter = 'pow';
sourceAint      = ft_sourceinterpolate(cfg, sourceA, mri);

% Plot source [SEE FIGURE SOURCEANALYSIS ATTACHED]
cfg = [];
cfg.method        = 'slice';
cfg.funparameter  = 'pow';
cfg.maskparameter = cfg.funparameter;
cfg.funcolorlim   = [0.0 2479475.3054];
cfg.opacitylim    = [0.0 1.2];
cfg.opacitymap    = 'rampup';
ft_sourceplot(cfg, sourceAint);

Please feel free to make any comments/suggestions on the above code and questions!
Any insight is extremely appreciated!

I think I'm getting there.. and luckily I'm -still- excited about it 😊

Thank you all so much in advance, have a great weekend!

Best,
Ioanna


________________________________
From: fieldtrip <fieldtrip-bounces at science.ru.nl> on behalf of Es, M.W.J. van (Mats) <M.vanEs at donders.ru.nl>
Sent: Thursday, May 2, 2019 11:03:39 AM
To: FieldTrip discussion list
Subject: Re: [FieldTrip] beamforming pipeline & comparing sources between groups of participants?


Dear Ioanna,



Indeed, these types of analysis are exciting, but complex! I have some suggestions for you. They might not solve your problem per se, but at least it should give you some insight in your analysis.



1)      As Vladimir suggested, make sure your headmodel and sourcemodel align and are of the same unit. Also, it might be better to look at source contrasts due to the center of the head bias (see http://www.fieldtriptoolbox.org/tutorial/beamformer/#source-analysis-without-contrasting-condition)

Localizing oscillatory sources using beamformer techniques - FieldTrip toolbox<http://www.fieldtriptoolbox.org/tutorial/beamformer/#source-analysis-without-contrasting-condition>
www.fieldtriptoolbox.org
Tags: tutorial meg freq source headmodel mri plot meg-language Localizing oscillatory sources using beamformer techniques Introduction. In this tutorial we will continue working on the dataset described in the preprocessing tutorials. Below we will repeat code to select the trials and preprocess the data as described in the first tutorials (trigger based trial selection, visual artifact ...



-          Your frequency analysis looks correct. Since dics sourceanalysis is done on a single frequency, you can use smoothing to still encompass an entire frequency range.

-          This means that in the sourceanalysis you don’t have to specify the [12 32] but could enter the center frequency: [22 22],  since the estimate at this frequency encompasses the entire range.

-          In your sourceanalysis you don’t have to specify cfg.latency. Your frequency estimate is based on this window already. The cfg.latency option is used when your frequency data is time-resolved (cfg.method = ‘mtmconvol’/’wavelet’ in ft_freqanalysis).

-          In your frequency analysis, there’s no need to keep trial information for sourceanalysis. As default, sourceanalysis will average over trials anyway. (trial information is only required if you use some kind of resampling procedure (like cfg.jackknife, cfg.bootstrap etc). (If you’d want to do single-trial analysis, you could multiply the spatial filter (from sourceanalysis) with channel-level single-trial frequency estimates. )

2)      Yes, you should do sourceanalysis separately for every participant.

3)      Take a look at ft_sourcegrandaverage

4)      Very good question, without a straightforward answer.

-          If you’ve already found a statistically significant effect at the channel level, there’s no need to do statistics at the source level anymore; you’ve already rejected the null-hypothesis. You use source analysis only to visualize and interpret the data.

-          If you think you can gain statistical sensitivity by going to the source level, you should think of some way to reduce the dimensionality of your data. If you would statistically test power at every grid point, you will probably lose any effect when doing multiple comparison correction. For example, you might know (from the literature) that if there would be an effect, it will most likely be in a specific ROI. Then you could choose to average power in this ROI and test this between groups.

Alternatively, you could define your own ROI based on for example the induced power effect over all subjects: find out which region has the highest power increase (i.e. from baseline) in this task in general (thus irrespective of condition). Use this region the then test differences between conditions.



Hope this helps!



All the best,

Mats



PhD candidate


Dynamic Connectivity


Donders Institute for Brain,

Cognition and Behaviour


e:


m.vanes at donders.ru.nl<mailto:m.vanes at donders.ru.nl>


a:


Kapittelweg 29, 6525 EN Nijmegen



p:


+31(0)24 36 68291












From: Ioanna Zioga <i.zioga at qmul.ac.uk>
Sent: woensdag 1 mei 2019 16:48
To: litvak.vladimir at gmail.com
Cc: fieldtrip at science.ru.nl
Subject: [FieldTrip] beamforming pipeline & comparing sources between groups of participants?



Dear Vladimir,



For anyone interested, I used SPM to make a template head model which I'm going to use to do beamforming in FT.

I have queries with regards to the source analysis pipeline I'm using in FT, as the results I get don't seem right.



Vladimir, following our previous email exchange (and thanks to your suggestions), I have now managed to compute the lead field matrix in FT (by removing eeglab and fieldtrip directories from the path, and adding spm's).



I want to contrast the sources of two groups of participants (high- vs. low-learners) in two frequency bands (low: 2.5-4.5 Hz; high: 12-32 Hz), from 0.20-1 sec post stimulus onset.



Here is my pipeline:



% Calculate the cross spectral density matrix (e.g., for the 12-32 Hz frequency band)

cfg                    = [];

cfg.method     = 'mtmfft';

cfg.output       = 'powandcsd';

cfg.foilim         = [22 22];

cfg.taper          = 'dpss';

cfg.tapsmofrq = 10;

cfg.keeptrials   = 'yes';

cfg.keeptapers = 'no';

cfg.toi                = 0.6;

cfg.t_ftimwin   = 0.4;

freq                    = ft_freqanalysis(cfg, EEGft);



% Source analysis using DICS beamformer

cfg                      = [];

cfg.headmodel = vol1;

cfg.grad             = sens1;

cfg.senstype     = 'eeg';

cfg.grid              = grid;

cfg.method       = 'dics';

cfg.frequency   = [12 32];

cfg.latency        = [0.2 1];

cfg.dics.projectnoise   = 'yes';

cfg.dics.lambda            = 0;

cfg.dics.keepfilter        = 'yes';

cfg.dics.realfilter          = 'yes';

sourceA                         = ft_sourceanalysis(cfg, freq);



% Plot sources

cfg                           = [];

cfg.method            = 'slice';

cfg.funparameter = 'pow';

ft_sourceplot(cfg, sourceA);



=> The source plots look weird though - they scale from 0 to x10^45, and are totally black.



1) Am I doing something wrong in the freqanalysis or the sourceanalysis?

2) Do I need to do the ft_sourceanalysis separately for each participant?

3) Is there a way to average the results of the source analysis over groups of participants?

4) Could you give any direction/resource on how to statistically compare the sources of different groups?



As you all know this is a very exciting but also not trivial analysis.. so I'd be extremely grateful for any help at this point, it'd be very much appreciated! Thanks so much in advance!



Best,

Ioanna


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20190504/e27d3114/attachment-0002.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sourceanalysis.png
Type: image/png
Size: 324068 bytes
Desc: sourceanalysis.png
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20190504/e27d3114/attachment-0008.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vol_cond_model.png
Type: image/png
Size: 107279 bytes
Desc: vol_cond_model.png
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20190504/e27d3114/attachment-0009.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: elec_align.png
Type: image/png
Size: 14879 bytes
Desc: elec_align.png
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20190504/e27d3114/attachment-0010.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: leadfield.png
Type: image/png
Size: 123269 bytes
Desc: leadfield.png
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20190504/e27d3114/attachment-0011.png>
-------------- next part --------------
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202


More information about the fieldtrip mailing list