[FieldTrip] Better Segmentation of MRI Images

Edward Lannon elannon at stanford.edu
Tue Mar 21 23:29:29 CET 2023


Dear Community,

I am analyzing resting state EEG data. We also have t1W images collected at another time. I would like to use the t1W images to create a head model for my EEG source analysis.

 My current pipeline does not construct the head properly I get the error when computing volumen conduction:
Error using ft_headmodel_bemcp (line 127)
vertex 467 of surface 2 is outside surface 3

The pipeline was taken from the Fieldtrip turorial websites. See below. See also attached for MRI and segmented visualizations. I have tried chagning cfg.scalpthreshold, but have not landed on a desirable outcome. I have also used ft_volumebiascorrect and the scalp is not calculated correctly. Is there another strategy that I can use to calculate the scalp correctly?

%Interactive Search of Fids
cfg = [];
cfg.method = 'interactive'
cfg.coordsys = 'ctf'; % the desired coordinate system
mri_realigned = ft_volumerealign(cfg,  mri)

%Cut image
cfg = [];
cfg.method = 'linear';
mri_resliced = ft_volumereslice(cfg,  mri_realigned);

%Segment to areas
cfg           = [];
cfg.output    = {'brain', 'skull', 'scalp'};
%cfg.scalpthreshold = 0.1;
%cfg.scalpsmooth  = 'no';
segmentedmri  = ft_volumesegment(cfg, mri_resliced);

disp(segmentedmri)

%Visualize the segmentation result
segmentedmri_indexed = ft_checkdata(segmentedmri, 'segmentationstyle', 'indexed')
segmentedmri_indexed.anatomy = mri_resliced.anatomy;

cfg = [];
cfg.method = 'ortho';
cfg.anaparameter = 'anatomy';
cfg.funparameter = 'tissue';
cfg.funcolormap = [
  0 0 0
  1 0 0
  0 1 0
  0 0 1
  ];
ft_sourceplot(cfg, segmentedmri_indexed)

%Create Mesh
cfg = [];
cfg.tissue      = {'brain', 'skull', 'scalp'};
cfg.numvertices = [3000 2000 1000];
mesh = ft_prepare_mesh(cfg, segmentedmri);

%Plot Mesh

figure
ft_plot_mesh(mesh(1), 'facecolor', 'none'); % brain
view([0 -1 0]); % from the right side

figure
ft_plot_mesh(mesh(2), 'facecolor', 'none'); % skull
view([0 -1 0]); % from the right side

figure
ft_plot_mesh(mesh(3), 'facecolor', 'none'); % scalp
view([0 -1 0]); % from the right side

figure
ft_plot_mesh(mesh(1), 'facecolor','r', 'facealpha', 1.0, 'edgecolor', 'k', 'edgealpha', 1);
hold on
ft_plot_mesh(mesh(2), 'facecolor','g', 'facealpha', 0.4, 'edgecolor', 'k', 'edgealpha', 0.1);
hold on
ft_plot_mesh(mesh(3), 'facecolor','b', 'facealpha', 0.4, 'edgecolor', 'k', 'edgealpha', 0.1);

% Create a volume conduction model
cfg        = [];
cfg.method = 'bemcp'; % You can also specify 'openmeeg', 'bemcp', or another method
headmodel  = ft_prepare_headmodel(cfg, mesh);

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20230321/227a2d48/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Brain.jpg
Type: image/jpeg
Size: 122306 bytes
Desc: Brain.jpg
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20230321/227a2d48/attachment-0005.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Skull.jpg
Type: image/jpeg
Size: 118766 bytes
Desc: Skull.jpg
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20230321/227a2d48/attachment-0006.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Scalp.jpg
Type: image/jpeg
Size: 89351 bytes
Desc: Scalp.jpg
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20230321/227a2d48/attachment-0007.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: HeadModel.jpg
Type: image/jpeg
Size: 63927 bytes
Desc: HeadModel.jpg
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20230321/227a2d48/attachment-0008.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Original_MRI.jpg
Type: image/jpeg
Size: 44519 bytes
Desc: Original_MRI.jpg
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20230321/227a2d48/attachment-0009.jpg>


More information about the fieldtrip mailing list