[FieldTrip] restrict source reconstruction to gray matter

jan-mathijs schoffelen jan.schoffelen at donders.ru.nl
Sat Mar 31 13:30:02 CEST 2012

Hi Fred,

I am not aware of any example code on the FT-website, but I would do something like this:

mri = ft_read_mri('...');
seg = ft_volumesegment([],mri);

cfg = [];
cfg.parameter = 'gray';
cfg.smooth = 10; % or some other value
cfg.downsample = 5; % downsample with a factor of 5
seg = ft_volumedownsample(cfg, seg);

% create a dipole grid
[X,Y,Z] = ndgrid(1:seg.dim(1), 1:seg.dim(2), 1:seg.dim(3));

grid = [];
grid.pos = warp_apply(seg.transform, [X(:) Y(:) Z(:)]); clear X Y Z
grid.dim = seg.dim;
grid.inside = find(seg.gray>0.5); % the threshold value needs to be verified, you can play with the value
grid.outside = find(seg.gray<=0.5);

grid = ft_convert_units(grid, 'cm'); % I assume that the sensors are defined in cm.

Just give it a shot. I would appreciate it very much if you could try this code and maybe optimize it. When you have done that, we could make a piece of documentation on the FT-website, i.e. I will create a page (because I don't think you could do that), and you'll write the documentation ;-). Sounds like a win-win situation to me. How does it sound to you?

Best wishes,


On Mar 31, 2012, at 1:10 PM, Frederic Roux wrote:

> Dear all,
> I read that it is possible to restrict source reconstruction to gray matter.
> Can anyone give me a hint on where can I find example code on how to do it?
> I was searching for it on the fieldtrip-webstite but couldn't find anything.
> Any help would as always be highly appreciated.
> Fred
> -- 
> Frédéric Roux, PhD student
> Department of Neurophysiology
> Max Planck Institute for Brain Research
> D-60529 Frankfurt am Main
> Frederic.Roux at brain.mpg.de
> +49(0)69630183225
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip

Jan-Mathijs Schoffelen, MD PhD 

Donders Institute for Brain, Cognition and Behaviour, 
Centre for Cognitive Neuroimaging,
Radboud University Nijmegen, The Netherlands

Max Planck Institute for Psycholinguistics,
Nijmegen, The Netherlands

J.Schoffelen at donders.ru.nl
Telephone: +31-24-3614793

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

More information about the fieldtrip mailing list