[FieldTrip] Error in Beamforming analysis due to units?

Andreas Sauer sauer.mpih at googlemail.com
Wed Jul 17 17:16:14 CEST 2013


Dear all,

I'm having a hard time understanding my beamforming analysis/results. I set
up the analysis pipeline as described in the tutorial(s). First, I create
my template grid as shown below:

----------------------
% Step 1: CREATE A TEMPLATE
template = ft_read_mri([TemplateDir 'T1.nii']);
template.coordsys = 'spm';

% Step 2: Segment the template brain and construct a volume conduction
% model (i.e. head model): this is needed for the inside/outside detection
of voxels
cfg = [];
template_seg = ft_volumesegment(cfg,template);

cfg = [];
cfg.method = 'singleshell';
template_vol = ft_prepare_headmodel(cfg,template_seg);
template_vol = ft_convert_units(template_vol,'cm');

% Step 3: Construct the dipole grid in the template brain coordinates.
% The source units are in cm
cfg = [];
cfg.grid.xgrid  = -20:1:20;
cfg.grid.ygrid  = -20:1:20;
cfg.grid.zgrid  = -10:1:20;
cfg.unit        = 'cm';
cfg.grid.tight  = 'yes';
cfg.inwardshift = -1.5; % negative inwardshift leads to an outwardshift of
the brain's surface
cfg.reducerank  = 'no';
cfg.vol         = template_vol;
template_grid = ft_prepare_sourcemodel(cfg);

% Step 4: Make a figure with the template head model and dipole grid
figure
hold on;
ft_plot_vol(template_vol,'facecolor','cortex','edgecolor','none'); alpha
0.5; camlight;
ft_plot_mesh(template_grid.pos(template_grid.inside,:));
----------------------

Some of my colleagues also add another step where they convert the template
grid units from 'cm' to 'mm' since MNI space is in 'mm'. Since this is not
mentioned in the tutorial, I skipped that step.

In the next steps for creating the single subject's grid and headmodel I
follow exactly the steps described in the tutorial to create single subject
grids in MNI space. When I check the segmentation everything looks fine.

I then of course use this grid to calculate the sources, also as described
in the tutorial. At the end I put the template grid position fields onto
the subject's baseline normalized source (sourceDiff_tem).

-----------------------------------------------------
for k = 1:length(cond)
        cfg               = [];
        eval(['cfg.frequency = freqAll.Cond_',num2str(cond(k)),'.freq;']);
        cfg.method        = 'dics';
        cfg.grid          = grid; % Here it gives .pos, .inside, .outside
to the structure
        cfg.vol           = vol;
        cfg.dim           = grid.dim;
        eval(['cfg.grad = Cond_',num2str(cond(k)),'.hdr.grad;']);
        cfg.lambda        = '5%';
        cfg.reducerank    = 'no';
        cfg.projectnoise  = 'yes';
        cfg.realfilter    = 'yes';
    cfg.keepfilter    = 'yes'; % the output saves the computed inverse
filter

        eval(['sourceAll.Cond_',num2str(cond(k)),' =
ft_sourceanalysis(cfg,freqAll.Cond_',num2str(cond(k)),');'])
        % use the pre-calculated common filter here
        eval(['cfg.grid.filter =
sourceAll.Cond_',num2str(cond(k)),'.avg.filter;']);
        eval(['sourcePre.Cond_',num2str(cond(k)),' =
ft_sourceanalysis(cfg,freqPre.Cond_',num2str(cond(k)),');'])
        eval(['sourcePost.Cond_',num2str(cond(k)),' =
ft_sourceanalysis(cfg,freqPost.Cond_',num2str(cond(k)),');'])

        % compute the contrast of (post-pre)/pre (normalization of the
power with the baseline activity)
        eval(['sourceDiff.Cond_',num2str(cond(k)),' =
sourcePost.Cond_',num2str(cond(k)),';'])
        eval(['sourceDiff.Cond_',num2str(cond(k)),'.avg.pow =
(sourcePost.Cond_',num2str(cond(k)),'.avg.pow-sourcePre.Cond_',num2str(cond(k)),'.avg.pow)
./ sourcePre.Cond_',num2str(cond(k)),'.avg.pow;']);

        % put the template grid positions (x,y,z & pos) into the source
structure
        eval(['sourceDiff_tem.Cond_',num2str(cond(k)),' =
sourceDiff.Cond_',num2str(cond(k)),';']);
        eval(['sourceDiff_tem.Cond_',num2str(cond(k)),'.pos =
template_grid.pos;']);
        eval(['sourceDiff_tem.Cond_',num2str(cond(k)),'.xgrid =
template_grid.xgrid;']);
        eval(['sourceDiff_tem.Cond_',num2str(cond(k)),'.ygrid =
template_grid.ygrid;']);
        eval(['sourceDiff_tem.Cond_',num2str(cond(k)),'.zgrid =
template_grid.zgrid;']);
    end
-----------------------------------------------------

If I then look at the data of this sourceDiff_tem, i.e. of condition 1,
plotted on a surface file, it looks a bit strange to me (see Fig1). Also, I
am not able to plot this data with cfg.method 'slice'. I get the error that
the dimensions do not match.

pos: [5780x3 double]
dim: [17 20 17]
avg: [1x1 struct]
var: [1x1 struct]
dimord: 'voxel'
inside: [2985x1 double]
outside: [2795x1 double]
df: [5780x1 double]
cfg: [1x1 struct]

I then tried it the 'old' way and took the Diff_Source of each subject,
interpolated this to the subject's anatomy and normalized it. With that I
get a result that makes more sense to me (Fig2). However, also with this I
am not able to plot it with cfg.method 'slice'. Actually, the slices I can
only use for plotting the stats.

So I guess that something is wrong here and that I have an error somewhere
in my script. However, I really can't find it. Our guess is that it has
something to do with the units and the conversion(s) from one space to the
other. I went through all the tutorials again and again but I can't see the
mistake. I am stuck and therefore would really appreciate any help on that
matter!

Thanks a lot!

Best,

Andreas

-- 
Andreas Sauer
Max Planck Institute for Brain Research
Deutschordenstra├če 46
60528 Frankfurt am Main
Germany

T: +49 69 96769 278
F: +49 69 96769 327
Email: sauer.mpih at gmail.com
www.brain.mpg.de
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20130717/9f460d83/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Fig1.png
Type: image/png
Size: 295434 bytes
Desc: not available
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20130717/9f460d83/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Fig2.png
Type: image/png
Size: 291696 bytes
Desc: not available
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20130717/9f460d83/attachment-0003.png>


More information about the fieldtrip mailing list