[FieldTrip] BEM headmodel NaN when created from individual MRIs

Wilken, Saskia saskia.wilken at fernuni-hagen.de
Fri Sep 20 12:45:09 CEST 2024


Dear community,
I am Saskia Wilken and I am doing my PhD at the Fernuniversität in Hagen in Germany on motor control and its neuronal correlates. I am currently analyzing data for a paper for which we recorded EEG and an anatomical MRI image per participant. We are doing source reconstruction via beamforming using the individual anatomies for the headmodels.
My preprocessing pipeline does not work for around a third (20) of my participants' MRI images. After running the segmentation using ft_volumesegment and preparing meshes for skull, brain and scalp using ft_prepare_mesh, ft_prepare_headmodel yields a headmodel.mat with all NaN values. I posted the code and the cfg of all three functions below. I intended to use a Boundary Element Model and wouldn't want to use a different type of headmodel on a subset of my data.
All MRIs are resliced and bias corrected. I tried out different methods and parameters - adjusting smoothing and threshold worked on a few of the other MRIs - but not on these remaining 20 MRIs. I also tried with different numbers of vertices, different methods for mesh preparation, and different segmentation methods I also attempted to correct the segmentation manually by filling holes and smoothing out ragged edges between the tissue types using Seg3D like suggested on the Fieldtrip website, assuming that the issue might be intersecting or self-intersecting meshes. But it didn't change the outcome.

subject_id = '3313';
mri_resliced = ft_read_mri([subject_id + "_resliced.mat"])

%% Segmentation of Brain, Skull and Scalp
cfg           = [];
cfg.output    = {'brain', 'skull', 'scalp'};
% I tried out a wide array of different value combinations already
cfg.brainsmooth      = 5; % default = 5;
cfg.scalpsmooth      = 5; % default = 5;
cfg.skullsmooth      = 5; % default = 5;
cfg.brainthreshold   = 0.5; % default = 0.5;
cfg.scalpthreshold   = 0.1; % default = 0.1;
cfg.skullthreshold   = 0.5; % default = 0.5;

segmentedmri  = ft_volumesegment(cfg, mri_resliced);
ft_checkdata(segmentedmri, 'feedback', 'yes');

%% Create Mesh
cfg = [];
cfg.tissue      = {'brain', 'skull', 'scalp'};
cfg.method      = 'projectmesh';
cfg.numvertices = [3000 2000 1000] %[6000 4000 4000];

mesh = ft_prepare_mesh(cfg, segmentedmri);
mesh = ft_convert_units(mesh, 'mm'); % Use SI Units

%% Create a volume conduction model
cfg        = [];
cfg.method = 'bemcp'; % only BEM method that works on my machine
headmodel = ft_prepare_headmodel(cfg, mesh);
headmodel = ft_convert_units(headmodel, 'mm'); % Use SI Units
headmodel.coordsys = 'ctf';
I uploaded an example of a not-working MRI, you can download it from https://fernuni-hagen.sciebo.de/s/fFAYa0CopBAz2qY
When I run fr_prepare_headmodel, I get the following warnings:

% Appears 8 times:
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.
% Appears only once respectively:
Warning: NaN detected, trying once more with slightly different vertex positions
Warning: flipping mesh 1
Warning: flipping mesh 2
Warning: flipping mesh 3


I appreciate any help that can point me towards another solution attempt I haven't tried yet that can help me create a BEM headmodel for the subjects in question.
Best,
Saskia Wilken
Doktorandin
-----------------------------------------------
FernUniversität in Hagen
Fakultät für Psychologie
Allgemeine Psychologie: Urteilen, Entscheiden, Handeln
Gebäude 11 (Psychologie)
Universitätsstraße 37
58097 Hagen
Telefon: (02331) 987 -4124
saskia.wilken at fernuni-hagen.de
https://www.fernuni-hagen.de/psychologie-urteilen-entscheiden/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20240920/fce51783/attachment.htm>


More information about the fieldtrip mailing list