# [FieldTrip] Source Reconstruction using Openmeeg method

Johanna Zumer johanna.zumer at gmail.com
Mon May 27 15:12:27 CEST 2013

```Hi Mushfa,

The values inside grid_*.leadfield are the ones that need to be
concatenated, per grid position.   So the first thing to do is figure out
which rows in grid_eeg.pos match up with which rows in grid_meg.pos, and
then only for those that match, concatenate so that the *.leadfield is of
size [(number of eeg channels + number of meg channels)  X 3].

It might be easier to first ensure that the grid used to create these
leadfields have the same 'inside' positions (inside the volume conductor).

Best,
Johanna

2013/5/22 Mushfa Yousuf <mushfa.yousuf at googlemail.com>

> Hello Jörn;
>
> I have calculated an indiviual leadfield for both EEG and MEG. The
> structure of EEg and MEG shows the following variable
>
> grid_meg =
>
>         xgrid: [1x20 double]
>         ygrid: [-8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8]
>         zgrid: [-2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13]
>           dim: [20 17 16]
>           pos: [5440x3 double]
>          unit: 'cm'
>        inside: [1x3177 double]
>       outside: [1x2263 double]
>           cfg: [1x1 struct]
>
>
> grid_eeg =
>
>         xgrid: [-6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9]
>         ygrid: [-6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6]
>         zgrid: [2 3 4 5 6 7 8 9 10 11]
>           dim: [16 13 10]
>           pos: [2080x3 double]
>          unit: 'cm'
>        inside: [1x1331 double]
>       outside: [1x749 double]
>           cfg: [1x1 struct]
>
>
> Can you please give me a rough idea that how to concatenate the variables
> from both structure ?
>
>
> Thank you
>
> Regards ;
>
> Mushfa Yousuf
>
>
> On Mon, May 13, 2013 at 11:13 AM, "Jörn M. Horschig" <
> jm.horschig at donders.ru.nl> wrote:
>
>>  Dear Mushfa,
>>
>> I think you have to compute two leadfield matrices, one for EEG (elec)
>> and one for MEG (grad), and then concatenate these (and make sure that the
>> order of sensors won't get mixed up anywhere, because  sourceanalysis just
>> expects the leadfield matrix to be ordered like your data. If that's not
>> the case, you either encounter the previous error you described or (if the
>> number of channels matches, but order is mixed up) it will just return
>> wrong source estimated activity.
>>
>> Best,
>> Jörn
>>
>>
>> On 5/6/2013 2:47 PM, Mushfa Yousuf wrote:
>>
>> Hello;
>>
>>  Yes you were right. I have defined the wrong sensors i.e 'grad' instead
>> of 'elec' while calculating the Leadfield.
>>
>>  Actually I am trying to calculate Combined source reconstruction from
>> both EEG and MEG sensors.
>>
>>  Do you have any idea, how to define both elec and grad definition
>> while calculating first forward then inverse solution.
>>
>>  Because in a fieldtrip either you can defined elec or grad at one time.
>>
>>
>>  Regards;
>>
>>
>>  Mushfa Yousuf
>>
>>  Neurozentrum,
>> Universitätsklinikum Schleswig-Holstein,
>> Campus Kiel (UKSH), Deutschland
>>
>>
>> On Tue, Apr 30, 2013 at 6:23 PM, Johanna Zumer <johanna.zumer at gmail.com>wrote:
>>
>>> Hi Mushfa,
>>>
>>>  My guess is that the channels that have you used to compute .csdspctrm
>>> are not the same as the channels in cfg.elec.    If you set cfg.channel =
>>> freqPost.label, does that solve it?
>>>
>>>  Cheers,
>>> Johanna
>>>
>>>
>>> 2013/4/30 Mushfa Yousuf <mushfa.yousuf at googlemail.com>
>>>
>>>>   Hello Fieldtrippers,
>>>>
>>>>  I am doing source reconstruction using EEG channels on a fieldtrip.
>>>>
>>>>  I have computed Forward solution i.e head model using  'Openmeeg' and
>>>>
>>>>  For the inverse solution using 'dics' method, I wrote the following
>>>> syntax
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>   cfg              = [];
>>>>   cfg.method       = 'dics';
>>>>  cfg.frequency    = 130;
>>>>  cfg.elec         = dataFIC12.hdr.elec;
>>>>  cfg.grid         = grid;
>>>>  cfg.vol          = vol;
>>>>
>>>>   sourcePost = ft_sourceanalysis(cfg, freqPost);
>>>>
>>>>
>>>>  and I have received the following error:
>>>>
>>>>
>>>>  ??? Error using ==> mtimes
>>>> Inner matrix dimensions must agree.
>>>>
>>>>  Error in ==> beamformer_dics at 314
>>>>         filt = pinv(lf' * invCf * lf) * lf' * invCf;              %
>>>>         Gross eqn. 3, use PINV/SVD to cover rank deficient
>>>>
>>>>  Error in ==> ft_sourceanalysis at 595
>>>>       dip(i) = beamformer_dics(grid, sens, vol, [],
>>>>       squeeze(Cf(i,:,:)), optarg{:});
>>>>
>>>>  Error in ==> newCode at 214
>>>> sourcePost = ft_sourceanalysis(cfg, freqPost);
>>>>
>>>>
>>>>
>>>>
>>>>  Any help would be appreciated.
>>>>
>>>>
>>>>  Regards;
>>>>
>>>>
>>>>  Mushfa Yousuf
>>>>
>>>>  Neurozentrum,
>>>> Universitätsklinikum Schleswig-Holstein,
>>>> Campus Kiel (UKSH), Deutschland
>>>>
>>>>
>>>>  _______________________________________________
>>>> 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
>>>
>>
>>
>>
>> _______________________________________________
>> fieldtrip mailing listfieldtrip at donders.ru.nlhttp://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>
>>
>>
>> --
>> Jörn M. Horschig
>> PhD Student
>> Donders Institute for Brain, Cognition and Behaviour
>> Centre for Cognitive Neuroimaging
>> Neuronal Oscillations Group
>> FieldTrip Development Team
>>
>> P.O. Box 9101
>> NL-6500 HB Nijmegen
>> The Netherlands
>>
>> Contact:
>> E-Mail: jm.horschig at donders.ru.nl
>> Tel:    +31-(0)24-36-68493
>> Web: http://www.ru.nl/donders
>>
>> Trigon, room 2.30
>> Kapittelweg 29
>> NL-6525 EN Nijmegen
>> The Netherlands
>>
>>
>> _______________________________________________
>> 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/20130527/c87c33ba/attachment-0002.html>
```