Incorrect coordinates?

Robert Oostenveld r.oostenveld at FCDONDERS.RU.NL
Mon Oct 16 20:16:37 CEST 2006

Hi Jared,

On 15 Oct 2006, at 0:12, Jared Van Snellenberg wrote:
> I've rerun the analysis with mri's that were reoriented to MNI, and
> the same problem has emerged.

I would guess that the anatomical MRIs themselves do not influence
the coordinate system of the source reconstruction. That would
influence the interpolation though.

If you do
   source = besa2fieldtrip(filename1)
   mri = read_fcdc_mri(filename)
then the source structure is defined using the source.pos field that
describes the position of each source. SInce in this case the
positions are on a regular 3D grid, there is additional structure in
the arrangement of source.pos, which is described using source.xgrid,
source.ygrid, source.zgrid.

If you do
   tmp = reshape(source.avg.pow, source.dim)
you will get a 3D array with along the first dimension the voxels
along the x-axis, etc. The 1..Nth voxels along the xasix have the X
coordinates source.xgrid(1)..source.xgrid(N). Similar for the Y and Z
coordinates. That allows you to determine the coordinate of each voxel.

Since the anatomical MRI is typically of much higher resolution, you
can use sourceinterpolate which interpolates the source (or stat)
volumes onto the voxel locations that are in the anatomical MRI. I.e.
sourceinterpolate upsamples the functional data to the anatomical
MRI. Normally you would do sourceinterpolate AFTER calling
sourcestatistics, since the source positions in all subjects are all
based on the same standard realistic head moidel in BESA and hence
the source positions in all subjects are the same (please check
whether positions are all the same over subjects/conditions).

If you work with MEG or with EEG individual headmodels, the source
positions in all subjects are all different, which requires
sourceanalysis->sourceinterpolate->volumenormalize as shown in the
schema for

> The typo you noted in your last email was indeed the reason for the
> empty src plot. Plotting src, interp, volume, and grandavg,
> everything looks ok. The 'pow' parameter values all appear within
> the brain. The tscore and p values in stat, however, are all messed
> up. I've attached .bmp's from using sourceplot on grandavg and stat
> to this email. The quality is poor (matlab's figure window doesn't
> ever save bmp's very well), but it should demonstrate the problem
> clearly. Note all the large values outside of the brain.

In your case you should be able to do besa2fieldtrip ->
sourcestatistics, and then the source positions with the statistical
data on them should stll be the same as the positions with the
original functional data on them. After doing the statistics (or
after doing sourcegrandaverage), you can interpolate the functional/
statistical data onto the MRI. But since the statistical data and the
functional (beamed power) data are on the same coordinates, there
should not be a difference between them.

> Any comments you have would be greatly appreciated. I've considered
> just masking out everything that's not in the brain, but I'm not
> confident that the within-brain values are accurate.

Looking at the bitmaps, I cannot see teh anatomy, but I do see a
brain-shaped outline with some blobs in them. I cannot recognise the
problem from these figures, to me they seem ok. The only problem that
I can see is the one that you also mention, and that is for the
masking. In the original source data (i.e. output from
besa2fieldtrip) there is an source.inside and source.outside field.
Those should contain the indices of the voxels (linear indices, so
voxel [1 1 1] has index 1 and voxel [2 1 1] has index 2...) of the
sources that are inside the brain and outside the brain. Only the
inside voxels are considered for sourcestatistics and for
sourceinterpolation. However, the problem with BESA data is that it
does not describe the inside/outside voxels and therefoer by default
all voxels are marked as inside. Perhaps you can determine the inside/
outside voxels manually, e.g.
   source.inside  = find(source.avg.pow(:)>eps);
   source.outside = find(source.avg.pow(:)<eps);
After fixing the inside/outside, you can rerun sourcestatistics and
the rest. See the related FAQ

To me it seems that the outside brain mess is caused by an
interpolation artifact, which can well be explained by the missing
inside/outside specification of besa. After fixing the inside/outside
vectors in the source structure, and passing it through
sourceinterpolate, you will get an interp.inside 3D boolean volume
with 0s and 1s for outside and inside voxels. You can element-wise
multiply the data with it, to mask the outside, or you can specify
cfg.mask='inside' in sourceplot (which uses opacity).

Hope this helps, if not, please put some data (source, mri, stat,
interp) in a zip file on


More information about the fieldtrip mailing list