''' [TUTORIAL UNDER CONSTRUCTION]''' = FEM tutorial: MEG/EEG Median nerve stimulation = ''Authors: Takfarinas Medani, Juan Garcia-Prieto, Wayne Mead, Francois Tadel '' This tutorial introduces the FEM modeling in the Brainstorm environment, using DTI tensors and third-party programs BrainSuite, SimNIBS and CAT12. Note that the operations used here are not detailed, the goal of this tutorial is not to introduce Brainstorm to new users. For in-depth explanations of the interface and theoretical foundations, please refer to the [[http://neuroimage.usc.edu/brainstorm/Tutorials#Get_started|introduction tutorials]]. <> <> == Download and installation == * '''Requirements''': You have already followed all the introduction tutorials and you have a working copy of Brainstorm installed on your computer. * '''Additional programs''': You need to install the following programs to follow this tutorial: * '''SimNIBS''': [[https://neuroimage.usc.edu/brainstorm/Tutorials/FemMesh#SimNIBS|Description]] | [[https://simnibs.github.io/simnibs/build/html/installation/simnibs_installer.html|Download]] * '''BrainSuite''': Description | [[http://forums.brainsuite.org/download/|Download]] * '''MATLAB Runtime''': Follow the instructions on the BrainSuite download page * '''SPM12''': Install as [[https://neuroimage.usc.edu/brainstorm/Tutorials/Plugins|Brainstorm plugins]] * '''CAT12''': Install as [[https://neuroimage.usc.edu/brainstorm/Tutorials/Plugins|Brainstorm plugins]] * '''Iso2mesh''': Install as [[https://neuroimage.usc.edu/brainstorm/Tutorials/Plugins|Brainstorm plugins]] * '''Download the dataset''': * Go to the [[http://neuroimage.usc.edu/bst/download.php|Download]] page and get the file: '''sample_fem.zip''' * Unzip it outside of any of the Brainstorm folders (program folder or database folder) * '''Brainstorm''': * Start Brainstorm (Matlab scripts or stand-alone version) * Select the menu File > Create new protocol. Name it "'''TutorialFem'''" and select:<
>"'''No, use individual anatomy'''"<
>"'''No, use one channel file per condition'''". == Import the anatomy == === T1 MRI === * Switch to the "anatomical data" view, the left button in the toolbar above the database explorer. * Right-click on the TutorialFem folder > New subject > '''Subject01''' * Keep the default options you set for the protocol. * Right-click on the subject node > '''Import MRI''': * Set the file format: '''All MRI files (subject space)''' * Select the T1 file: sub-fem01/ses-mri/anat/'''sub-fem01_ses-mri_T1w.nii.gz''' * Click on the link "'''Click here to compute MNI normalization'''": option "'''maff8'''".<
>This estimates an affine transformation to the [[https://neuroimage.usc.edu/brainstorm/CoordinateSystems#MNI_coordinates|MNI space]] and sets default positions for the anatomical fiducials. Because we will use the digitized head shape of the subject to [[https://neuroimage.usc.edu/brainstorm/Tutorials/ChannelFile#Automatic_registration|refine the MRI/MEG registration]], we don't need the position of the fiducials to be very accurate.<
><
> {{attachment:importT1.gif}} === T2 MRI === * Right-click on the subject node > '''Import MRI''': * Set the file format: '''All MRI files (subject space)''' * Select the T2 file: sub-fem01/ses-mri/anat/'''sub-fem01_ses-mri_T2w.nii.gz''' * Brainstorm asks about registering the new T2 with the reference T1 image: * Select the option: '''SPM''' * Reslice the volume: '''Yes''' * This process will take few minutes, just be patient.<
><
> {{attachment:importT2.gif}} === Diffusion imaging === The FEM has the ability to incorporate anisotropic conductivity from MRI diffusion imaging, which is particularly interesting for the modeling of the white matter. Brainstorm can load the Diffusion-Weighted Images (DWI), and compute the tensors (DTI) using the [[Tutorials/FemTensors|BrainSuite Diffusion Pipeline]] (BDP). This requires BrainSuite to be installed on your computer, with the bdp program available in the system path. * Right-click on Subject01''' '''> '''Convert DWI to DTI''' * Select the DWI file: sub-fem01/ses-mri/dwi/'''sub-fem01_ses-mri_dwi.nii.gz''' * The associated files *dwi.bvec and *dwi.bval must be in the same folder. * The process can take up to 30min. At the end, a new file '''DTI-EIG''' appears in the database. This file contains 12 volumes, ie. 12 values for each voxel. From 1 to 9: components of the three eigenvectors; from 10 to 12: the values of their norm to the eigenvalue. <
><
> {{attachment:importDTI.gif}} == FEM head model == The FEM approach requires a segmentation of the head volume in different tissues, represented as hexahedral or tetrahedral 3D meshes. The methods available within Brainstorm are listed in the tutorial [[Tutorials/FemMesh|FEM mesh generation]]. This tutorial illustrates only the use of SimNIBS. === FEM mesh with SimNIBS === Running SimNIBS: * Select both the T1 and the T2 MRIs, using the mouse and the SHIFT or CTRL keys. * Right-click on the selected files > MRI segmentation > '''Generate FEM mesh''' > '''SimNIBS'''. Keep the default options. * This process can take 2-5 hours. * The output of SimNIBS is saved in the temporary folder $HOME/.brainstorm/tmp/simnibs, and then imported into the Brainstorm database. At the end of this computation, new files are available in the database: * '''tissues''': Segmentation of the head volume in 6 different tissues * '''head mask''': Outer surface of the scalp * '''cortex_280000V''': Pial surface generated by CAT12 within the SimNIBS process * '''cortex_15002V''': Low-resolution version of the pial surface * '''cortex_fem''': Outer surface mesh of the gray matter, extracted from the FEM mes * '''FEM 70000V''': Tetrahedral FEM mesh with 5 layers (gm, wm, CSF, skull, scalp). At the end of the process, make sure that the file "cortex_15002V" is selected (downsampled pial surface, which will be used for the source estimation). If it is not, double-click on it to select it as the default cortex surface. {{attachment:simnibs.gif}} === Remesh with Iso2mesh === In some cases, the FEM mesh generated with SimNibs causes issues with the DUNEuro FEM solver, due to the air cavities that are not tesselated. In order to avoid these possible issues in the next steps, we will correct the mesh using the Iso2mesh functions integrated within Brainstorm. * Richt click on the FEM mesh > '''Extract surfaces'''. * Hold the CTRL key to select all the extracted surfaces (white, gray, csf, skull, scalp). * Right-click > '''Generate FEM mesh''' > '''Iso2mesh-2021''' > '''MergeMesh''' > Max volume = '''0.001''', Percentage kept = '''100'''. Note that the higher the resolution leads to higher accuracy but also higher memory requirements and longer computation times.<
><
> {{attachment:remeshHeadIso2mesh.jpg||width="600",height="150"}} The following figure shows the two model, left is the initial model obtained with SimNibs, right is the second model obtained from the Iso2Mesh remesh: the air cavity in the bottom-right corner is now fully tesselated. Note that you can also use this process to generate FEM models with higher mesh densities. {{attachment:femMeshSimNibsVSiso2mesh2.jpg||width="600",height="150"}} === FEM tensors === We can now incorporate the diffusion information into the FEM model, and compute anisottropic conductivity tensors for the tetrahedral elements of the white matter (we consider the other tissues to have isotropic conductivities). * Right-click on the FEM mesh > '''Compute FEM tensors'''. Select the options as illustrated below, and refer to the tutorial [[Tutorials/FemTensors|FEM tensors]] for more information. <
><
>{{attachment:computeTensors.gif}} * This process can take up to 5min, depending on the resolution of the FEM mesh. === Visualisation of the FEM volume conductor === Brainstorms include the possibilities to display the FEM head models and the tensors, users can also overlay the display with the MRI as well as with the different surfaces. {{attachment:overlayModalities.png||width="600",height="150"}} The FEM tensors can be also displayed either on the mesh or on the MRI, to do so, right-click on the FEM mesh, then "Display FEM tensors", you can choose the displaying mode, the tensors can be displayed either as arrows (line) on the main eigenvector or as ellipsoids, on each FEM element (tetrahedron). {{attachment:dispTensorMenu.png||width="600",height="150"}} {{attachment:tensorsOnBrain.jpg||width="600",height="150"}} {{attachment:tensorsOnMRI.jpg||width="600",height="150"}} The size of the displayed tensors can be changed from the keyboard with the "Up" or "Down " arrows keys. You can also switch the display mode (from lines to ellipsoids to line or inversely) by using the shortcut "Shift + Space". ---- <> === On the hard disc === The "DTI-EIG" is saved structure as the Brainstorm MRI format, but it contains 12 values, from 1 to 9: components of the three eigenvectors, and from 10 to 12, the values of their norm to the eigenvalue. The FEM mesh, as shown in the figure, contains the following fields . Comment: 'FEM 722358V (simnibs, 5 layers)' . Vertices: number of vertices x3, the coordinates of the nodes Elements: number of element x4, list of the connectivity between nodes . Tissue: number of element x1, indexes or labels of the tissues, in Brainstorm the tissues are numbered from the inner to the outer layer (wm=1, gm=2, csf=3, skull=4, scalp=5) . TissueLabels: the labels of the tissues, {'white' 'gray' 'csf' 'skull' 'scalp'} . Tensors: number of elements ×12 if tensors are computed, otherwise it's empty. the 12 values are the eigenvalues and eigenvectors interpolated on each element of the mesh. . History: history of the processes applied on this file {{attachment:femDataOnHardDisc.png||width="600",height="150"}} === BEM head model === For the purpose of comparison between the FEM and the BEM, we will generate also the BEM surfaces for this subject and we will follow the same step as explained in [[https://neuroimage.usc.edu/brainstorm/Tutorials/TutBem?highlight=(bem)#Brainstorm|this page]]. The obtained surfaces will be used later for the BEM source computation. Richt-click on the subject01, then "MRI Segmentation" and then "Generate BEM surfaces", then keep the default options, Brainstorm, ('''1922 vertices) ''' for each layer and 4mm for the skull. Three new nodes appear in the database explorer, bem_head_1922V, bem_outerskull_1922V, and bem_innerskull_1922V. These surfaces will be used for the BEM forward computation. Now we have two head geometry available for this subject, BEM and FEM {{attachment:fem&bemModels.jpg|fem&bemModels.jpg|width="600",height="150"}} == Access the recordings == === Link the recordings === * Switch to the "functional data" view, the middle button in the toolbar above the database explorer. * You notice a folder with "eeg_postions" that contains an EEG cap, this folder is generated by the simnibs process. we will not use it in this tutorial. * Right-click on the subject folder > '''Review raw file''': * Select the file type: "MEG/EEG: Electa-Neuromag(*.fif)" * Navigate to the downloaded folder and select the file "subject01_median_nerve_L2_raw_tsss_anonymized.fif" * On the FIF event file, select "Event Channel", this will read the events markers * Apply the refine registration to the head points, click on yes. * A figure is opened to show the current registration MRI/MEG. It is already quite good for this dataset. The new file "Link to raw file" lets you access directly the contents of the MEG/EEG recordings. The "Neuromag channels(374)" contains the name of the channels and the position of the corresponding sensors (MEG/EEG) {{attachment:reviewMEEGsensors.jpg||width="600",height="150"}} === The channel file === * The recordings contain signals coming from different types of electrodes: * 306 MEG channels (102 magnetometers and 204 gradiometers ) * 64 EEG channels * 2 EOG channels: EO1 and EO2 * 1 Stim channel that contain the stimulation signals === Refine the MRI registration === * Right-click on the channel file > MRI registration > Edit... (EEG) * The white points are the electrodes, the green points are the additional digitized head points. To display the label of the electrodes, click on the [LABEL] button in the toolbar. To see what the other buttons in the toolbar are doing and how to use them, leave your mouse over them for a few seconds and read the description. * Now try to manipulate the position of the EEG+MEG sensors using '''rotations '''and '''translations '''only (no "resize" or individual electrodes adjustments). The objective is to have all the points close to the surface and the three forehead points inside the little peaks on the surface (due to markers in the MRI). * The rotation+translation is going to be applied both to the EEG and the MEG sensors. After you are done with this solid registration part, you can click on the button '''"Project electrodes on scalp surface"''', it will help for the source modeling later. The green points (digitized) stay in place, the white points (electrodes) are now projected on the skin of the subject. * If you feel like you didn't do this correctly, close the figure and cancel the modifications, then try again. It takes a few trials to get used to this rotation/translation interface. * Click on '''[OK]''' when done. * Answer '''YES''' to save the modifications. * Answer '''YES''' again to apply the solid transformation (rotation+translation) to the MEG sensors. * Now all the electrodes are projected on the surface. * (refine head with digitized points) {{attachment:MEEGsensors.jpg||width="600",height="150"}} === Pre-processing === * Drag and drop the "Link to raw file" into the Process1 list. * Select the process "'''Frequency > Power spectrum density'''", configure it as in the figure * After the computation, double-click on the new PSD file to display it. {{attachment:psd.jpg||width="600",height="500"}} * The lines on the top represent the EEG electrodes, the lines at the bottom the MEG sensors(MAG and GRAD). If you want to get clearer plots, you can calculate separately the spectrum for the two types of sensors separately, by running twice the process "Power spectrum density", once with sensor types = "MEG" and once with "EEG", instead of running in on both at the same time as we did. * Observations (below 250Hz): * Peak around 10Hz: Alpha waves from the subject's brain * Peaks at 60Hz, 120Hz, 180Hz, 240Hz on EEG + MEG: Power lines (60Hz+harmonics) * Most of the signal looks clean and no bad channel is observed * If we review quickly the EEG and EOG signals, we notice that they are quite clean and no artifacts are observed. The experiment is well designed and the subject was not moving the eyes (blinks and slow movements), maybe because there was a fixation cross for this experiment. However, we will apply at least a high-pass filter to make the signals easier to process (we are not interested in very low frequencies in this experiment). === Frequency filters === * In Process1, select the "Link to raw file". * Select process '''Pre-process > Band-pass filter''': Frequency='''[20, 250]Hz''', Sensors='''MEG,EEG''' * Add processs '''Pre-process > Notch filter''': Frequencies='''[60 120 180]Hz''', Sensors='''MEG,EEG''' {{attachment:freqFilters.jpg||width="600",height="500"}} * In Process1, select the filtered file "Raw | Band | Notch". * Run the process "'''Frequency > Power spectrum density'''", with the same options as before. And compare with the previous figure. You may find that the power line frequency and its harmonics are removed and the data is filtered between 20 and 250Hz. {{attachment:spectreClean.jpg||width="600",height="500"}} === EEG: Average reference === * Right-click on the filtered file "Raw|band|notch" > EEG > Display time series. * In the Record tab, menu '''Artifacts > Re-reference EEG''' > "AVERAGE". {{attachment:avgRef.jpg||width="600",height="500"}} At the end, the window "Select active projectors" is open to show the new re-referencing projector. Just close this window. To get it back, use the menu Artifacts > Select active projectors. To keep the interface clean and eeasy to follow, you may need also to remove the previous and keep only the last folder that inlude all the post-processing. === Epoching === In this experiment, the electric stimulation is sent with a frequency of 2Hz, meaning that the inter-stimulus interval is 500ms. We are going to import epochs of 300ms around the stimulation events (-100 to 200ms). * Right-click on the filtered file "Raw|band|notch" > '''Import in database''': * Check "'''Use events'''" and select "'''2'''", this is the name that brainstorm assigns for the stimulus onset, it may have different name on your computer. Set epoch time: '''[-100, 200]''' '''ms ''' and Apply SSP/ICA in order to apply the average reference. {{attachment:importEpochs.jpg||width="600",height="500"}} In the end, you are asked whether you want to ignore one epoch that is shorter than the others. This happens because the acquisition of the MEG signals was stopped less than 300ms after the last stimulus trigger was sent. Therefore, the last epoch cannot have the full [-100,200]ms time definition. This shorter epoch would prevent us from averaging all the trials easily. As we already have enough repetitions in this experiment (240), we can just ignore it. The total number of epochs is then 239. === Averaging === * Drag and drop all the Trigger01 trials to the Process1 tab. * Run the process '''Average > Average files''': By trial group (folder average) {{attachment:avrgEpochs.jpg||width="600",height="500"}} Review the average for the '''MEG''' and '''EEG''' as a topography plot -Right-click on the averaged signal -EEG (then MEG) > 2D disc {{attachment:megEegTopography.jpg||width="800",height="700"}} AT the selected time, an ERP is visible with a nice dipolar pattern on the sensors, both for the EEG and MEG. == Source estimation == We are going to use the realistic FEM head model, the one previously generated from the MRI as explained in sections above. Go to the "Anatomy" view, and make sure that the FEM head model is highlighted in green color (it should be the case if you have only one model). You may also highlight the cortex to use for the computation (select the cortex_15002V). '''IMPORTANT:''' You can compute the forward model both for EEG and MEG simultaneously, however, using the high mesh resolution model we recommend to compute separately the head model for each modality(EEG and then MEG). The time required for EEG is aound one hour for ~70 channles, for the MEG with 306 sensors it can take up to 4 hours or more (with the integrations points). The EEG/MEG FEM computation depends on the computation of the FEM transfer matrix, and the computation of this matrix is related to the resolution of the FEM head mesh (number of vertices) and the number of sensors. In most of the case, the number of EEG sensors is lower than the number of MEG sensors. Furthermore, internally the MEG sensors modeling uses the integrations points, which increase the number of computation points (~ multiplied by 4 for the magnetometers and by 8 for the gradiometers). Therefore the MEG requires more time than the EEG. To reduce the MEG computation time, there are some tips : 1. Use only the inners tissues (wm, gm, and CSF) ==> reduce the number of vertices 1. Do not use the integration points ==> reduce the number of virtual sensors 1. These parameters can be tuned from the DUNEuro Options panel (see the advanced panel) In this tutorial, we will separate the modalities. === EEG Head model with DTI tensors === * Go back to the "Functional data" view, right-click on the channel file > '''Compute head model''' * Select the DUNEuro FEM, change the comment to "DUNEuro FEM EEG DTI tensors", '''select only the EEG, ''' as shown in the panel * On the DUNEuro Options panel, click on the "Show details" button for more option * Set the DUNEuro option as shown in the following figure, and then click on "Ok" {{attachment:eegDuneuroPanels.jpg||width="600",height="300"}} The FEM EEG head modeling will start and depending on the performance and the workload of your computer, it can last between 30min to 2 hours. Once the computation is done, a new node with the name "DUNEuro FEM EEG DTI tensors" appear on the Brainstorm database navigator, which can be used for the source localization process. === MEG Head model with DTI tensors === * Go back to the "Functional data" view, right-click on the channel file > '''Compute head model''' * Select the DUNEuro FEM, change the comment to "DUNEuro FEM MEG DTI tensors", '''select only the MEG, ''' as shown in the panel * On the DUNEuro Options panel, click on the "Show details" button for more option * For this case (MEG), in order to reduce the computation, we will check only the inner layers (white, gray, and CSF). Not that this is true only for the MEG [ref]. * Set the DUNEuro option as shown in the following figure, and then click on "Ok" {{attachment:megDuneuroPanelsDTI.jpg||width="600",height="300"}} The FEM MEG head modeling will start and depending on the performance and the workload of your computer, it can last between 1hour to 4 hours (even more if you select all the tissues). Once the computation is done, a new node with the name "DUNEuro FEM MEG DTI tensors" appears on the Brainstorm database navigator, which can be used for the source localization process. === EEG Head model with isotropic conductivity === In the case where the DTIs are not available, or if the users want to use the isotropic conductivity, the following section explains how to do it. * First you need to make sure that the tensors are not computed * If you have the tensor computed, as in this tutorial, we need to clear these values. Go to the "Anatomy" view, right-click on the FEM head model, and then "Clear tensor" * Go back to the "Functional data" view, right-click on the channel file > '''Compute head model,''' and set the value as in the figures. * Compare to the previous panels, in this case, the DUNEuro options allow you to change the isotropic conductivity for each tissue. In this example keep the * Click on "Ok", then the FEM computation will start with the new value of the conductivities. {{attachment:eegDuneuroPanelsIso.jpg||width="600",height="300"}} === MEG Head model with isotropic conductivity === Same step as before, first you need to make sure that the tensors are not computed, * right-click on the channel file > '''Compute head model,''' and set the value as in the figures. * Compare to the previous panels, in this case, the DUNEuro options allow you to change the isotropic conductivity for each tissue. In this example keep only the inner tissues (wm, gm and csf) * Click on "Ok", then the FEM computation will start with the new value of the conductivities. {{attachment:megDuneuroPanelsIso.jpg||width="600",height="300"}} In this tutorial, for each modelity we have computed two forward models (isotropic and anisotrpic). This is a good option to compare if there is any difference between the isotropic model and the anisotropic model. === Noise covariance matrix === * We will use the baseline of the single epochs to calculate the noise covariance matrix. * Right-click on the Trigger01 epochs group > Noise covariance > '''Compute from recordings'''. Enter the same baseline interval we used for removing the DC offset: '''[-100, -10] ms''' {{attachment:noiseCovariance.jpg||width="600",height="300"}} === Inverse model === * Right-click on the head model > '''Compute sources'''. * Select "Dipole modeling option" and '''EEG'''. Repeat the same operation for '''MEG''' and make sure to select the appropriate head model at each step. {{attachment:computeDipolesInverseAll.jpg||width="600",height="300"}} It is better to study separately the two modalities because the method for combining MEG and EEG are not working well yet within Brainstorm. This operation creates a shared inversion kernel and one source link for each block of recordings in the folder. {{attachment:sharedKernelDipolesEegMeg.jpg||width="600",height="300"}} Drag and drop the Dipoles kernels in the Process table and select the process > Run> Dipole Scanning> {{attachment:dipoleScanningProcess.jpg||width="600",height="300"}} If you are not familiar with those concepts, please refer to the [[https://neuroimage.usc.edu/brainstorm/Tutorials/SourceEstimation|Source estimation tutorial]]. Once the dipoles are computed, we display both EEG and MEG separately in the following figures. We merge the MEG ISO and the MEG DTI dipoles as well as the EEG dipoles. {{attachment:dipolesMergeEEG&MEG.jpg|dipolesMergeEEG&MEG.jpg|width="600",height="300"}} === P20/N20 source localization === The following figures (left EEG, right MEG), show the localization of the dipoles on the MRI at the 21ms. The ISO model is colored in greeen wherease the DTI model is colored in red. {{attachment:eegMegDipolesSagittal.jpg||width="600",height="300"}} {{attachment:eegMegDipolesAxial.jpg||width="600",height="300"}} {{attachment:eegMegDipolesCoronal.jpg||width="600",height="300"}} In this experiment, the anisotropy does not show a significant effect on the source localization, whereas it shows a slich difference in the orientation. When we compare between the EEG and the MEG, there is a difference of 20mm between the localization between the MEG and the EEG as well as a difference in the orientation in the coronal view. If we compare the difference between the EEG and MEG dipoles, the following figures (left anisotropy, right isotropic), show the localization of the dipoles on the MRI at the 21ms. The EEG dipole is colored in green wherease the MEG dipole is colored in red. {{attachment:eegMegDipolesSagittal2.jpg||width="600",height="300"}} {{attachment:eegMegDipolesAxial2.jpg||width="600",height="300"}} {{attachment:eegMegDipolesCoronal2.jpg||width="600",height="300"}} Aniso: Eeg [-7.5 -35.7 89.8] vs Meg [-0.2 -33.6 88.6] ==> '''distance = 7.7mm ''' Iso: Eeg [-7.5 -35.7 89.8] vs Meg [-0.2 -33.6 88.6] ==> '''distance = 7.7mm ''' In both modalities, the dipoles are located exactely in the same positions, and there is 7.7mm between the two dipoles. Further more, we notice a difference on the orientation on the coronal and sagital views === Comparaison with BEM for EEG and with OS for the MEG === In order to compare qualitatively the results of the FEM models, we will use the previous methods already implemented in Brainstorm. For the EEG: compute the forward using the BEM For the MEG: compute the forward using overlapping spheres, For all the methods, we will perform the dipole scanning as done previously but with the new forward models, the results are shown in the following figures: In the following figures, left is the dipoles computed from the EEG (BEM in red and FEM in green), right are the dipoles computed from the MEG (OS in red and FEM in green) {{attachment:eegMegDipolesSagittal3.jpg||width="600",height="300"}} {{attachment:eegMegDipolesAxial3.jpg||width="600",height="300"}} {{attachment:eegMegDipolesCoronal3.jpg||width="600",height="300"}} EEG: fem [-7.5 -35.7 89.8] ; bem [-10.7 -35.0 89.5] ==> '''3.3mm''' MEG: fem [-0.2 -33.6 88.6] ; os [-10.7 -39.3 83.2] ==> '''13.1 mm''' As expeced, the slight difference on the localization can be explained by the difference on the head shape, the conductivity values as well as the resolution method. <> === Resect the neck and the bottom part of the head model === The FEM computation can be time and memory-consuming, on way to reduce this issue is to remove the part of the FEM mesh that is not required. In some cases where the field of the MRI is large, you can have the mesh of the neck and even the shoulders. In Brainstorm, it is possible to remove these parts. You can this by following these steps : right-click on the FEM-mesh => Resect Neck ==> keep the default value ==> Ok ---- {{attachment:resectNeck.JPG||width="600",height="150"}} ---- Once the process is finished, a new FEM head model appears in the database with the same name and a prefix "resect" which is the resected head. The following figure shows the model before and after re-section. {{attachment:FemMeshAllandResect.JPG||width="600",height="150"}} Note that the initial model has 743828 nodes and 4079587 and the resected model has 613955 nodes and 3400957 elements. == Scripting == This section is under devellopement == DUNEuro advanced options == This section is under development A set of advanced options are made available and can be easily changed. Here a short explanation is given for each option. * '''FEM''' layers & conductivities: same explanation as in the previous section. Moreover, in the case where the conductivity tensor are previously computed, Brainstorm detects these tensors and load them. In this case, the users can't change the conductivities scalar values, since they are not used. The following is displayed panel is displayed. * '''FEM''' solver type: * CG or Continuous Galerkin: This is the standard Lagrangian method. * DC or the Discontinuous Galerkin: In this version, only the Fitted '''FEM''' approaches are integrated, that require the '''FEM''' mesh of the head model. Unfitted methods are also available within DUNEuro, and will be integrated soon in Brainstorm. * '''FEM''' source model: The list of the available source are * Venant * Subtraction * Partial Integration For more information about these methods, users can check this thesis (Vorwek thesis). * Source space * Shrink source space: the location of dipoles are moved inward by the specified value in this field(in mm). * Force source space: this is required in the case where the dipoles are not within the GM matter. * Outputs options * Save transfer matrix: All these parameters are stored and passed to the DUNEuro as a text file. This file is the main interface that passes the parameters from Brainstorm to DUNEuro. More details about the integration can be found in these links: * GitHub repository for the [[https://github.com/brainstorm-tools/bst-duneuro|Brainstorm-DUNEuro]] compilation and integration * GitHub repository for the [[https://github.com/tmedani/duneuro_interface|matlab-duneuro interface]] * Brainstorm-DUNEuro integration discussions: * [[https://github.com/brainstorm-tools/brainstorm3/issues/185|Brainstorm-simbio/DUNEuro implementation]]/head model generation * [[https://github.com/brainstorm-tools/brainstorm3/issues/242|Integrate the DUNEuro FEM computation]] * [[https://github.com/brainstorm-tools/brainstorm3/pull/282|Genration of the FEM tensor]] * [[https://github.com/brainstorm-tools/brainstorm3/issues/302|Generation of the FEM source space]] == Troubleshooting and solution(TODO) == Dipoles outside of the grid for the MEG: remove this dipole or replace it with its spatial neighbors (not the neighbor in the list) ==> not easy to handle write small tuto?