diff --git a/_includes/shared/tutorial/headmodel_background.md b/_includes/shared/tutorial/headmodel_background.md index b1a9478b7..06a198028 100644 --- a/_includes/shared/tutorial/headmodel_background.md +++ b/_includes/shared/tutorial/headmodel_background.md @@ -1,3 +1,3 @@ -In FieldTrip a volume conduction model is represented as a MATLAB structure which is usually indicated with the variable name **vol**. It describes how the currents flow through the tissue, not where they originate from. In general it consists of a description of the geometry of the head, a description of the conductivity of the tissue, and mathematical parameters that are derived from these. Whether and how the mathematical parameters are described depends on the computational solution to the forward problem either by numerical approximations, such as the boundary element and finite element method (BEM and FEM), or by exact analytical solutions (e.g., for spherical models). +A volume conduction model of the head, also known as a head model, is represented in FieldTrip as a MATLAB structure. It describes how the currents flow through the tissue, not where they originate from. In general it consists of a description of the geometry of the tissue(s), a description of the conductivity of the tissue(s), and mathematical parameters that are derived from these. Whether and how the mathematical parameters are described depends on the computational solution to the forward problem either by numerical approximations, such as the boundary element and finite element method (BEM and FEM), or by exact analytical solutions (e.g., for spherical models). The more accurate the description of the geometry of the head or the source, the better the quality of the forward model. There are many types of head models which, to various degrees, take the individual anatomy into account. The different head models available in FieldTrip are listed [here](/faq/what_kind_of_volume_conduction_models_are_implemented). diff --git a/_includes/shared/tutorial/sourcelocalization_background.md b/_includes/shared/tutorial/sourcelocalization_background.md index 3b18fb40d..b336626ac 100644 --- a/_includes/shared/tutorial/sourcelocalization_background.md +++ b/_includes/shared/tutorial/sourcelocalization_background.md @@ -1,18 +1,18 @@ The EEG/MEG signals measured on the scalp do not directly reflect the location of the activated neurons. To reconstruct the location and the time-course or spectral content of a source in the brain, various source-localization methods are available. You can read more about the different methods in review papers suggested [here](/references_to_implemented_methods#references_to_review_papers). -The level of the activity at a source location is estimated from +The activity in the brain responsible for the EEG or MEG signals is estimated from 1. the EEG/MEG activity measured on or around the scalp 2. the spatial arrangement of the electrodes/gradiometers (**sensor positions**), 3. the geometrical and conductive properties of the head (**head model**) 4. the location of the source (**source model**) -Using this information, source estimation comprises two major steps: (1) Estimation of the potential or field distribution for a known source and for a known model of the head is referred to as **forward modeling**. (2) Estimation of the unknown sources corresponding to the measured EEG or MEG is referred to as **inverse modeling**. +Using this information, source estimation comprises two major steps: (1) Estimation of the EEG potential or MEG field distribution for a known source is referred to as **forward modeling**. (2) Estimation of the unknown sources corresponding to the measured EEG or MEG is referred to as **inverse modeling**. -The forward solution can be computed when the head model, the sensor positions and the source is given. For distributed source models and for scanning approaches (such as beamforming), the source model is discretizing the brain volume into a volumetric or surface grid. When the forward solution is computed, the **lead field matrix** (= channels X source points matrix) is calculated for each grid point taking into account the head model and the sensor positions. +The forward solution can be computed when the head model, the sensor positions and the model for the source are given. For distributed source models and for scanning approaches (such as beamforming), the source model consists of a discrete description of the the brain volume or of the cortical sheet in many voxels or vertices. When the forward solution is computed, the **lead field matrix** (= channels X source points matrix) is calculated for each point, taking into account the head model and the sensor positions. -A prerequisite of forward modeling is that the geometrical description of all elements (sensor positions, head model and source model) is registered in the same coordination system with the same units. There are different "conventions" how to define a coordinate system, but the precise coordinate system is not relevant, as long as all data is expressed in it consistently (i.e. in the same coordinate system). [Here](/faq/coordsys) read more about how the different head and mri coordinate systems are defined. The MEG sensors by default are defined relative to anatomical landmarks of the head (the fiducial coils), therefore when the anatomical images are also aligned to these landmarks, the MEG sensors do not need to be re-aligned. EEG data is typically not aligned to the head, therefore, the electrodes have to be re-aligned prior to source-reconstruction (see also [this faq](/faq/how_to_coregister_an_anatomical_mri_with_the_gradiometer_or_electrode_positions) and [this example](/example/electrodes2bem)). +A prerequisite of forward modeling is that the geometrical description of all geometrical elements (sensor positions, head model and source model) is registered in the same coordination system and expressed with the same units (mm, cm, or m). There are different conventions for coordinate systems. The precise coordinate system is not relevant, as long as all data is expressed consistently. [Here](/faq/coordsys) you can read more about how the different head and MRI coordinate systems are defined. For most MEG systems, the gradometer sensors are by default defined relative to head localizer coils or anatomical landmarks, therefore when the anatomical MRI are aligned to the same landmarks, the position of the MEG sensors matches the MRI. EEG data is typically not explicitly aligned relatively to the head, therefore, the EEG electrodes also have to be re-aligned prior to source reconstruction (see also [this faq](/faq/how_to_coregister_an_anatomical_mri_with_the_gradiometer_or_electrode_positions) and [this example](/example/electrodes2bem)). -{% include image src="/assets/img/shared/tutorial/sourcelocalization_background/figure1.png" width="500" %} +{% include image src="/assets/img/shared/tutorial/sourcelocalization_background/figure1.png" width="600" %} -_Figure 1. Major steps in source reconstruction_ +_Figure 1. Overall outline of the pipeline used for source reconstruction_ diff --git a/assets/img/shared/tutorial/sourcelocalization_background/figure1.png b/assets/img/shared/tutorial/sourcelocalization_background/figure1.png index 936bc7347..6804456f0 100644 Binary files a/assets/img/shared/tutorial/sourcelocalization_background/figure1.png and b/assets/img/shared/tutorial/sourcelocalization_background/figure1.png differ diff --git a/assets/img/tutorial/headmodel_eeg_bem/figure1.png b/assets/img/tutorial/headmodel_eeg_bem/figure1.png index 47fa4420c..2e1b28565 100644 Binary files a/assets/img/tutorial/headmodel_eeg_bem/figure1.png and b/assets/img/tutorial/headmodel_eeg_bem/figure1.png differ diff --git a/faq/homogenous.md b/faq/homogenous.md index a51136fc4..ce69b4fd2 100644 --- a/faq/homogenous.md +++ b/faq/homogenous.md @@ -5,12 +5,19 @@ tags: [faq, coordinate] # How do homogenous coordinate transformation matrices work? Or how do I get the coordinates for a specific voxel? -The documentation of the [AIR](http://air.bmap.ucla.edu/AIR5) software by Roger P. Woods provides a very nice description of [homogenous coordinates](http://air.bmap.ucla.edu/AIR5/homogenous.html). Another, perhaps more accessible description can be found on the [brainvoyager website](https://www.brainvoyager.com/bv/doc/UsersGuide/CoordsAndTransforms/SpatialTransformationMatrices.html). +A coordinate system specifies the interpretation of how points are expressed in 3D space. This makes use of the three numbers (x, y, z) that represent the point, relative to a known origin (0,0,0), and making use of cardinal x-, y-, and z-axes that are pointing into a specific direction such as towards the nasion, or from the [posterior to the anterior commissure](/faq/acpc/). -The long story short is, that a homogen(e)ous transformation matrix allows you to toggle between 3-dimensional points in space that are expressed in different coordinate systems (i.e. the points are expressed relative to an origin (with coordinate (0,0,0)), and where the three (orthogonal) coordinate axes are pointing into a specific direction). The conversion is achieved by simple matrix multiplication, as described in detail by one of the links above. +A homogenous transformation matrix allows you to transform 3D points from one coordinate system to another. The conversion is achieved by simple matrix multiplication, as described in detail in the documentation of the [AIR](http://air.bmap.ucla.edu/AIR5) software by Roger P. Woods. This provides a very complete description of [homogenous coordinates](http://air.bmap.ucla.edu/AIR5/homogenous.html). Another, perhaps more accessible description can be found on the [brainvoyager website](https://www.brainvoyager.com/bv/doc/UsersGuide/CoordsAndTransforms/SpatialTransformationMatrices.html). -In FieldTrip, as in many other software packages that deal with volumetrically defined data, we use a homogen(e)ous coordinate transformation matrix to describe the relation between voxels in the volumetric image, and real world coordinates (typically a coordinate system that is defined based on the anatomy of the experimental subject). In FieldTrip, a **[volume data object](/reference/utilities/ft_datatype_volume)** always contains a `transform` field that maps from voxel indices to the coordinate system, which, if it is known, is specified in the `coordsys`. You can read more about coordinate systems [here](/faq/coordsys). The convention is that the indexing of the voxels starts with 1, i.e. the first voxel in the volume is described by the indices [1,1,1]. Thus, if you want to obtain the real world coordinate of a voxel with indices (i,j,k), you have to perform the following multiplication: +In FieldTrip, as in many other software packages that deal with volumetrically defined data, we also use a homogen(e)ous coordinate transformation matrix to describe the relation between voxels in the volumetric data, and real-world or "head" coordinates. The [real-world coordinates](/faq/coordsys) are usually related to anatomical landmarks and the voxel coordinates are directly related to the 3D array with the grey-scale numbers that represent the MRI images. - coord = T * [i;j;k;1]; +The FieldTrip data structure that describes **[volumetric data](/reference/utilities/ft_datatype_volume)** includes a `transform` field with the homogenous 4x4 trasformation matrix that maps from voxel indices to the head (or device) coordinate system. If the head coordinate system is known, it is specified in the `coordsys` field. -The variable `T` is the transform field of the data structure, and the first 3 elements of the `coord` vector are the (x,y,z) coordinates of the voxel-of-interest. +Indexing of numerical arrays in MATLAB starts with 1, i.e., the first voxel in the volume is described by the indices (1,1,1). Thus, if you want to obtain the real world coordinate of a voxel with indices (i,j,k), you have to perform the following multiplication: + + voxpos = [i j k 1]' + headpos = transform * voxpos + +The first 3 elements of the resulting `headpos` vector correspond to the (x,y,z) coordinates in the head coordinate system. + +Note that, if the MRI comes directly from the scanner, it still is expressed in DICOM or in NIFTI scanner coordinates, and not relative to actual anatomical landmarks of the individual participant whose data is represented in the MRI. diff --git a/faq/how_to_coregister_an_anatomical_mri_with_the_gradiometer_or_electrode_positions.md b/faq/how_to_coregister_an_anatomical_mri_with_the_gradiometer_or_electrode_positions.md index 9c7c0cf22..955d77fb1 100644 --- a/faq/how_to_coregister_an_anatomical_mri_with_the_gradiometer_or_electrode_positions.md +++ b/faq/how_to_coregister_an_anatomical_mri_with_the_gradiometer_or_electrode_positions.md @@ -5,10 +5,24 @@ tags: [faq, eeg, meg, mri, headmodel, source, coordinate] # How to coregister an anatomical MRI with the gradiometer or electrode positions? -In general, anatomical volumes are represented in FieldTrip as a MATLAB-structure, containing the anatomical (and if applicable also the functional) information in a 3D numeric matrix, and a [4x4] affine transformation matrix. The 4x4 homogenous transformation matrix specified how to go from voxel space to source space. When the anatomical image is read in using **[ft_read_mri](/reference/fileio/ft_read_mri)**, a transformation is attached to the data structure. This transformation matrix is extracted from the file. If this is not possible, FieldTrip assumes the transformation to be an identity matrix. Importantly, the assumption is that the transformation matrix and the voxel coordinate system are consistent between one another. Typically, when doing source reconstruction, we work with real world coordinate systems that are defined relative to the participant's head. When the anatomical images are coming off the scanner, they lack such a coordinate system, so this needs to be added to the data. Most MEG systems come with software to convert DICOM files to a MEG-system specific MRI file format. That software then also takes care of aligning the MRI with the helmet location. e.g., for CTF this is done with MRIConverter and MRIViewer. FieldTrip can read the MRI files that are generated using the MEG-system specific software, and if you use those, the alignment is taken care of outside FieldTrip. In case the alignment is not done with external software, or if you want to read the DICOM files directly, the **[ft_volumerealign](/reference/ft_volumerealign)** function can be used after **[ft_read_mri](/reference/fileio/ft_read_mri)**. +In general, volumetric data such as anatomical MRIs are represented in FieldTrip as a MATLAB-structure, containing the anatomical (and if applicable also the functional) information in a 3D numeric matrix, combined with a 4x4 affine transformation matrix. The 4x4 transformation matrix specified how to go from voxel space to source space, as explained in this [frequently asked question](/faq/homogenous). + +When reading anatomical data with **[ft_read_mri](/reference/fileio/ft_read_mri)**, the transformation is extracted from the MRI file. In the case that the MRI has not been processed, it is likely that the coordinate system corresponds to DICOM or in NIFTI scanner coordinates, which do _not_ relate the coordinates to the actual anatomy represented in the data. + +You can read more about how the different coordinate systems relate to the anatomy and/or to the scanner hardware in this [frequently asked question](/faq/coordsys). + +## MEG + +When reading MEG data from the original files, the gradiometer sensor data is automatically read along with the channel timeseries. With most MEG systems the sensor positions are automatically expressed relative to head localization coils that are placed on the head relative to well-defined anatomical landmarks. The `coordsys` option in **[ft_read_sens](/reference/fileio/ft_read_sens)** also allows you to get the sensor positions relative to the device or dewar. + +For source reconstruction we need to express all geometrical data in a consistent coordinate system that is defined relative to the participant's head. In FieldTrip it is common to do MEG source reconstruction in the coordinate system of the MEG acquisition device. Consequently, the MRI needs to be updated using **[ft_volumerealign](/reference/ft_volumerealign)** so that it is expressed relative to the same anatomical landmarks as the MEG data. {% include markup/danger %} -In its default behavior **[ft_volumerealign](/reference/ft_volumerealign)** creates a transformation matrix from fiducials/landmarks using a right-handed convention. If the input data is defined in a left-handed coordinate system, the resulting transformation matrix may be incorrect (when supplying only 3 fiducial locations). However, it is possible to define a 4th point in ft_volumerealign (using the 'z' key) that should be a point in the positive z-direction. Using this information, the correct transformation can be constructed. +Other MEG analysis software may use other conventions. For example in MNE-Python it is common to do MEG source reconstruction in a coordinate system that is the result of the Freesurfer pipeline which is used to extract the cortical sheet. That means that, rather than aligning the MRI to the MEG, it aligns the MEG to one of the Freesurfer outputs. {% include markup/end %} -EEG acquisition systems typically do not come with software to deal with anatomical MRIs, so you should read the MRI file(s) with **[ft_read_mri](/reference/fileio/ft_read_mri)** and use **[ft_volumerealign](/reference/ft_volumerealign)** to specify the position of the fiducials. The same fiducials should then be specified in **[ft_electroderealign](/reference/ft_electroderealign)** to ensure that both electrodes and anatomical MRI are expressed in the same head-coordinate system. See also the FAQ on the [definition of the various head and MRI coordinate systems](/faq/coordsys). +## EEG + +EEG systems typically do not include an integrated way to record ans store EEG electrode positions. Although separate 3D tracking systems (e.g., Polhemus, Optotrack, Structure Sensor) can be used to record the electrode positions, the electrode positions are usually not stored directly along with the EEG data. So when reading the EEG data from disk, the position of the EEG electrodes is usually not known. + +For EEG it is therefore common to use **[ft_read_mri](/reference/fileio/ft_read_mri)** and **[ft_volumerealign](/reference/ft_volumerealign)** to place the anatomical MRI in a well-defined coordinate system, and to use **[ft_read_sens](/reference/fileio/ft_read_sens)** and **[ft_electroderealign](/reference/ft_electroderealign)** to place the electrodes in the same coordinate system. diff --git a/template/headmodel.md b/template/headmodel.md index 97c79de59..ad78adedb 100644 --- a/template/headmodel.md +++ b/template/headmodel.md @@ -1,17 +1,17 @@ --- -title: Template head models for forward volume conduction modeling +title: Template head models for EEG volume conduction modeling tags: [template, headmodel] --- -# Template head models for forward volume conduction modeling +# Template head models for EEG volume conduction modeling -Volume conduction models of the head are a necessary ingredient for source reconstruction. Sources are typically modeled as equivalent current dipoles (ECDs), i.e. point sources with a location and orientation. These sources produce an electrical current that flows through all surrounding tissue. The geometrical and conductive aspects of the tissue influence how the source becomes visible in the EEG or MEG. +Volume conduction models of the head are a necessary ingredient for source reconstruction. Sources are typically modeled as equivalent current dipoles (ECDs), i.e. point sources with a location and orientation. These sources produce an electrical current that flows through all surrounding tissue. The geometrical and conductive aspects of the tissue influence how the source becomes visible in the EEG. {% include markup/warning %} You can find the template head models included in FieldTrip [here](https://github.com/fieldtrip/fieldtrip/tree/master/template/headmodel). {% include markup/end %} -## standard_bem +## standard_bem.mat This file contains a standard Boundary Element Method volume conduction model of the head that can be used for EEG forward and inverse computations. The geometry is based on the "colin27" template that is described further down. The BEM model is expressed in MNI coordinates in mm. @@ -19,9 +19,9 @@ The BEM model is based on the segmentation from [BrainWeb: Anatomical Model of N Accompanying electrode positions according to the 10-20, the 10-10 and the 10-5 standards (with different naming schemes) can be found in the `template/electrode` directory. -## standard_mri +## standard_mri.mat -The original construction of the averaged "“colin27”" MRI is detailed in [here](https://www.bic.mni.mcgill.ca/ServicesAtlases/Colin27) and in the publication from Holmes et al. in [J Comput Assist Tomogr. 1998 Mar-Apr;22(2):324-33](http://www.ncbi.nlm.nih.gov/pubmed/9530404). +This complements the standard BEM head model. The original construction of the averaged "“colin27”" MRI is detailed in [here](https://www.bic.mni.mcgill.ca/ServicesAtlases/Colin27) and in the publication from Holmes et al. in [J Comput Assist Tomogr. 1998 Mar-Apr;22(2):324-33](http://www.ncbi.nlm.nih.gov/pubmed/9530404). The relation of the "colin27" MRI to the Talairach-Tournoux atlas and to the MNI and SPM templates is described in detail [here](http://imaging.mrc-cbu.cam.ac.uk/imaging/MniTalairach). A small excerpt follows: @@ -43,14 +43,14 @@ As of August 23, 2018, the hdr-field has been removed from the data structures i ## skin -This directory contains a triangulated high-resolution geometrical description of the skin surface. This skin surface is not used in the BEM model itself for computational reasons, but can be used for visualization. It is expressed in MNI coordinates in mm. +This directory contains a triangulated high-resolution geometrical description of the skin surface. This skin surface is not used in the BEM model itself for computational reasons, but can be used for visualization. It is expressed in [MNI coordinates](/faq/coordsys/#details-of-the-mni-coordinate-system) in mm. You can visualize it with >> skin = ft_read_headshape('standard_skin_14038.vol') skin = - pnt: [14038x3 double] + pos: [14038x3 double] fid: [1x1 struct] tri: [28072x3 double] unit: 'mm' diff --git a/tutorial/headmodel_eeg_bem.md b/tutorial/headmodel_eeg_bem.md index 4a2c743f3..d5d05cfab 100644 --- a/tutorial/headmodel_eeg_bem.md +++ b/tutorial/headmodel_eeg_bem.md @@ -7,9 +7,9 @@ tags: [tutorial, eeg, source, headmodel, mri, plotting, meg-language] ## Introduction -In this tutorial you can find information about how to construct a Boundary Element Method (BEM) volume conduction model of the head (head model) based on a single subject's MRI. We will use the anatomical images that belong to the same subject whose data was analyzed in other tutorials. The anatomical MRI data is included in the [Subject01.zip](https://download.fieldtriptoolbox.org/tutorial/Subject01.zip) MEG dataset. +In this tutorial you can find information about how to construct a Boundary Element Method (BEM) volume conduction model of the head, also known as head model, based on an individual subject's anatomical MRI. For didactic resons we will use the anatomical MRI corresponding to the data that was also analyzed in other tutorials. The anatomical MRI data is included in the [Subject01.zip](https://download.fieldtriptoolbox.org/tutorial/Subject01.zip) MEG dataset. -The volume conduction model shown here is EEG specific. In reality, we do not have corresponding EEG data to the anatomical MRI we use in this tutorial, but we will use a template EEG set to demonstrate how to build a head model for EEG and how to align the electrodes to anatomical data. Different strategies can be used for the construction of head models. The processing pipeline of the tutorial is an example which we think is the most appropriate for the tutorial-dataset. +In reality we did _not_ record EEG data for this subject. To demonstrate the EEG volume conduction model, we will "cheat" and use an EEG dataset from another recording in which we did not have an anatomical MRI. Although this results in a bit of a Frankenstein dataset, it does allows us to demonstrate how to build an EEG head model and how to align the electrodes. This tutorial will **not** show how to perform the source reconstruction itself. If you are interested in source reconstruction methods, you can go to the [Localizing oscillatory sources using beamformer techniques](/tutorial/beamformer) and to the [Source reconstruction of event-related fields using minimum-norm estimate](/tutorial/minimumnormestimate) tutorials. @@ -19,40 +19,43 @@ Furthermore, if you are interested in MEG head models, you can go to the corresp {% include /shared/tutorial/sourcelocalization_background.md %} -This tutorial is focusing on how to build the **volume conduction model for the head**. +This tutorial is focusing on how to build the **volume conduction model for the head**, which is also known as the **head model**. {% include /shared/tutorial/headmodel_background.md %} {% include markup/info %} -If an anatomical MRI is not available for your EEG subject, you can consider to use a template MRI or a template head model that is located in the FieldTrip template directory. See [here](/template/headmodel) for more info. +If you do not have an MRI for your subject, you can consider to use a template MRI or a template head model that is located in the FieldTrip `template` directory. See [here](/template/headmodel) for more info. -If you do not have an MRI, but do have a measurement of the scalp surface or electrodes (e.g., with a Polhemus tracker), you can fit a concentric spheres volume conduction model to the scalp. +If you do not have an MRI but do have a measurement of the scalp surface and/or of the electrodes (e.g., with a Polhemus tracker), you can also fit a concentric spheres model to the scalp and/or electrodes. However, we recommend to use a realistic template head model and fit the measured electrodes to the template head model rather than the other way around. {% include markup/end %} ## Procedure -Here, we will work towards a volume conduction model of the head based on the boundary element method (BEM). The BEM model assumes realistic information (of a certain degree) about the interface between the skin, skull and brain surfaces. First, we will use an anatomical MRI to extract these surfaces. This procedure is termed **segmentation**. Following the segmentation, a description of each surface using vertices and triangles is constructed. Finally, the BEM model will be computed. +Here, we will work towards a volume conduction model of the head based on the boundary element method (BEM). The BEM makes use of the realistic shjape of the interfaces (the boundaries) between the skin, skull and brain surfaces. The outline is that we will classify each of the voxels in an anatomical MRI as one of the known tissue types; this is termed **segmentation**. Following the segmentation, we construct a triangulated mesh that describes each surface. Finally, the BEM model will be computed. -The anatomical mri of the [tutorial data set](/tutorial/meg_language) is available [here](https://download.fieldtriptoolbox.org/tutorial/Subject01.zip). Although we did not record EEG in this particular language study, we will nevertheless use it as example MRI to make an EEG volume conduction model. +The anatomical MRI of the [tutorial data set](/tutorial/meg_language) is available [here](https://download.fieldtriptoolbox.org/tutorial/Subject01.zip). Although we did not record EEG in this particular language study, we will nevertheless use it as example MRI to make an BEM volume conduction model for EEG. -- First, we will read the anatomical data with **[ft_read_mri](/reference/fileio/ft_read_mri)**; -- then we segment the anatomical information into different tissue types with **[ft_volumesegment](/reference/ft_volumesegment)**; -- triangulate the surfaces with **[ft_prepare_mesh](/reference/ft_prepare_mesh)**; -- and create the headmodel with **[ft_prepare_headmodel](/reference/ft_prepare_headmodel)**. -- Finally, we will check the geometry of the head model by plotting it with **[ft_plot_mesh](/reference/plotting/ft_plot_headmodel)**. +- we read the anatomical data with **[ft_read_mri](/reference/fileio/ft_read_mri)** +- if needed, we use **[ft_volumerealign](/reference/ft_volumerealign)** to align the MRI with the desired coordinate system +- if needed, we use **[ft_volumereslice](/reference/ft_volumereslice)** to ensure that the voxels are isotropic +- we segment the anatomical information into different tissue types with **[ft_volumesegment](/reference/ft_volumesegment)** +- we triangulate the boundaries between the tissues with **[ft_prepare_mesh](/reference/ft_prepare_mesh)** +- we create the headmodel with **[ft_prepare_headmodel](/reference/ft_prepare_headmodel)** + +Throughout the process we use **[ft_sourceplot](/reference/ft_sourceplot)**, **[ft_plot_mesh](/reference/plotting/ft_plot_mesh)** and **[ft_plot_headmodel](/reference/plotting/ft_plot_headmodel)** to check that each of the steps was executed correctly. {% include image src="/assets/img/tutorial/headmodel_eeg_bem/figure1.png" %} -_Figure 2. Pipeline of creating a BEM model_ +_Figure 2. Pipeline for creating a BEM model_ -## Reading in the anatomical data +### Reading in the anatomical data Before starting with FieldTrip, it is important that you set up your [MATLAB path](/faq/should_i_add_fieldtrip_with_all_subdirectories_to_my_matlab_path) properly. cd ft_defaults -Then, you can read in the mri data. +Then, you can read in the anatomical MRI data. mri = ft_read_mri('Subject01.mri'); @@ -63,47 +66,46 @@ Then, you can read in the mri data. transform: [4x4 double] coordsys: 'ctf' -The structure of your mri variable contains the following field +The structure of the `mri` variable contains the following fields: -- **dim**: This field gives information on the size (i.e. the number of voxels) of the anatomical volume into each direction. -- **anatomy**: This is a matrix (with the size and number of dimensions specified in **dim**) that contains the anatomical information represented by numbers. -- **hdr**: Header information of the anatomical images. -- **transform**: A homogenous [transformation matrix](/faq/how_change_mri_orientation_size_fov) that aligns the anatomical data (in field **anatomy**) to a certain coordinate system. -- **coordsys**: The description of the coordinate system which the anatomical data is aligned to. +- `dim` gives information on the size (i.e. the number of voxels) of the anatomical volume into each direction +- `anatomy` is a matrix (with the size and number of dimensions specified in `dim`) that contains the anatomical information +- `hdr` contains the detailled header information from the original file, it contents vary, depending on the file format +- `transform` is a homogenous [transformation matrix](/faq/homogenous) that allows expressing the voxel positions (in the field `anatomy`) in a certain coordinate system +- `coordsys` specifies the coordinate system -You can see that the **coordsys** field of anatomical data that we read in is already aligned to the [ctf coordinate system](/faq/coordsys#details_of_the_ctf_coordinate_system). +You can see that in the data we just read in the `coordsys` specifies that it is already aligned to the [CTF coordinate system](/faq/coordsys#details-of-the-ctf-coordinate-system). -{% include markup/info %} -Later in this tutorial, we will segment the anatomical MRI. Segmentation works properly when the voxels of the anatomical images are homogenous (i.e. the size of the voxel is the same into each direction). If you do not have homogenous voxels (or you are not sure of), you can use the **[ft_volumereslice](/reference/ft_volumereslice)** function on the anatomical data before segmentation. Read more about re-slicing [here](/faq/how_change_mri_orientation_size_fov). -{% include markup/end %} +### Align the MRI to the head coordinate system -## Align MRI to the head coordinate system +The EEG head model needs to be expressed in the same coordinate system as the electrodes and the source model. It is not really relevant which specific coordinate system is used, as long as all are consistently [aligned](/faq/how_to_coregister_an_anatomical_mri_with_the_gradiometer_or_electrode_positions). -When you prepare a head model for EEG, the head model should be in the same coordinate system as the electrodes. It is not relevant in which coordinate system the geometrical information is defined, until all are [aligned](/faq/how_to_coregister_an_anatomical_mri_with_the_gradiometer_or_electrode_positions). For this, you can do two thing +As the very first step, we recommend to use **[ft_volumerealign](/reference/ft_volumerealign)** to align the anatomical MRI to the coordinate system that you want to use in your source reconstruction. If you want to align the anatomical MRI to the CTF coordinate system, you need to specify the anatomical landmarks (LPA, RPA and nasion) and the MRI will be translated and rotated such that the axes of the coordinate systems pass thorugh these landmarks. -- either you need to align the anatomical MRI (before the segmentation) into the same coordinate system in which the electrodes will be expressed. For example, if you want to align the anatomical MRI to the ctf coordinate system, it can be aligned with using the **[ft_volumerealign](/reference/ft_volumerealign)** function. For this alignment, you will need to align your MRI to the fiducial points (LPA, RPA and nasion). The output of any later processing step (segmentation, mesh, headmodel) will be expressed in the same coordinate system as your anatomical mri. And then, you can also align the electrodes to the same points. +The output of any later processing step on the MRI (reslicing, segmentation, mesh, headmodel) will consequently be expressed in the same coordinate system as the anatomical MRI. Once the anatomical processing on the basis of the MRI is done, you can align the electrodes to the same anatomical landmarks and/or you can fit the electrodes interactively on the scalp surface of your head model. -- or you can also align later your electrodes interactively or manually to an existing head model. - -The anatomical MRI that we use in this tutorial is already aligned to a head coordinate system (ctf). We also have information (see later) how the EEG electrodes are positioned relative to the fiducials. Therefore, we do not need to align the anatomical MRI to any other convention. +In this specific case the anatomical MRI is already aligned to the CTF coordinate system; you can check this yourself with **[ft_determine_coordsys](/reference/utilities/ft_determine_coordsys)**. Therefore, we do not need to align the anatomical MRI to any other convention. +{% include markup/info %} It is also possible to read in anatomical MRI data in [other formats](/faq/dataformat), which are defined in [a different coordinate system](/faq/coordsys). When you read in your own anatomical data, it may does not give information on the coordinate system in which the anatomical data is expressed and/or maybe there is no transformation matrix specified. In this case, you can check the coordinate-system with the **[ft_determine_coordsys](/reference/utilities/ft_determine_coordsys)** function. +{% include markup/end %} -## Segmentation +### Reslicing -In this step, the voxels of the anatomical MRI are segmented (i.e. separated) into the three different tissue types: scalp, skull and brain. The function **[ft_volumesegment](/reference/ft_volumesegment)** will produce the required output. You can read more about how the tissue-types are represented in the output of this function in this [FAQ](/faq/how_is_the_segmentation_defined). +The segmentation of the anatomical MRI works best if the voxels are isotropic, i.e., if the size of the voxel is identical in each direction. If you do not have isotropic voxels, or you are not sure, you can use the **[ft_volumereslice](/reference/ft_volumereslice)** function to interpolate the anatomical MRI onto isotropic voxels. You can read more about reslicing in this [frequently asked question](/faq/how_change_mri_orientation_size_fov). -{% include markup/warning %} -Note that the segmentation is quite time consuming (~15mins) and if you want you can load the result and skip ahead to the next step. You can download [segmentedmri.mat](https://download.fieldtriptoolbox.org/tutorial/headmodel_eeg/segmentedmri.mat) which contains the segmented MRI used in this tutorial. -{% include markup/end %} +An advantage of reslicing is that it also aligns the voxels with the axes of the coordinate system, thereby avoiding it being plotted [upside down](/faq/my_mri_is_upside_down_is_this_a_problem) later in the pipeline. -{% include markup/info %} -Occasionally, the quality of the anatomical image is not sufficient to provide a good segmentation out-of-the-box. This could for example happen if the anatomical MRI has been acquired with the subject wearing an EEG cap. This could cause image inhomogeneities that make the automatic segmentation fail. One possible solution could be to correct for these inhomogeneitie using the **[ft_volumebiascorrect](/reference/ft_volumebiascorrect)** function. For more information, you can consult this **[frequently asked question](/faq/why_does_my_eegheadmodel_look_funny)**. +### Segmentation + +In this step, the voxels of the anatomical MRI are segmented or classified using **[ft_volumesegment](/reference/ft_volumesegment)** into the three different tissue types: scalp, skull and brain. You can read more about how the tissue-types are represented in the output of this function in this [FAQ](/faq/how_is_the_segmentation_defined). +{% include markup/info %} +The segmentation is quite time consuming (~15mins). For the purpose of this tutorial you can skip this and load the result and move on to the next step. You can download the result from our [download server](https://download.fieldtriptoolbox.org/tutorial/headmodel_eeg_bem/). {% include markup/end %} cfg = []; - cfg.output = {'brain','skull','scalp'}; + cfg.output = {'brain', 'skull', 'scalp'}; segmentedmri = ft_volumesegment(cfg, mri); save segmentedmri segmentedmri @@ -118,48 +120,51 @@ Occasionally, the quality of the anatomical image is not sufficient to provide a scalp: [256x256x256 logical] cfg: [1x1 struct] -The segmentedmri data structure is similar to the mri data structure, but contains the new field +The `segmentedmri` data structure is similar to the `mri` data structure, but contains the additional fields -- **unit**: unit of the head coordinate system -- **brain**: binary representation of the brain -- **skull**: binary representation of the skull -- **scalp**: binary representation of the scalp -- **cfg**: configuration information of the function which created segmentedmri +- `brain`: binary representation of the brain +- `skull`: binary representation of the skull +- `scalp`: binary representation of the scalp -The segmentation does not change the coordinate system, nor the size of the volume. You can see this in the first three fields (dim, transform and coordsys) which are the same as the corresponding fields of the input mri data structure. But now, the field **transform** aligns the matrix in field **brain**, **skull** and **scalp** to the coordinate system defined in the **coordsys** field. It is good practice to check at this point in a figure, whether the segmented compartments look as expected. +The segmentation does not change the coordinate system, nor the size of the volume. You can see this in the first three fields (`dim`, `transform` and `coordsys`) which are the same as the corresponding fields in the MRI. But now, the field `transform` aligns the matrix in field `brain`, `skull` and `scalp` to the coordinate system defined in the `coordsys` field. It is good practice to check at this point in a figure, whether the segmented compartments look as expected. -## Mesh +{% include markup/warning %} +Occasionally, the quality of the anatomical image is not sufficient to provide a good segmentation out-of-the-box. This for example happens if there are large spatial inhomogeneities in the MRI that are caused by the anatomical MRI being acquired while the subject was wearing an EEG cap. The **[ft_volumebiascorrect](/reference/ft_volumebiascorrect)** function allows correcting for these inhomogeneities. For more information, you can consult this [frequently asked question](/faq/why_does_my_eegheadmodel_look_funny). +{% include markup/end %} -In this step, surfaces are created at the borders of the different tissue-types by the **[ft_prepare_mesh](/reference/ft_prepare_mesh)** function. The output of this function are surfaces which are represented by points (vertices) connected in a triangular way. The tissues from which the surfaces are created have to be specified and also the number of vertices for each tissue. +### Construct meshes for the boundaries - cfg=[]; - cfg.tissue={'brain','skull','scalp'}; +In this step, triangulated surface meshes are created at the borders of the different tissue-types using **[ft_prepare_mesh](/reference/ft_prepare_mesh)**. The output consists of surfaces represented by points or vertices that are connected in triangles. The tissues from which the surfaces are created have to be specified and also the number of vertices for each tissue. + + cfg = []; + cfg.tissue = {'brain','skull','scalp'}; cfg.numvertices = [3000 2000 1000]; - bnd=ft_prepare_mesh(cfg,segmentedmri); + mesh = ft_prepare_mesh(cfg,segmentedmri); - save bnd bnd + save mesh mesh - disp(bnd(1)) + disp(mesh(1)) pnt: [3000x3 double] tri: [5996x3 double] unit: 'mm' -The bnd contains the following field +The mesh structure contains the following field + +- `pos` represents the (x,y,z) coordinate of alll vertices of the surface. +- `tri` each row defines the indices (the row numbers) of three vertices that form a triangle +- `unit` describes the units in which the points are expressed -- **pnt** : The coordinates of the vertices of the surface. -- **tri** : Each row defines three vertices (row numbers of the **pnt** field) from a triangle. -- **unit**: Units in which the points are expressed. +The mesh is a structure array with the geometry of three surfaces. The first represents the boundaty between the brain and the inside of the skull, the second the outside surface of the skull, and the third represents the boundary between the scalp and the air. -It is a structure array which describes the geometry of three surfaces in these fields. The first structures represents the triangulation of the brain surface, the second the outside surface of the skull and so on. +### Head model -## Head model +The scalp, skull and brain mask have already been segmented and surface descriptions of the boundaries have been constructed. Now, we will use **[ft_prepare_headmodel](/reference/ft_prepare_headmodel)** to create the actual volume conduction model. -The scalp, skull and brain mask have already been segmented and a surface description of the brain has been constructed. Now, we will create the volume conduction model. We will specify method 'dipoli', and 'openmeeg' to build the head model in the cfg.method field, but there also [other methods](/faq/what_kind_of_volume_conduction_models_are_implemented) to build a BEM model. For example, method 'dipoli' will not work on a Windows platform. In this case, you can either use 'openmeeg', 'bemcp', or another method or you can download the [headmodel](https://download.fieldtriptoolbox.org/tutorial/headmodel_eeg/vol.mat). +Here we will specify the 'dipoli' method, but there are [other methods](/faq/what_kind_of_volume_conduction_models_are_implemented) to build a BEM model. Some of these methods are not supported on all platforms (windows/macos/linux), some of them are more accurate, and some of them do not come pre-packaged and are more hassle to install. If 'dipoli' does not work for you, you can try 'openmeeg' or 'bemcp'. To skip this step and continue with the tutorial, you can also download the result from our [download server](https://download.fieldtriptoolbox.org/tutorial/headmodel_eeg_bem/). - % Create a volume conduction model using 'dipoli', 'openmeeg', or 'bemcp'. - % Dipoli + % Create a volume conduction model cfg = []; - cfg.method ='dipoli'; % You can also specify 'openmeeg', 'bemcp', or another method. + cfg.method = 'dipoli'; % You can also specify 'openmeeg', 'bemcp', or another method headmodel = ft_prepare_headmodel(cfg, bnd); save headmodel headmodel @@ -174,29 +179,28 @@ The scalp, skull and brain mask have already been segmented and a surface descri The headmodel data structure contains the following fields: -- **bnd**: contains the geometrical description of the head model. -- **cond**: conductivity of each surface -- **mat**: matrix -- **type**: describes the method that was used to create the headmodel. -- **unit**: the unit of measurement of the geometrical data in the bnd field -- **cfg**: configuration of the function that was used to create the headmodel +- `bnd` contains the geometrical description of the head model. +- `cond` conductivity of each surface +- `mat` matrix +- `type` describes the method that was used to create the headmodel. +- `unit` the unit of measurement of the geometrical data in the bnd field -The **bnd** field contains the same information as the mesh we created in the earlier step. But the headmodel also contains a conductivity value for each surface and a matrix used for the volume conduction model. Note that the unit of measurement used in the geometrical description of headmodel is in 'mm'. The EEG sensors should be also defined in 'mm'. The units of all type of geometrical information should be the same when a leadfield is computed for source-reconstruction. +The `bnd` field is the same as the mesh that we created in the previous step. The head model also contains a conductivity value for each compartment and a matrix used for the volume conduction model. Note that, as the unit of measurement for the head model is 'mm', the EEG sensors should be also defined in 'mm'. {% include markup/danger %} -The order in which different tissue types are represented in the output of ft_prepare_headmodel may depend on the volume conduction model you are using. Make sure to double-check which tissue type is represented where in headmodel.bnd. +The order in which different tissue types are represented in the output of **[ft_prepare_headmodel](/reference/ft_prepare_headmodel)** may depend on the volume conduction model you are using. Make sure to double-check which tissue type is represented where in headmodel.bnd. {% include markup/end %} -## Visualization +### Visualization -The headmodel contains three structures in the **bnd** field. These are the geometrical descriptions of the scalp, skull and brain surfaces. First, we will plot each of the surfaces using the **[ft_plot_mesh](/reference/plotting/ft_plot_mesh)** function. Then, all surfaces will be plot together on the same figure. +The headmodel contains three structures in the `bnd` field. These are the geometrical descriptions of the scalp, skull and brain surfaces. First, we will plot each of the surfaces using the **[ft_plot_mesh](/reference/plotting/ft_plot_mesh)** function. Then, all surfaces will be plot together on the same figure. - figure; - ft_plot_mesh(headmodel.bnd(3),'facecolor','none'); %scalp - figure; - ft_plot_mesh(headmodel.bnd(2),'facecolor','none'); %skull - figure; - ft_plot_mesh(headmodel.bnd(1),'facecolor','none'); %brain + figure + ft_plot_mesh(headmodel.bnd(3),'facecolor','none'); % scalp + figure + ft_plot_mesh(headmodel.bnd(2),'facecolor','none'); % skull + figure + ft_plot_mesh(headmodel.bnd(1),'facecolor','none'); %b rain {% include image src="/assets/img/tutorial/headmodel_eeg_bem/figure2.png" %} {% include image src="/assets/img/tutorial/headmodel_eeg_bem/figure3.png" %} @@ -205,20 +209,20 @@ The headmodel contains three structures in the **bnd** field. These are the geom _Figure 3. The geometry of the volume conduction model using BEM ('dipoli'): scalp (left), skull (middle) and brain (right)_ ft_plot_mesh(headmodel.bnd(1), 'facecolor',[0.2 0.2 0.2], 'facealpha', 0.3, 'edgecolor', [1 1 1], 'edgealpha', 0.05); - hold on; + hold on ft_plot_mesh(headmodel.bnd(2),'edgecolor','none','facealpha',0.4); - hold on; + hold on ft_plot_mesh(headmodel.bnd(3),'edgecolor','none','facecolor',[0.4 0.6 0.4]); {% include image src="/assets/img/tutorial/headmodel_eeg_bem/figure5.png" width="350" %} _Figure 4. The geometry of the volume conduction model. All surfaces (scalp:gray,skull:white,brain:green) plotted together_ -When the figure is plotted, you can look at the figure from different views using the curved arrow in the MATLAB figure menu. +You can look at the figure from different 3D view poiunts using the curved arrow in the MATLAB figure menu. -## Align the electrodes +### Align the electrodes -The head model is expressed in head coordinates of the anatomical mri (ctf [coordinate system](/faq/coordsys)). We need to define the electrode positions in the same head coordinate system. First, we plot the outermost layer of the head model (scalp) together with the electrodes to check if the alignment is necessary. We use a template set of electrodes which you can find in the FieldTrip/template/electrode/standard_1020.elc file. +The head model is expressed in head coordinates of the anatomical MRI (ctf [coordinate system](/faq/coordsys)). We need to define the electrode positions in the same head coordinate system. First, we plot the outermost layer of the head model (scalp) together with the electrodes to check if the alignment is necessary. We use a template set of electrodes which you can find in the FieldTrip/template/electrode/standard_1020.elc file. % you may need to specify the full path to the file elec = ft_read_sens('standard_1020.elc'); @@ -230,14 +234,14 @@ The head model is expressed in head coordinates of the anatomical mri (ctf [coor type: 'ext1020' unit: 'mm' -The electrode positions are described in the **elecpos** field. The **label** field contains the name of the electrodes. +The electrode positions are described in the `elecpos` field. The `label` field contains the name of the electrodes. % load volume conduction model - load headmodel; - figure; - % head surface (scalp) + load headmodel + figure + % plot the scalp surface from the head model ft_plot_mesh(headmodel.bnd(1), 'edgecolor','none','facealpha',0.8,'facecolor',[0.6 0.6 0.8]); - hold on; + hold on % electrodes ft_plot_sens(elec,'style', 'sk'); @@ -247,27 +251,22 @@ _Figure 5._ The figure shows that the electrodes are not aligned with the scalp surface. -The electrodes can be aligned in two way +The electrodes can be aligned in two ways, which we will demonstrate below: -- if there are anatomical landmarks which positions are known in the anatomical mri and also relative to the electrodes, we can automatically align the electrode positions with a few lines of script or +- if there are anatomical landmarks which positions are known in the anatomical MRI and also relative to the electrodes, we can automatically align the electrode positions with a few lines of script or +- if the exact position of anatomical landmarks are not known relative to the electrodes, we visualize the surface of the head and the electrodes on the same image, and we transform, rotate and scale the electrodes until they fit to the head surface according to our visual judgement. -- if the exact position of anatomical landmarks are not known relative to the electrodes, we visualize the surface of the head and the electrodes on the same image, and we transform, rotate and scale the electrodes until they fit to the head surface according to our visual judgement. +#### Automatic alignment -Now, we will show how to do the alignment in both way - -### Automatic alignment - -First, we will align the electrodes automatically to the anatomical landmarks of the anatomical mri. The head model was created from the same mri, therefore the electrodes will also be aligned to the head-model. +First, we will align the electrodes automatically to the anatomical landmarks of the anatomical MRI. The head model was created from the same mri, therefore the electrodes will also be aligned to the head-model. For the automatic alignment, we need three pieces of informatio -- electrode positions - -- position of fiducial landmarks relative to the electrodes +- electrode positions +- position of fiducial landmarks relative to the electrodes +- position of fiducial landmarks in the anatomical MRI -- position of fiducial landmarks in the anatomical mri - -In the template set of electrodes, the first three labels are: 'Nz', 'LPA' and 'RPA'. These labels show that the first three rows of the **elec.chanpos** field defines the position of the nasion, left and right PA (the landmarks of the CTF ) in _"electrode" coordinates_. We can use this information for the automatic alignment. But we also need to know the position of the same points in the anatomical mri. We use an anatomical mri which has been already aligned to these points, therefore we can find these coordinates in the header information. +In the template set of electrodes, the first three labels are: 'Nz', 'LPA' and 'RPA'. These labels show that the first three rows of the `elec.chanpos` field defines the position of the nasion, left and right PA (the landmarks of the CTF ) in _"electrode" coordinates_. We can use this information for the automatic alignment. But we also need to know the position of the same points in the anatomical MRI. We use an anatomical MRI which has been already aligned to these points, therefore we can find these coordinates in the header information. mri = ft_read_mri('Subject01.mri'); @@ -280,19 +279,19 @@ In the template set of electrodes, the first three labels are: 'Nz', 'LPA' and ' If you do not have the position of the anatomical landmarks in your volume, you can use the **[ft_volumerealign](/reference/ft_volumerealign)** function to get those positions. {% include markup/end %} -First, we get these positions in the ctf coordinate system using the transformation matrix of the mri and the ft_warp_apply function. +First, we get these positions in the CTF coordinate system using the transformation matrix of the mri and the ft_warp_apply function. - nas=mri.hdr.fiducial.mri.nas; - lpa=mri.hdr.fiducial.mri.lpa; - rpa=mri.hdr.fiducial.mri.rpa; + nas = mri.hdr.fiducial.mri.nas; + lpa = mri.hdr.fiducial.mri.lpa; + rpa = mri.hdr.fiducial.mri.rpa; - transm=mri.transform; + transm = mri.transform; - nas=ft_warp_apply(transm,nas, 'homogenous'); - lpa=ft_warp_apply(transm,lpa, 'homogenous'); - rpa=ft_warp_apply(transm,rpa, 'homogenous'); + nas = ft_warp_apply(transm,nas, 'homogenous'); + lpa = ft_warp_apply(transm,lpa, 'homogenous'); + rpa = ft_warp_apply(transm,rpa, 'homogenous'); -Then, we align the position of the fiducials in the electrode structure (defined with labels 'Nz', 'LPA', 'RPA') to their ctf-coordinates that we acquired from the anatomical mri (nas, lpa, rpa). +Then, we align the position of the fiducials in the electrode structure (defined with labels 'Nz', 'LPA', 'RPA') to their ctf-coordinates that we acquired from the anatomical MRI (nas, lpa, rpa). % create a structure similar to a template set of electrodes fid.elecpos = [nas; lpa; rpa]; % ctf-coordinates of fiducials @@ -311,9 +310,9 @@ Then, we align the position of the fiducials in the electrode structure (defined We can check the alignment by plotting together the scalp surface with the electrodes. - figure; + figure ft_plot_sens(elec_aligned,'style','sk'); - hold on; + hold on ft_plot_mesh(headmodel.bnd(1),'facealpha', 0.85, 'edgecolor', 'none', 'facecolor', [0.65 0.65 0.65]); %scalp {% include image src="/assets/img/tutorial/headmodel_eeg_bem/figure7.png" width="350" %} @@ -322,17 +321,17 @@ _Figure 6. Electrodes plotted together with the scalp surface._ {% include markup/warning %} Some of the electrodes are below the skin in the front, while the electrodes in the back do not fit tightly to the head. This happened because there are [different conventions to define the fiducials](/faq/how_are_the_lpa_and_rpa_points_defined). -< -he anatomical MRI is in CTF coordinates with the fiducials for the left and right ear [aligned with the ear canal](/faq/how_can_i_convert_an_anatomical_mri_from_dicom_into_ctf_format) according to DCCN convention. -The description of the electrodes includes the position of the left and right pre-auriciular point proper, i.e. the point of the posterior root of the zygomatic arch lying immediately in front of the upper end of the tragus. +The anatomical MRI is expressed in CTF coordinates with the fiducials for the left and right ear [aligned with the ear canal](/faq/how_can_i_convert_an_anatomical_mri_from_dicom_into_ctf_format) according to DCCN conventions. + +The description of the electrodes includes the position of the left and right pre-auriciular point proper, i.e., the point of the posterior root of the zygomatic arch lying immediately in front of the upper end of the tragus. {% include markup/end %} One way to fix the misalignment is to provide the location of consistent fiducial locations. In this case it could be implemented by specifying the LPA and RPA point in the anatomical MRI shifted approximately 20 mm more anterior. In the subsequent section however, we try to improve the alignment of the electrodes interactively. -### Interactive alignment +#### Interactive alignment cfg = []; cfg.method = 'interactive'; @@ -348,17 +347,17 @@ _Figure 7. Aligned electrodes plotted together with the scalp surface_ This electrode structure can be used later when the leadfield is computed during source-reconstruction. During the computation of the leadfield, the electrodes will be projected onto the scalp surface. -## Exercise 1 +### Exercise 1 {% include markup/info %} Create a head model with method 'concentricspheres' that you fit on scalp, skull and brain surfaces, i.e. using the already made mesh. -Plot the head model in the same figure with the brain surface and scalp. Check the help of **[ft_plot_headmodel](/reference/plotting/ft_plot_headmodel)** for further options of the visualization (e.g., color, transparency) which help to see the spheres and the brain surface together. +Plot the head model in the same figure including the brain, skull and scalp. Check the help of **[ft_plot_headmodel](/reference/plotting/ft_plot_headmodel)** for further options of the visualization (e.g., color, transparency) which help to see the spheres together with the actual surfaces in the mesh that results from the segmentation. -What is the difference between this head model and the BEM? +What is the difference between the spherical and the BEM model? {% include markup/end %} -## Exercise 2 +### Exercise 2 {% include markup/info %} In exercise 1, you created a head model with method 'concentricspheres'. How is its geometrical description defined? What is the difference between the geometrical description of the concentric spheres model and BEM model? @@ -366,7 +365,7 @@ In exercise 1, you created a head model with method 'concentricspheres'. How is ## Summary and further reading -In this tutorial, it was explained how to build a volume conduction model of the head using a single subject anatomical mri and the boundary element method (BEM) developed by Oostendorp and van Oosterom (1989). In the exercises, we compared the BEM model to a concentric spheres model that was fitted on the scalp, skull and brain surfaces. +In this tutorial, it was explained how to build a volume conduction model of the head using a single subject anatomical MRI and the boundary element method (BEM) developed by Oostendorp and van Oosterom (1989). In the exercises, we compared the BEM model to a concentric spheres model that was fitted on the scalp, skull and brain surfaces. You can read more about specific source-reconstruction methods in the [Localizing oscillatory sources using beamformer techniques](/tutorial/beamformer) and in the [Source reconstruction of event-related fields using minimum-norm estimate](/tutorial/minimumnormestimate) tutorials. diff --git a/tutorial/headmodel_eeg_fem.md b/tutorial/headmodel_eeg_fem.md index 12b3402c6..a46a499df 100644 --- a/tutorial/headmodel_eeg_fem.md +++ b/tutorial/headmodel_eeg_fem.md @@ -119,12 +119,14 @@ _Figure 3. MRI plotted before (left) and after reslicing (right)_ In this step, the voxels of the anatomical MRI are segmented (i.e., separated) into the five different tissue types: scalp, skull, csf (cerebro-spinal fluid), gray and white matter. These latest three tissues belong to the brain. The function **[ft_volumesegment](/reference/ft_volumesegment)** will produce the required output. You can read more about how the tissue-types are represented in the output of this function in this [FAQ](/faq/how_is_the_segmentation_defined). The segmentation should contain a binary representation of 5 tissue types which do not overlap. {% include markup/warning %} -Note that the segmentation is quite time consuming (~15mins) and if you want you can load the result and skip ahead to the next step. You can download the segmented MRI of this tutorial data from the from the [download server](https://download.fieldtriptoolbox.org/tutorial/headmodel_fem/segmentedmri.mat) (segmentedmri.mat). +Note that the segmentation is quite time consuming (~15mins) and if you want you can load the result and skip ahead to the next step. You can download the segmented MRI of this tutorial data from the [download server](https://download.fieldtriptoolbox.org/tutorial/headmodel_eeg_fem/). {% include markup/end %} cfg = []; cfg.output = {'gray', 'white', 'csf', 'skull', 'scalp'}; segmentedmri = ft_volumesegment(cfg, mri); + + save segmentedmri segmentedmri disp(segmentedmri) dim: [256 256 256] @@ -200,11 +202,11 @@ At the moment FieldTrip only supports hexahedrons for FEM modeling. ## Head model -Gray and white matter, csf, skull and skin has been differentiated in the geometrical description of the head. Now, we will create the volume conduction model. We will specify `cfg.method='simbio'` in **[ft_prepare_headmodel](/reference/ft_prepare_headmodel)**. This methods also requires to specify the conductivities for each tissue-types. The headmodel can also be downloaded here [download server](https://download.fieldtriptoolbox.org/tutorial/headmodel_fem/headmodel.mat). +Gray and white matter, csf, skull and skin has been differentiated in the geometrical description of the head. Now, we will create the volume conduction model. We will specify `cfg.method='simbio'` in **[ft_prepare_headmodel](/reference/ft_prepare_headmodel)**. This methods also requires to specify the conductivities for each tissue-types. The headmodel can also be downloaded from our [download server](https://download.fieldtriptoolbox.org/tutorial/headmodel_eeg_fem/). cfg = []; cfg.method ='simbio'; - cfg.conductivity = [0.33 0.14 1.79 0.01 0.43]; % order follows mesh.tissuelabel + cfg.conductivity = [0.33 0.14 1.79 0.01 0.43]; % the order follows mesh.tissuelabel headmodel = ft_prepare_headmodel(cfg, mesh); disp(headmodel)