[FieldTrip] Fwd: AW: Forward solution using concentric spheres and BEM models
Micheli, C.
c.micheli at fcdonders.ru.nl
Wed Sep 14 17:56:38 CEST 2011
Hi Margit and Juan Pablo
see my answers below.
----- "Margit Schönherr" <Margit.Schoenherr at uk-erlangen.de> schreef:
> Van: "Margit Schönherr" <Margit.Schoenherr at uk-erlangen.de>
> Aan: "c micheli" <c.micheli at fcdonders.ru.nl>
> Verzonden: Woensdag 7 september 2011 09:33:53
> Onderwerp: AW: [FieldTrip] Forward solution using concentric spheres and BEM models
>
> Hello Cristiano,
>
> thank you for your email. I have tried the code, but I have 2 problems
> with it.
> 1) When I do it exactly as suggested in the email, I get the following
> error when using ft_prepare_mesh:
>
> bnd = ft_prepare_mesh(cfg, mri_segment);
> ??? Error using ==> ft_prepare_mesh at 159
> unsupported cfg.method and/or input
>
> I think, this is simply a problem concerning the naming of the
> variables. The segmented mri is called 'seg', the labels are assigned
> to 'mri_segment'. I think, this is the wrong input for
> ft_prepare_mesh, because 'mri_segment' does not contain any mri
> information. Putting the labels into a new field 'seg.seg' and calling
> bnd = ft_prepare_mesh(cfg, seg) solves this.
>
I could replicate the error and this is due to the fact that ft_prepare_mesh accepts inputs of FieldTrip type 'volume'. See ft_datatype_volume. The function crashed because I simply used an old version of the test file where I inputted the volume matrix only, whereas three fields are required (dim, transform and anatomy), that's why the input should look like this:
mri2 = [];
mri2.anatomy = mri_segment;
mri2.dim = mri.dim;
mri2.transform = mri.transform;
I patched the correct code at the end of the mail.
> 2) However, there is still only one surface triangulated. So as I
> wrote in my last email, I still believe that line 25 in
> prepare_mesh_segmentation needs to be commented. What do you mean?
I agree. This function needs a general review altogether and at the moment I committed your correction. In the future I'll restructure the whole function taking care of the more recent guidelines. Thanks for your suggestion.
Try this:
% download from the FieldTrip ftp site
% (ftp://ftp.fcdonders.nl/pub/fieldtrip/tutorial/Subject01.zip)
% load the MRI
mri = ft_read_mri('Subject01.mri');
% segment it
cfg = [];
cfg.output = {'scalp', 'skull', 'brain'};
seg = ft_volumesegment(cfg, mri);
% volumetric preprocessing
% Note: the three compartments have to be 'filled' otherwise the triangulation won't work correctly. The output of ft_volumesegment will change soon, making it compatible with ft_prepare_mesh. As of today we need the following:
mri_segment{1} = seg.scalp;
mri_segment{2} = imfill(seg.skull,'holes'); % you need the image processing toolbox here!
mri_segment{3} = seg.brain;
% triangulation (from volumes to surfaces)
% Note: now the volumes are inputted one at a time
mri2 = mri;
cfg=[];
cfg.sourceunits = 'mm';
cfg.mrinuits = 'mm';
cfg.tissue = 1;
cfg.numvertices = 1000;
for i=1:3
mri2.seg = mri_segment{i};
mesh{i} = ft_prepare_mesh(cfg,mri2);
end
% visualization of the triangulated surfaces
figure,ft_plot_mesh(mesh{1},'edgecolor','none','facecolor','w','facealpha',0.5)
ft_plot_mesh(mesh{2},'edgecolor','none','facecolor','g','facealpha',0.7)
ft_plot_mesh(mesh{3},'edgecolor','none','facecolor','r','facealpha',1)
> Thank you.
Be my guest.
Cheers,
Cristiano
>
> Best regards,
> Margit
>
>
> ***********************************
> Margit Schönherr
> Universitätsklinikum Erlangen
> Neurologische Klinik
> Epilepsiezentrum (Biomagnetismus)
> Schwabachanlage 6
> 91054 Erlangen
> Telefon: ++49 9131 / 85 36921
> Email: margit.schoenherr at uk-erlangen.de
> ***********************************
> ________________________________________
> Von: fieldtrip-bounces at donders.ru.nl [fieldtrip-bounces at donders.ru.nl]
> im Auftrag von Micheli, C. [c.micheli at fcdonders.ru.nl]
> Gesendet: Montag, 5. September 2011 12:59
> An: Email discussion list for the FieldTrip project
> Betreff: Re: [FieldTrip] Forward solution using concentric spheres
> and BEM models
>
> Dear Juan Pablo and Margit
>
> The function 'ft_prepare_mesh' takes care of triangulating every
> compartment via the cfg.tissue option. This option contains the
> integers which describe a type of tissue, given that the user
> beforehand defined all voxels of the segmented MRI compartment as
> having that particular value.
> As an example, download the sample MRI in FieldTrip ftp location:
>
> ftp://ftp.fcdonders.nl/pub/fieldtrip/tutorial/Subject01.zip
> Create a folder and unzip these files.
>
> % read in the mri
> mri = ft_read_mri('Subject01.mri');
>
> % segment it
> cfg = [];
> cfg.output = {'scalp', 'skull', 'brain'};
> seg = ft_volumesegment(cfg, mri);
>
> % assign a label
> scalp = (seg.scalp) & ~(seg.skull | seg.brain);
> skull = 2*(seg.skull);
> brain = 3*(seg.brain);
> mri_segment = scalp + skull + brain;
>
> % build the meshes
> cfg = [];
> cfg.method = 'segmentation';
> cfg.tissue = [1 2 3]; % scalp = 1; skull = 2; brain = 3;
> cfg.numvertices = [2000 1000 800];
> cfg.sourceunits = 'mm';
> cfg.mriunits = 'mm';
> bnd = ft_prepare_mesh(cfg, mri_segment);
>
> If any of the tissues has a different value from cfg.tissues this
> won't be triangulated. To check for this use ft_sourceplot in the
> interactive mode. By clicking around you can see the tissue's value in
> the command window:
>
> % view the labelled segmentations
> mri2 = mri;
> mri2.seg = mri_segment;
> cfg=[];
> cfg.interactive = 'yes';
> cfg.funparameter = 'seg';
> ft_sourceplot(cfg,mri2);
>
> About the concentric spheres:
> both ways to derive a concentric spheres model are correct. In one
> case you directly build the vol structure and you assume you know the
> radiuses of your spheres. In the other case you allow the
> ft_prepare_concentricspheres function to build the spheres starting
> from realistic geometrical boundaries.
> The second approach is my favorite because the ft_prepare function
> contains a function that fits a sphere to each boundary and I don't
> have to do it myself.
> The first approach (directly force the radiuses in your vol structure)
> is preferable if you derive the information from other software (e.g.
> CTF's MRIView) or if you fit the sphere yourself.
>
> @Pablo
> If the sphere is fitted inside the brain it is correct. You do not
> want the sphere to include other tissues, because your assumption for
> the construction of the forward model is that the tissue inside the
> sphere is homogeneous.
> For a more realistic model (encompassing the whole brain volume) I
> would rather use a BEM model.
>
> I hope this helps,
> Cristiano
More information about the fieldtrip
mailing list