Cut neck and merge layers programmatically

I am trying to prepare a matlab script that

  1. impots my simnibs 4.0 folder
  2. resect the neck from the FEM (automatically imported)
  3. merge the 12 layers to 5 layers (as in the turorial)

However after I import the simnibs folder I do not find the functions to programmatically cut out the neck and merge the FEM layers.

Is there a way to do that?

Thanks for the support!

Hi @GiacomoBertazzoli,

Once the FEM is imported for a given Subject, resect and layer-merging can be done with these lines:

% Subject name for imported FEM

% Find default FEM file for Subject
sSubject = bst_get('Subject', SubjectName);
Fem12File = sSubject.Surface(sSubject.iFEM).FileName;

% Resect neck. Plane in MNI coordinates: (a.x + b.y + c.z + d = 0)
NoNeckFem12File = fem_resect(Fem12File, [0, 0, 1, .085]);

% FEM mesh: Merge 12 tissues into 5 tissues
NoNeckFem5File = panel_femname('Edit', NoNeckFem12File, {'white', 'gray', 'csf', 'skull', 'scalp', 'scalp', 'skull', 'skull', 'csf', 'csf', '', ''});



Thanks, Ray, I can't do better :slight_smile:

1 Like

It worked perfectly, thank you!