Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
tutorial:beamformer_lcmv [2018/10/22 06:35]
42.49.180.224 old revision restored (2015/10/18 11:23)
tutorial:beamformer_lcmv [2017/08/17 11:21] (current)
127.0.0.1 external edit
Line 1: Line 1:
-{{tag>fixme}}+{{tag>fixme}}
  
-&lt;note warning&gt;+<note warning>
 This page is a draft for a future tutorial and is still developing. Hence, there is no guarantee that the content of this page at this moment is correct and complete. ​ This page is a draft for a future tutorial and is still developing. Hence, there is no guarantee that the content of this page at this moment is correct and complete. ​
  
Line 8: Line 8:
 Once this tutorial is completed, it will be listed in the tutorial section in the menu. Also once complete, it will receive the tags //tutorial meg source headmodel mri lcmv beamformer//​ to link it to other pages. Once this tutorial is completed, it will be listed in the tutorial section in the menu. Also once complete, it will receive the tags //tutorial meg source headmodel mri lcmv beamformer//​ to link it to other pages.
  
-&lt;/note&gt;+</note>
  
 ====== Localizing sources using beamformer techniques ====== ====== Localizing sources using beamformer techniques ======
Line 33: Line 33:
  
    * Read the data into Matlab using **[[reference:​ft_definetrial|ft_definetrial]]** and **[[reference:​ft_preprocessing|ft_preprocessing]]**    * Read the data into Matlab using **[[reference:​ft_definetrial|ft_definetrial]]** and **[[reference:​ft_preprocessing|ft_preprocessing]]**
-   * Compute the cavariance ​matrix using the function **[[reference:​ft_timelockanalysis|ft_timelockanalysis]]**+   * Compute the covariance ​matrix using the function **[[reference:​ft_timelockanalysis|ft_timelockanalysis]]**
    * Construct a forward model and lead field matrix using **[[reference:​ft_volumesegment|ft_volumesegment]]**,​ **[[reference:​ft_prepare_singleshell|ft_prepare_headmodel]]** and **[[reference:​ft_prepare_leadfield|ft_prepare_leadfield]]**    * Construct a forward model and lead field matrix using **[[reference:​ft_volumesegment|ft_volumesegment]]**,​ **[[reference:​ft_prepare_singleshell|ft_prepare_headmodel]]** and **[[reference:​ft_prepare_leadfield|ft_prepare_leadfield]]**
   * Compute a spatial filter and estimate the amplitude of the sources using **[[reference:​ft_sourceanalysis|ft_sourceanalysis]]**   * Compute a spatial filter and estimate the amplitude of the sources using **[[reference:​ft_sourceanalysis|ft_sourceanalysis]]**
Line 49: Line 49:
  
  
-&lt;code&gt;+<code>
 % find the interesting segments of data % find the interesting segments of data
 cfg                         = []; cfg                         = [];
Line 66: Line 66:
 cfg.lpfreq ​                 = 55;        % lowpass at 55 Hz cfg.lpfreq ​                 = 55;        % lowpass at 55 Hz
 data = ft_preprocessing(cfg);  ​ data = ft_preprocessing(cfg);  ​
-&lt;/code&gt;+</code>
  
  
Line 77: Line 77:
 Note that we have not yet cleaned the data from artifacts. For your own dataset, we recommend that you have a look at the [[tutorial:​visual_artifact_rejection|visual artifact rejection tutorial]]. Note that we have not yet cleaned the data from artifacts. For your own dataset, we recommend that you have a look at the [[tutorial:​visual_artifact_rejection|visual artifact rejection tutorial]].
   ​   ​
-&lt;code&gt;+<code>
 cfg                  = []; cfg                  = [];
 cfg.covariance ​      = '​yes';​ cfg.covariance ​      = '​yes';​
Line 83: Line 83:
 cfg.vartrllength ​    = 2; cfg.vartrllength ​    = 2;
 timelock ​            = ft_timelockanalysis(cfg,​ data); timelock ​            = ft_timelockanalysis(cfg,​ data);
-&lt;/code&​gt; ​ +</code 
  
 ====Visualize the sensor level results (axial gradients)==== ====Visualize the sensor level results (axial gradients)====
Line 89: Line 89:
 We can plot the results with the matlab plot command to get a first impression: We can plot the results with the matlab plot command to get a first impression:
  
-&lt;code&gt;+<code>
 plot(timelock.time,​ timelock.avg) plot(timelock.time,​ timelock.avg)
-&lt;/code&gt;+</code>
  
-{{:​tutorial:​beamformer:​subjectseftimelock.png?​direct&​amp;400|}}+{{:​tutorial:​beamformer:​subjectseftimelock.png?​direct&​400|}}
  
 We can additionally explore the spatiotemporal dynamics using fieldtrip interactive plotting functions: We can additionally explore the spatiotemporal dynamics using fieldtrip interactive plotting functions:
  
-&lt;code&gt;+<code>
 % view the results % view the results
 cfg                    = []; cfg                    = [];
Line 105: Line 105:
 % or using  % or using 
 ft_movieplotER(cfg,​ timelock); ​ ft_movieplotER(cfg,​ timelock); ​
-&lt;/code&gt;+</code>
  
 ====Visualize the sensor level results (planar gradients)==== ====Visualize the sensor level results (planar gradients)====
Line 116: Line 116:
 Calculate the planar gradient of the averaged data: Calculate the planar gradient of the averaged data:
  
-&lt;code&gt;+<code>
 % calculate planar gradients % calculate planar gradients
 cfg                 = []; cfg                 = [];
Line 126: Line 126:
 cfg.planarmethod ​   = '​sincos';​ cfg.planarmethod ​   = '​sincos';​
 timelock_planar ​    = ft_megplanar(cfg,​ timelock); timelock_planar ​    = ft_megplanar(cfg,​ timelock);
-&lt;/code&gt;+</code>
  
 Compute the amplitude of the planar gradient by combining the horizontal and vertical components of the planar gradient according to Pythagoras rule, and visualize the results (can you see the differences between the axial and planar gradients?​):​ Compute the amplitude of the planar gradient by combining the horizontal and vertical components of the planar gradient according to Pythagoras rule, and visualize the results (can you see the differences between the axial and planar gradients?​):​
  
-&lt;code&gt;+<code>
 % combine planar gradients % combine planar gradients
 cfg                 = []; cfg                 = [];
Line 142: Line 142:
 % or using  % or using 
 ft_movieplotER(cfg,​ timelock_planarcomb); ​ ft_movieplotER(cfg,​ timelock_planarcomb); ​
-&lt;/code&gt;+</code>
  
 ===== The forward model and lead field matrix ===== ===== The forward model and lead field matrix =====
Line 151: Line 151:
 The first step in constructing the forward model is to find the brain surface from the subject'​s MRI, using [[reference:​ft_volumesegment|ft_volumesegment]]. The MRI scan used in this tutorial has already been realigned to the same coordinate system as the MEG data (in this case '​CTF',​ see [[faq:​how_can_i_convert_an_anatomical_mri_from_dicom_into_ctf_format|this page]] on how to realign your subject'​s brain volume. ​ The first step in constructing the forward model is to find the brain surface from the subject'​s MRI, using [[reference:​ft_volumesegment|ft_volumesegment]]. The MRI scan used in this tutorial has already been realigned to the same coordinate system as the MEG data (in this case '​CTF',​ see [[faq:​how_can_i_convert_an_anatomical_mri_from_dicom_into_ctf_format|this page]] on how to realign your subject'​s brain volume. ​
  
-&lt;code&gt;+<code>
 % read and segment the subject'​s anatomical scan % read and segment the subject'​s anatomical scan
 load('​SubjectSEF_mri.mat'​);​ % matfile containing the realigned anatomical scan load('​SubjectSEF_mri.mat'​);​ % matfile containing the realigned anatomical scan
Line 165: Line 165:
 cfg.funparameter ​      = '​brain';​ cfg.funparameter ​      = '​brain';​
 ft_sourceplot(cfg,​ segmentedmri);​ ft_sourceplot(cfg,​ segmentedmri);​
-&lt;/code&gt;+</code>
  
 Now prepare the head model from the segmented brain surface: Now prepare the head model from the segmented brain surface:
  
-&lt;code&gt;+<code>
 % compute the subject'​s headmodel/​volume conductor model % compute the subject'​s headmodel/​volume conductor model
 cfg                = []; cfg                = [];
Line 175: Line 175:
 vol                = ft_prepare_headmodel(cfg,​ seg); vol                = ft_prepare_headmodel(cfg,​ seg);
 vol                = ft_convert_units(vol,​ '​cm'​);​ % mm to cm, since the grid will also be expressed in cm vol                = ft_convert_units(vol,​ '​cm'​);​ % mm to cm, since the grid will also be expressed in cm
-&lt;/code&gt;+</code>
  
-&lt;note important&gt;+<note important>
 If you want to do a beamformer source reconstruction on EEG data, you have to pay special attention to the EEG referencing. The forward model will be made with an common average reference [*], i.e. the mean value over all electrodes is zero. Consequently,​ this also has to be true in your data.  If you want to do a beamformer source reconstruction on EEG data, you have to pay special attention to the EEG referencing. The forward model will be made with an common average reference [*], i.e. the mean value over all electrodes is zero. Consequently,​ this also has to be true in your data. 
  
Line 185: Line 185:
  
 [*] except in some rare cases, like with bipolar iEEG electrode montages [*] except in some rare cases, like with bipolar iEEG electrode montages
-&lt;/note&gt;+</note>
  
 ==== Source model ==== ==== Source model ====
 Now prepare the source model. Here one has the option to make a '​normalized grid', such that the grid points in different subjects are aligned in MNI-space. For more details on how to make a normalized grid, see [[example:​create_single-subject_grids_in_individual_head_space_that_are_all_aligned_in_mni_space|here]]. In this tutorial, we continue with non-normalized grid points: Now prepare the source model. Here one has the option to make a '​normalized grid', such that the grid points in different subjects are aligned in MNI-space. For more details on how to make a normalized grid, see [[example:​create_single-subject_grids_in_individual_head_space_that_are_all_aligned_in_mni_space|here]]. In this tutorial, we continue with non-normalized grid points:
  
-&lt;code&gt;+<code>
 % create the subject specific grid % create the subject specific grid
 hdr                 = ft_read_header('​SubjectSEF.ds'​);​ hdr                 = ft_read_header('​SubjectSEF.ds'​);​
Line 206: Line 206:
 ft_plot_vol(vol,​ '​edgecolor',​ '​none'​);​ alpha 0.4; ft_plot_vol(vol,​ '​edgecolor',​ '​none'​);​ alpha 0.4;
 ft_plot_mesh(grid.pos(grid.inside,:​));​ ft_plot_mesh(grid.pos(grid.inside,:​));​
-&lt;/code&gt;+</code>
  
 ==== Leadfield ==== ==== Leadfield ====
Line 212: Line 212:
 Combine all the information into the leadfield matrix: Combine all the information into the leadfield matrix:
  
-&lt;code&gt;+<code>
 % create leadfield % create leadfield
 hdr                  = ft_read_header('​SubjectSEF.ds'​);​ hdr                  = ft_read_header('​SubjectSEF.ds'​);​
Line 222: Line 222:
 cfg.normalize ​       = '​yes';​ % to remove depth bias (Q in eq. 27 of van Veen et al, 1997) cfg.normalize ​       = '​yes';​ % to remove depth bias (Q in eq. 27 of van Veen et al, 1997)
 lf                   = ft_prepare_leadfield(cfg);​ lf                   = ft_prepare_leadfield(cfg);​
-&lt;/code&gt;+</code>
  
 ===== Source analysis ===== ===== Source analysis =====
  
-&lt;code&gt;+<code>
 % create spatial filter using the lcmv beamformer % create spatial filter using the lcmv beamformer
 cfg                  = []; cfg                  = [];
Line 235: Line 235:
 cfg.lcmv.fixedori ​   = '​yes';​ % project on axis of most variance using SVD cfg.lcmv.fixedori ​   = '​yes';​ % project on axis of most variance using SVD
 source_avg ​          = ft_sourceanalysis(cfg,​ timelock); source_avg ​          = ft_sourceanalysis(cfg,​ timelock);
-&lt;/code&gt;+</code