[FieldTrip] plotting interpolated sources with ft_sourceplot

"Jörn M. Horschig" jm.horschig at donders.ru.nl
Mon Mar 31 13:54:53 CEST 2014


Hi Tyler,

there is not much inherently different between time- and 
freuqency-domain beamformer, at least in terms of computing the forward 
and the inverse solution. But I see that you are obviously confused, so 
let me try to help you out and shed some light on what you are actually 
doing ;)


> I had a look at my variables.
>
> source.avg =
>
>         pow: [642x1 double]
>      filter: {642x1 cell}
>
> sourceInt.avg =
>
>      pow: [16777216x1 double]
>
> So clearly, as both variables are completely different. Something has gone wrong.
No, that is actually how it should be. From below you can see that your 
MRI has 3-dimensions, each with 256 elements, that is 256*256*256 = 
16777216 elements. In line with source.avg.pow, you should see that your 
'grid' consists of 642 elements, so you were computing your source 
activity on a grid of in total 642 elements. Then you used the original 
MRI to interpolate from 642 to these 16 million grid points. Actually, 
since you specific cfg.downsample = 2, it should have been only 8 
million points, so that's where things already get a bit weird.

So let's go into some sanity checks:
1. are you using the latest version (or a recent, i.e. from this year) 
of FielTrip?
2. sourceInt should look something like this, does it?

source_diff_int =
        inside: [46x55x46 logical]
           avg: [1x1 struct]
           dim: [46 55 46]
     transform: [4x4 double]
       anatomy: [46x55x46 double]
          unit: 'mm'
           cfg: [1x1 struct]



3. source should look something like this:

source =
           dim: [20 25 22]
          freq: 54.8287
     cumtapcnt: [338x1 double]
           pos: [11000x3 double]
        inside: [1x5798 double]
       outside: [1x5202 double]
        method: 'average'
           avg: [1x1 struct]
     trialinfo: [338x1 double]
           cfg: [1x1 struct]

4. also check your grid, should be something like this:

sourcemodel =

         pos: [11000x3 double]
         dim: [20 25 22]
        unit: 'cm'
      inside: [1x5798 double]
     outside: [1x5202 double]
      params: [1x1 struct]
     initial: [4x4 double]
         cfg: [1x1 struct]


Of course, it should all look a bit different, because you are using 
LCMV, but essentially it should be the same. Lastly, you can check other 
source plotting methods, like 'ortho' or try to plot the source 
structure rather than the sourceInt structure. In the end, the error 
must be somewhere in your grid, be it in .pos or .inside, because 
FieldTrip thinks that there is only one voxel to be plotted. There are 
other things that may be the issue, but I am not sure about these. So, I 
would suggest that you play a bit around and see where the error might 
come from (e.g. follow this tutorial: 
http://fieldtrip.fcdonders.nl/tutorial/beamformingextended and adapt the 
steps that you need for LCMV, maybe also check out: 
http://fieldtrip.fcdonders.nl/tutorial/connectivity#connectivity_between_meg_virtual_channel_and_emg 
there, LCMV is used, but on one voxel only)

Best,
Jörn

>
> The next part of my code is the following:
>
>            % interpolate sources
>              mri = ft_read_mri('Subject01.mri');
>              mri = ft_volumereslice([], mri);
>              
>              cfg            = [];
>              cfg.downsample = 2;
>              cfg.parameter = 'avg.pow';
>              sourceInt  = ft_sourceinterpolate( cfg, source, mri);
>              sourceInt = rmfield( sourceInt,'time'); % The avg.pow parameter
>              % does not vary over time, therefore the time  dimension is not needed.
>
> mri =
>
>        anatomy: [256x256x256 double]
>            dim: [256 256 256]
>      transform: [4x4 double]
>       coordsys: 'ctf'
>           unit: 'mm'
>            cfg: [1x1 struct]
>              
> I cant really see if the data works in the tutorial because it doesnt appear as though fieldtrip has a tutorial on lcmv beamformers, they seem to stick to frequency domain beamformers.
>
> Ive been wrong before though,
>
> thanks for your help.
>
> 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 "Jörn M. Horschig" <jm.horschig at donders.ru.nl>
> Sent: Monday, 31 March 2014 7:13 PM
> To: FieldTrip discussion list
> Subject: Re: [FieldTrip] plotting interpolated sources with ft_sourceplot
>
> Hi Tyler,
>
> hm, okay, it could be that the issue with the leadfield and with the
> plot are related, but it could also be that they are separate issues. I
> just saw that you posted the same 'problem' on bugzilla and included a
> picture. Maybe for next time, include a picture on the mailinglist and
> just create a bug on bugzilla if you are sure it is a bug in Fieldtrip
> and not if you are not sure. That saves us a lot of time in separating
> code issues from user problems ;)
>
> So, back to you problem. It seems that your reconstruction results in
> one voxel only. Are you sure that your grid consistents of more than
> just one position? So, for example check the size of the matrices in
> source.avg, source- and headmodel, etc.
>
> Also, you can check in Matlab the respective fields of source and
> sourceInt and see whether that makes sense.
>
> Lastly, a neat way to check is always to use your code on data from the
> tutorial, and vice versa, use code from the tutorial on your data and
> see whether that works. Both should give sensible results, and if one
> does not, you know where to start looking for a solution ;)
>
> Best,
> Jörn
>
>
> On 3/31/2014 9:41 AM, Tyler Grummett wrote:
>> Hey Jorn,
>>
>> Previously I have let ft_sourceanalysis do a lead field because if I use the following code:
>>
>>    % compute lead field ( apparently source analysis computes
>>               % lead field anyway
>>               cfg                 = [];
>>               cfg.elec            = timelock.elec;
>>               cfg.vol             = vol;
>>               cfg.reducerank      = 3;
>>               cfg.grid.resolution = 1;   % use a 3-D grid with a 1 cm resolution
>>               cfg.grid.unit       = 'cm';
>>               cfg.normalize       = 'yes'; % if you are not contrasting the activity of interest again another condition or baseline time-window
>>               grid = ft_prepare_leadfield( cfg); %% THIS IS WHERE I AM UP TO
>>
>> and then calculate the source analysis:
>>
>> % Source Analysis: without contrasting condition
>>               cfg              = [];
>>               cfg.method       = 'lcmv';
>>               cfg.grid         = grid;
>>               cfg.vol          = vol;
>> %             cfg.grid.pos = maxpos;
>>               cfg.keepfilter = 'yes';
>>               cfg.dics.projectnoise = 'yes';
>> %             cfg.dics.lambda       = 0;
>>               source = ft_sourceanalysis( cfg, timelock);
>>
>> then I get an error than says:
>>
>> Error using  *
>> Inner matrix dimensions must agree.
>>
>> Error in beamformer_lcmv (line 268)
>>       filt = pinv(lf' * invCy * lf) * lf' *
>>       invCy;              % van Veen eqn. 23, use
>>       PINV/SVD to cover rank deficient leadfield
>>
>> Error in ft_sourceanalysis (line 794)
>>         dip(i) = beamformer_lcmv(grid, sens, vol,
>>         squeeze_avg, squeeze(Cy(i,:,:)),
>>         optarg{:});
>>
>> I just removed the leadfield code and it successfully ran. I could also interpolate it later.
>> Is this the correct approach.
>>
>> Thankyou in advance!
>>
>> 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 "Jörn M. Horschig" <jm.horschig at donders.ru.nl>
>> Sent: Monday, 31 March 2014 5:30 PM
>> To: FieldTrip discussion list
>> Subject: Re: [FieldTrip] plotting interpolated sources with ft_sourceplot
>>
>> Hi Tyler,
>>
>> what you are describing sounds to me like the center bias of the
>> beamformer. Did you contrast the activity with anything, or did you
>> normalize your leadfield?
>> Check this out:
>> http://fieldtrip.fcdonders.nl/tutorial/beamformer#source_analysiswithout_contrasting_condition
>>
>> Best,
>> Jörn
>>
>> On 3/31/2014 5:46 AM, Tyler Grummett wrote:
>>> I have been trying to plot my interpolated source data using the code:
>>>
>>>               % interpolate sources
>>>               mri = ft_read_mri('Subject01.mri');
>>>               mri = ft_volumereslice([], mri);
>>>               cfg            = [];
>>>               cfg.downsample = 2;
>>>               cfg.parameter = 'avg.pow';
>>>               sourceInt  = ft_sourceinterpolate( cfg, source, mri);
>>>               sourceInt = rmfield( sourceInt,'time'); % The avg.pow
>>> parameter
>>>               % does not vary over time, therefore the time  dimension
>>> is not              needed.
>>>
>>>               % Plot interpolated data
>>>               cfg              = []; %#ok<UNRCH>
>>>               cfg.method       = 'ortho'; % spline
>>>               cfg.funparameter = 'avg.pow';
>>>               ft_sourceplot( cfg, sourceInt);
>>>
>>> However the figure that comes up just had orange squares in the subplots.
>>>
>>> I dont know where Ive gone wrong.
>>>
>>>
>>> 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
>> --
>> Jörn M. Horschig
>> PhD Student
>> Donders Institute for Brain, Cognition and Behaviour
>> Centre for Cognitive Neuroimaging
>> Radboud University Nijmegen
>> 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
>>
>> Visiting address:
>> 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
>
> --
> Jörn M. Horschig
> PhD Student
> Donders Institute for Brain, Cognition and Behaviour
> Centre for Cognitive Neuroimaging
> Radboud University Nijmegen
> 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
>
> Visiting address:
> 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


-- 
Jörn M. Horschig
PhD Student
Donders Institute for Brain, Cognition and Behaviour
Centre for Cognitive Neuroimaging
Radboud University Nijmegen
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

Visiting address:
Trigon, room 2.30
Kapittelweg 29
NL-6525 EN Nijmegen
The Netherlands




More information about the fieldtrip mailing list