# [FieldTrip] granger causality on beamformer data

Julian Keil julian.keil at gmail.com
Wed May 28 10:13:03 CEST 2014

```Hi Tyler,

sorry if my description was a bit brief, so here's a bit more information.

You need:
1) Virtual Electrodes (you have your 1400 electrodes, so I assume you got that far) and the .pos field with the XYZ-coordinates of the virtual electrodes.
2) A grid with a grid point for each voxel of the MNI brain (That's what you do using ft_prepare_sourcemodel)
3) A "inside" definition for your VOI (That's what you do with ft_volumelookup).

Now, given that your steps 1-3 all are in the same coordinate system, you can simply use pythagoras (s = sqrt((X2-X1)^2 + (Y2-Y1)^2 + (Z2-Z1)^2) to find the minimum distance between each virtual channels of step 1 and all grid points of step 2.

From the min (find the minimum distance) step, you can get the index of closest virtual channel to each grid point. You then apply this index to the output of ft_volumelookup and you have the virtual electrodes inside your ROI.

Best,

Julian

Am 28.05.2014 um 09:05 schrieb Tyler Grummett:

> I then do the following:
>
> % look up which virtual channels correspond to particular areas
>             % of the brain
>             cfg = [];
>             cfg.atlas = afni;
>             cfg.inputcoord = 'mni';
>             labels = ft_volumelookup( cfg, source);
>
>             % how many sources found in grey matter
>             [tmp ind] = sort(labels.count,1,'descend');
>             sel = find(tmp);
>             for j = 1:length(sel)
>                 found_areas{j,1} = [num2str(labels.count(ind(j))) ': ' labels.name{ind(j)}];
>             end​
>
> However I dont know how to find out what sources are the 'found_areas', after that I dont know how to cluster the source in a particular area.
>
> Tyler
>
>
> *************************
>
> Tyler Grummett ( BBSc, BSc(Hons I))
> PhD Candidate
> Brain Signals Laboratory
> Flinders University
> Rm 5A301
> Ext 66124
> From: fieldtrip-bounces at science.ru.nl <fieldtrip-bounces at science.ru.nl> on behalf of Tyler Grummett <tyler.grummett at flinders.edu.au>
> Sent: Wednesday, 28 May 2014 3:53 PM
> To: FieldTrip discussion list
> Subject: Re: [FieldTrip] granger causality on beamformer data
>
> Hello Julian,
>
> I think I got a few steps further into what I am trying to do, except I dont know whether I have done the correct thing or not, could you check it?
>
>             % interpolate sources
>             mri = ft_volumereslice([], mri);
>
>             % read in atlas from fieldtrip template
>
>             % construct grid that lies only in grey matter
>             cfg = [];
>             cfg.mri = mri;
>             cfg.grid.warpmni = 'yes';
>             cfg.grid = afni;
>             grid = ft_prepare_sourcemodel( cfg);
>
>             % Source Analysis: without contrasting condition
>             cfg = [];
>             cfg.channel = 'EEG';
>             cfg.method = 'lcmv';
>             cfg.grid = grid;
>             cfg.vol = vol;
>             cfg.keepfilter = 'yes';
>             source = ft_sourceanalysis( cfg, timelock);
> ​
> Tyler
>
> *************************
>
> Tyler Grummett ( BBSc, BSc(Hons I))
> PhD Candidate
> Brain Signals Laboratory
> Flinders University
> Rm 5A301
> Ext 66124
> From: fieldtrip-bounces at science.ru.nl <fieldtrip-bounces at science.ru.nl> on behalf of Tyler Grummett <tyler.grummett at flinders.edu.au>
> Sent: Wednesday, 28 May 2014 10:36 AM
> To: FieldTrip discussion list
> Subject: Re: [FieldTrip] granger causality on beamformer data
>
> ​Hey Julian,
>
> Having trouble making sense of that link. Am I correct in saying that I should be downloading the brede toolbox? because it is taking a long time, plus the functions in the brede toolbox dont make a lot of sense.
>
> Would you use ft_prepare_sourcemodel instead of ft_prepare_leadfield? or would you run in before running it?
>
> Regards,
>
> Tyler
>
> *************************
>
> Tyler Grummett ( BBSc, BSc(Hons I))
> PhD Candidate
> Brain Signals Laboratory
> Flinders University
> Rm 5A301
> Ext 66124
> From: fieldtrip-bounces at science.ru.nl <fieldtrip-bounces at science.ru.nl> on behalf of Julian Keil <julian.keil at gmail.com>
> Sent: Wednesday, 28 May 2014 1:55 AM
> To: FieldTrip discussion list
> Subject: Re: [FieldTrip] granger causality on beamformer data
>
> Hi Tyler,
>
> I can't comment on the usefulness of directionality between 1400 sources, but keep in mind, that you would have to compute something in the range of 1400*1400
> connections, so I hope you have a fast computer.
>
> As for the regions, in case you want to use anatomically defined regions, you an either use the atlases (atlanti? atlae?) that come with fieldtrip or generate a mask from this website:http://neuro.imm.dtu.dk/services/jerne/ninf/voi.html
>
> The general idea is to build a grid with a gridpoint per voxel of your MRI using ft_prepare_sourcemodel. Then you can check which of your virtual channels is closest to the voxel-gridpoints and thus select the virtual channels that are inside your ROI.
>
> In the first case, you can use ft_volumelookup to find the voxels corresponding to your ROI. In the latter case you can just use the mask and check which voxels are 1 (= inside your ROI).
>
> I hope that helps, if you have specific questions, feel free to ask.
>
> Best,
>
> Julian
>
>
> On Tue, May 27, 2014 at 7:44 AM, Tyler Grummett <tyler.grummett at flinders.edu.au> wrote:
> ​Hello fieldtrippers,
>
> I was just wondering whether it would be sensible to do granger causality on all 1400 virtual channels, as calculated using beamformer.
>
> Or should you do a PCA reduction of some description beforehand.
>
> I was also wondering how to create regions of interest. Some of my colleagues think that we should use some kind of spatial ICA technique.
>
> Im open to all suggestions.
>
> Tyler
>
> *************************
>
> Tyler Grummett ( BBSc, BSc(Hons I))
> PhD Candidate
> Brain Signals Laboratory
> Flinders University
> Rm 5A301
> Ext 66124
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20140528/a6b324e7/attachment-0002.html>
```