[Eeglablist] Re: mesh file for pop_headplot

Arnaud Delorme arno at sccn.ucsd.edu
Wed May 10 09:40:32 PDT 2006


Dear Sebastian

To create a custom mesh file for headplot (3D plotting)

1- load your mri into Matlab and extract mesh

The attached code will probably work but it requires that you install 
the AFNI matlab library http://afni.nimh.nih.gov/afni/matlab/ or SPM2 
http://www.fil.ion.ucl.ac.uk/spm/software/spm2/ (and EEGLAB plus 
Fieldtrip of course). The second solution will use the Fieldtrip 
function read_fcdc_mri() which is in theory able to read most MRI 
formats (through SPM2).

The matlab function attached uses the Matlab routine isosurface to 
extract the mesh. It will extract a mesh at the "color" you specify. 
There is a "histogram" button that plot the histogram of value for the 
anatomical MRI. Usually 0 is black, so you should select a color value 
in the first dip after 0 (and it can be at 30 or 1000 depending on the 
format of the MRI file). Alternatively, you may import into Matlab a 
triangular mesh created by Brainvisa or Freesurfer

2- adapt (maybe reorient) your mesh. The mesh included in EEGLAB only 
has about 6000 points whereas a standard mesh extracted with the 
function above might have more than 50000. If you do not want to wait 
forever when EEGLAB computes the interpolation, it might be necessary to 
reduce the mesh dimensionality.

There is a function in Matlab to do that while preserving the shape: 
reducepatch() (see below)

The other problem is that there are a lot of points inside the head that 
are useless. I wrote a routine to remove them but it is not optimal and 
I did not include it. There must be other options available (for 
instance some shrinkwrap method that would shrink a sphere to fit the 
shape of your surface). The EEG toolbox contains a variety of mesh 
routines that you may find useful in this respect. These internal points 
should not affect the interpolation on the head although I am not 100% 
sure about that (I would have to double check). I plotted some results 
on a mesh which had a lot of internal points and it looked fine but you 
should seek some more formal verification.

3- coregister with your channel file and plug in the result into headplot

------------------------------

The code below should perform all that (EEGLAB 5.01b)

mesh = mrisegment('mrifile'); % pops up GUI (look up function header for 
information)

[TRI1 POS]= reducepatch(mesh.faces, mesh.vertices, 0.1);
center = [0 0 0]; % this is the center of the head for the spline 
interpolation purposes
save -mat myhead.mat TRI1 POS center
% other possible variables understood by headplot are TRI2 (faces in 
skin color) NORM (normal vector to the skin for better shading)

You may then use the GUI (headplot) and enter your file name in the edit 
box "3D head mesh file", then select a channel location file in "mesh 
associated channel file" (the same you are using for the current 
dataset) and press coregister. Tune in manually angles and zoom so that 
your electrode file match with the head mesh (or align fiducial 
electrodes if available with hears and nazion on the head mesh). Then, 
it should plot OK. I have detected a small bug in pop_headplot() so I 
will send you personally an updated version (but until the next EEGLAB 
revision, the same operation may also be performed from the command line 
below).

[tmp transform] = coregister(EEG.chanlocs, EEG.chanlocs, 'mesh', 
'myhead.mat'); % align manually with head surface
headplot('setup', EEG.chanlocs, 'test.spl', 'chaninfo', EEG.chaninfo, 
'meshfile', 'myhead.mat', 'transform', transform);
headplot(EEG.icawinv(:,1), 'test.spl',  'meshfile', 'myhead.mat'); % 
plot first component

There is a variety of options in headplot to plot electrode on the 
sphere that is then shrinked to the head shape, etc...

Hope this helps,

Arno

Sebastian Jentschke wrote:
> Hi Arno,
>
> I would be interested in creating a mesh file for pop_headplot since 
> the currently used mesh file is one of adults and I am investigating 
> children. Would you be so kind to send me an explanation how to do 
> this. I can get MRI images of childrens heads if these are needed.
>
> Thank you very much in advance,
>
> Sebastian

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: mrisegment.m
URL: <http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20060510/bf3d66e1/attachment.ksh>


More information about the eeglablist mailing list