The purpose of this page is just to serve as todo or scratch pad for the development project and to list and share some ideas.

After making changes to the code and/or documentation, this page should remain on the wiki as a reminder of what was done and how it was done. However, there is no guarantee that this page is updated in the end to reflect the final state of the project

So chances are that this page is considerably outdated and irrelevant. The notes here might not reflect the current state of the code, and you should not use this as serious documentation.

Re-order tutorial documentation to build head models

This page refers to wiki page headmodels and describes the steps to be done to get a generic head model, with the final aim to calculate the lead fields. Firstly download and unzip the MRI files found in HERE. The following steps are necessary to build a head model in FieldTrip:

The MEG dataset that is used in this demo is available from ftp://ftp.fcdonders.nl/pub/fieldtrip/tutorial/ and is named Subject01.zip.

Load a set of MRI anatomical images and reslice

% load MRI and reslice 
mri = ft_read_mri('Subject01.mri');
 
% Reslicing makes the dimensions of the voxels cubic and
% interpolates/reslices the mri volume according to a given
% grid of points (i.e. in the MEG sensors space). 
% After this transformation the voxel's dimensions are the same.
 
scaling = 1;
cfg = [];
cfg.resolution = scaling;
mri = ft_volumereslice(cfg,mri);

Coregistration

% Coregister the MRI to a 'CTF-like' reference system (head coordinates)
% The cfg.method is 'interactive' so the nasion, 
% left ear and right ear pits have to be marked by pressing the right keys ('n'/'l'/'r')
cfg = [];
cfg.method = 'interactive';
[mri2]     = ft_volumerealign(cfg, mri);

Segment the anatomy

% This may take some time
% (SPM8 is required)
cfg = [];
cfg.smooth = 5;
cfg.threshold = 0.5;
[segment] = ft_volumesegment(cfg, mri2); 

Volume post-processing

This step is necessary to obtain volumes which are not directly output of the segmentation (skin volume)

% Extract the skin volume:
tmp = double(mri.anatomy);
% 1. get rid of artefacts on the MRI edge
tmp(:,:,175:end)=0; tmp(:,121:end,171:end) = 0;
tmp(:,134:end,168:end) = 0; tmp(139:end,94:end,172:end) = 0;
% 2. smooth and median threshold
spm_smooth(tmp,tmp,3); 
val  = 1.2*median(tmp(:));
tmp  = tmp>val;
% 3.take segmented csf+brain+perimeter
br = imdilate(segment.brainmask,strel_bol(3));
skin = (br | tmp);
 
% Extract the skull volume:
skinshr  = imerode(skin,strel_bol(5));
braindil = imdilate(segment.brainmask,strel_bol(6));
skull =  ~(~braindil & ~skinshr) & ~skin;
 
% Plot all the compartments together with anatomy
% Different compartments are labelled with different integer numbers:
% i.e. 10=brain, 20=skull, 30=skin
mri3=mri;
mri3.seg = 30*skin + 20*skull + 10*brain;
icfg = [];
icfg.interactive  = 'yes';
icfg.funparameter = 'seg';
icfg.funcolormap  = 'jet';
figure,ft_sourceplot(icfg,mri3);

Create a geometrical model of the head surface/surfaces

See also here

% performs an automatic tessellation on the basis of the segmented volume
% intensity value (an integer X) and the number of wanted vertices
cfg = [];
cfg.tissue = [1]; % e.g. skin
cfg.numvertices = [4000];
cfg.sourceunits = 'mm';
cfg.mriunits    = 'mm';
bnd = ft_prepare_mesh(cfg, skin);

Build the method specific Head Model

This step builds the volume conductor structure starting from the information of the head geometry.

It uses ft_prepare_headmodel

Something like the following pipeline would be obvious for me, and functions to separately do these tasks:

  • MRI (vol) –> segmented MRI (labeled vol)
  • segmented MRI (labeled vol) –> mesh
  • mesh –> conductivity model (headmodel)

clearly 'vol' is confusing: is it a 3d or 2d object?

The prepare_mesh part of the prepare_singleshell would be nice to have separated, to have more control (and overview) of the mesh part when preparing headmodel, e.g. in prepare_singleshell.

development/doku.txt · Last modified: 2011/04/20 10:37 by 131.174.45.50

You are here: startdevelopmentdoku
This DokuWiki features an Anymorphic Webdesign theme, customised by Eelke Spaak and Stephen Whitmarsh.
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0