6123
Comment:
|
9562
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
''Authors: Jeremy Moreau'' | = Fitting dipoles with FieldTrip = ''Authors: Jeremy Moreau, Francois Tadel'' This tutorial introduces dipole fitting and visualization in Brainstorm. You will need to have completed the introduction tutorials up to "Tutorial 16: Average response" before undertaking this tutorial. This tutorial explains how to fit dipoles to time series within Brainstorm. If you already have computed dipole fits using CTF DipoleFit or Neuromag XFit and would like to import them in Brainstorm, see [[http://neuroimage.usc.edu/brainstorm/Tutorials/TutDipScan#Neuromag_Xfit_and_CTF_DipoleFit|this tutorial]]. '''Warning''': This function does not work properly with FieldTrip versions released between 2015-10-05 and 2016-01-15. If you are using a version released around this time, update FieldTrip first. |
Line 5: | Line 10: |
This tutorial introduces dipole fitting and visualisation in Brainstorm. You will need to have completed the introductory tutorials up to "Tutorial 16: Average response" before undertaking this tutorial. This tutorial explains how to fit dipoles to time series within Brainstorm. If you already have computed dipole fits using CTF DipoleFit or Neuromag XFit and would like to import them in Brainstorm, see [[Tutorials/TutXfit|this tutorial]]. | == Process FieldTrip: ft_dipolefitting == This process wraps the FieldTrip function'' ft_dipolefitting''. For background information on the implementation of the dipole modeling see [[http://www.fieldtriptoolbox.org/tutorial/natmeg/dipolefitting|the FieldTrip dipole fitting tutorial]] or watch [[https://youtu.be/pFdCWsqPEFg|this video]]. |
Line 7: | Line 13: |
== Fitting dipoles using process FieldTrip: ft_dipolefitting == This process wraps the FieldTrip function'' ft_dipolefitting''. For background information on the implementation of the dipole modelling see [[http://www.fieldtriptoolbox.org/tutorial/natmeg/dipolefitting|the FieldTrip dipole fitting tutorial]] or watch [[https://youtu.be/pFdCWsqPEFg|this video]]. Note that in order to use this process you will need to [[http://www.fieldtriptoolbox.org/download|have FieldTrip installed]] and added to your Matlab path. |
* First you need to you need to [[http://www.fieldtriptoolbox.org/download|download FieldTrip]] and set the path to the FieldTrip folder in your Brainstorm preferences (menu File > Edit preferences). <<BR>><<BR>> {{attachment:brainstorm_preferences.png||height="237",width="516"}} * Open the protocol TutorialIntroduction and switch to the "functional data" view. * We will be fitting dipoles to the auditory ERFs computed in the tutorial [[http://neuroimage.usc.edu/brainstorm/Tutorials/Averaging|Average response]]. In a first step, we will fit a single dipole to the peak of the M100 ERF component (100ms). <<BR>><<BR>> {{attachment:tut_dipolefitting_m100_traces.png||height="156",width="353"}} * Expand the imported run01 and drag the average time series "Avg: standard" into the Process1 box. |
Line 10: | Line 18: |
We will be fitting dipoles to the auditory ERFs computed in "Tutorial 16: Average response". In a first step, we will fit a single dipole to the peak of the M100 ERF component. | * Run process '''Sources > FieldTrip: ft_dipolefitting''': Time window='''[100,100]ms''', Sensors='''MEG '''<<BR>><<BR>> {{attachment:process_dipolefitting.gif||height="366",width="479"}} |
Line 12: | Line 20: |
{{attachment:tut_dipolefitting_m100_traces.png}} | * Press "Run" and wait. Check the Matlab console for the progress. |
Line 14: | Line 22: |
* Open the protocol TutorialIntroduction and switch to the "functional data" view. * Expand the run 02 folder (not the Raw link), and drag the average time series "Avg: standard" into the Process1 box. * Click on "Run" and select the process Sources -> FieldTrip: ft_dipolefitting. |
* Once the process is done computing a new dipole file will appear in your database under the average time series on which it was computed. Before continuing to visualizing the dipoles, let's compute a second dipole around the M50 component. This time we'll fit a moving dipole over a 20ms time window around the peak of the M50.<<BR>><<BR>> {{attachment:process_dipolefitting2.gif||height="171",width="291"}} |
Line 18: | Line 24: |
{{attachment:tut_dipolefitting_processbox_s.png}} | == Process options == * '''Time window: '''Time window over which to run the dipole fit. If you want to fit a dipole to a single time point enter the same time value in the start and end field. * '''Sensor type or names: ''' Type of sensor (e.g. MEG, EEG) or comma separated list of sensor names (e.g. MLF42) to use in the dipole fit. It is not currently possible to select multiple sensor types at once (e.g. both MEG and EEG). * '''Dipole type: '''For each time sample within the selected time window, the moving dipole option fits a dipole with a different position and orientation, whereas the regional dipole option fits a dipole with a different orientation but always the same position. * '''Number of dipoles to fit: '''The number of dipoles that will be fit at each time point. * '''Initial dipole grid''': One fitting a single dipole, the dipole fitting algorithm starts with estimating the goodness of fit of a fixed grid of dipoles, then takes the best fitting one and refines it with an iterative dipole fitting algorithm. When fitting multiple dipoles, this initial grid search is disabled because it is not supported by the function ft_dipolefitting. * '''Left-right symmetry constraint:''' Selecting this option imposes a left-right symmetry constraint when fitting two dipoles. You may want to use this when you have a reason to believe that bilateral activation may be occuring (e.g. because you are delivering a stimulus bilaterally). * '''File tag: '''Text string that will be added at the end of the comment field of the dipole file. |
Line 20: | Line 33: |
* Enter M100 in the "File tag" field, 100 - 100 in the "Time window" fields, and leave all other options as they are. Press "Run" and wait (you may want to look at the Matlab console to see the progress). {{attachment:tut_dipolefitting_proccessbox2.png}} * Once the process is done computing a new dipole file will appear in your database under the average time series on which it was computed. Before continuing to visualising the dipoles, let's compute a second dipole around the M50 component. This time we'll fit a moving dipole over a 20ms time window around the peak of the M50. {{attachment:tut_dipolefitting_processbox3.png}} == Visualising dipole files == * Double click the M100 dipole file generated in the previous section. This will open up the 3D MRI viewer. For more information on usage and basic options of the 3D MRI viewer refer to the "MRI in 3D" subsection of [[Tutorials/ExploreAnatomy|Tutorial 3]]. {{attachment:tut_dipolefitting_m100_3d_dipolefit.png}} |
== Visualizing dipole files == * Double click the M100 dipole file generated in the previous section. This will open up the 3D MRI viewer. For more information on usage and basic options of the 3D MRI viewer, see [[http://neuroimage.usc.edu/brainstorm/Tutorials/ExploreAnatomy#MRI_in_3D|this tutorial]]. <<BR>><<BR>> {{attachment:dipole_files.gif||height="100",width="300"}} {{attachment:dipole_100ms.gif||height="265",width="293"}} |
Line 34: | Line 37: |
* Click on the dipole to get detailed information about its position, amplitude and significance. This single dipole localizes correctly the left primary auditory cortex, but it shows a goodness of fit of ~70%, which is a relatively poor performance for an average response with such a high SNR. This is due to the fact that there are multiple simultaneous sources (more details in the following sections). <<BR>><<BR>>{{attachment:dipole_infos.gif}} |
|
Line 36: | Line 41: |
{{attachment:tut_dipolefitting_m50_3d_dipolefit.png}} | * Switch between the "Time" and "Goodness of fit" options to get an idea of when the best fit occurs. You can also select the "Show max goodness of fit" option to display only the dipole with the best fit or move the "Goodness" slider to hide all dipoles with a goodness value under a selected threshold. <<BR>><<BR>> {{attachment:display_m50.gif}} |
Line 38: | Line 43: |
* Switch between the "Time" and "Goodness of fit" options to get an idea of when the best fit occurs. You can also select the "Show max goodness of fit" option to display only the dipole with the best fit or move the "Goodness" slider to hide all dipoles with a goodness value under a selected threshold. | == Single dipole with multiple sources == In the previous two examples, we fitted one single dipole at each time point. This approach is expected to work well if we assume that there is '''one active source only''' at each time point. This is not the case here, we expect a bilateral auditory response to this binaural sitmulus. We obtained results that look meaningful (dipoles close to the auditory regions) because the response we recorded is stronger on the left side, but this approach is globally '''wrong'''. This is why we had such low goodness of fit values (~50%). |
Line 40: | Line 46: |
{{attachment:tut_dipolefitting_view_options.png}} | If you expect to observe '''two sources of activity simultaneously''', then you need to either fit '''two dipoles''' at the same time, or to use a distributed source model. However, there are difficult methodological problems that come with multiple dipole fitting: Do you fit first a dipole and then fit a second one to the residuals? Do you try to optimize the two dipoles at once? But then how do you write your optimization function to guarantee your fitting algorithm converges? Obtaining correct results with usually requires an accurate manual initialization of the dipoles parameters, and a lot of user supervision on the process. Let's try to see what happens if we ask FieldTrip the FieldTrip function to fit two dipoles, to explain the activity of the left and right auditory cortices simultaneously. * Run the process '''Sources > FieldTrip: ft_dipolefitting''': Time window='''[40,60]ms''', Sensors=MEG, Number of dipoles to fit: '''2''', Left-right symmertry='''No''' <<BR>><<BR>> * |
Line 43: | Line 54: |
You may sometimes want to visualise multiple sets of dipoles together on the same MRI viewer. For instance, you may have fit dipoles to a series of individual epileptic spikes, and would like to see whether the dipoles form a cluster. In the context of this tutorial, we are going to merge the M50 dipole file with the M100 dipole file, so that we can see where they localise relative to each other. | You may sometimes want to visualize multiple sets of dipoles together on the same MRI viewer. For instance, you may have fit dipoles to a series of individual epileptic spikes, and would like to see whether the dipoles form a cluster. In the context of this tutorial, we are going to merge the M50 dipole file with the M100 dipole file, so that we can see where they localise relative to each other. |
Line 46: | Line 57: |
* In addition to the "Time" and "Goodness of fit" colouring options, you'll find that the "Group" option is useful when viewing merged dipole files. This option colours dipoles from each of the original dipole files in a different colour. <<BR>><<BR>> {{attachment:display_merge.gif}} | |
Line 47: | Line 59: |
{{attachment:tut_dipolefitting_m50-m100_merge_3d.png}} | == Additional documentation == * Brainstorm tutorial: [[http://neuroimage.usc.edu/brainstorm/Tutorials/Epilepsy#Dipole_fitting|EEG and epilepsy: Dipole fitting]] * Brainstorm tutorial: [[http://neuroimage.usc.edu/brainstorm/Tutorials/TutDipScan|Dipoles: Scanning and importing]] * FieldTrip reference: [[https://github.com/fieldtrip/fieldtrip/blob/master/ft_dipolefitting.m|ft_dipolefitting]] * FieldTrip tutorial: [[http://www.fieldtriptoolbox.org/tutorial/natmeg/dipolefitting|Dipole fitting of combined MEG/EEG data]] |
Line 49: | Line 65: |
* In addition to the "Time" and "Goodness of fit" colouring options, you'll find that the "Group option is useful when viewing merged dipole files. This option colours groups of dipoles from each of the original dipole files in a merged dipole file in a different colour. == FieldTrip: ft_dipolefitting process options == '''File tag: '''Text string that will be added at the end of the comment field of the dipole file. '''Time window: '''Time window over which to run the dipole fit. If you want to fit a dipole to a single time point enter the same time value in the start and end field. '''Sensor type or names: ''' Type of sensor (e.g. MEG, EEG) or comma separated list of sensor names (e.g. MLF42) to use in the dipole fit. It is not currently possible to select multiple sensor types at once (e.g. both MEG and EEG). '''Dipole type: '''For each time sample within the selected time window, the moving dipole option fits a dipole with a different position and orientation, whereas the regional dipole option fits a dipole with a different orientation but always the same position. '''Number of dipoles to fit: '''The number of dipoles that will be fit at each time point. '''Left-right symmetry constraint:''' Selecting this option imposes a left-right symmetry constraint when fitting two dipoles. You may want to use this when you have a reason to believe that bilateral activation may be occuring (e.g. because you are delivering a stimulus bilaterally). |
<<EmbedContent(http://neuroimage.usc.edu/bst/get_feedback.php?Tutorials/DipoleFitting)>> |
Fitting dipoles with FieldTrip
Authors: Jeremy Moreau, Francois Tadel
This tutorial introduces dipole fitting and visualization in Brainstorm. You will need to have completed the introduction tutorials up to "Tutorial 16: Average response" before undertaking this tutorial. This tutorial explains how to fit dipoles to time series within Brainstorm. If you already have computed dipole fits using CTF DipoleFit or Neuromag XFit and would like to import them in Brainstorm, see this tutorial.
Warning: This function does not work properly with FieldTrip versions released between 2015-10-05 and 2016-01-15. If you are using a version released around this time, update FieldTrip first.
Contents
Process FieldTrip: ft_dipolefitting
This process wraps the FieldTrip function ft_dipolefitting. For background information on the implementation of the dipole modeling see the FieldTrip dipole fitting tutorial or watch this video.
First you need to you need to download FieldTrip and set the path to the FieldTrip folder in your Brainstorm preferences (menu File > Edit preferences).
Open the protocol TutorialIntroduction and switch to the "functional data" view.
We will be fitting dipoles to the auditory ERFs computed in the tutorial Average response. In a first step, we will fit a single dipole to the peak of the M100 ERF component (100ms).
- Expand the imported run01 and drag the average time series "Avg: standard" into the Process1 box.
Run process Sources > FieldTrip: ft_dipolefitting: Time window=[100,100]ms, Sensors=MEG
- Press "Run" and wait. Check the Matlab console for the progress.
Once the process is done computing a new dipole file will appear in your database under the average time series on which it was computed. Before continuing to visualizing the dipoles, let's compute a second dipole around the M50 component. This time we'll fit a moving dipole over a 20ms time window around the peak of the M50.
Process options
Time window: Time window over which to run the dipole fit. If you want to fit a dipole to a single time point enter the same time value in the start and end field.
Sensor type or names: Type of sensor (e.g. MEG, EEG) or comma separated list of sensor names (e.g. MLF42) to use in the dipole fit. It is not currently possible to select multiple sensor types at once (e.g. both MEG and EEG).
Dipole type: For each time sample within the selected time window, the moving dipole option fits a dipole with a different position and orientation, whereas the regional dipole option fits a dipole with a different orientation but always the same position.
Number of dipoles to fit: The number of dipoles that will be fit at each time point.
Initial dipole grid: One fitting a single dipole, the dipole fitting algorithm starts with estimating the goodness of fit of a fixed grid of dipoles, then takes the best fitting one and refines it with an iterative dipole fitting algorithm. When fitting multiple dipoles, this initial grid search is disabled because it is not supported by the function ft_dipolefitting.
Left-right symmetry constraint: Selecting this option imposes a left-right symmetry constraint when fitting two dipoles. You may want to use this when you have a reason to believe that bilateral activation may be occuring (e.g. because you are delivering a stimulus bilaterally).
File tag: Text string that will be added at the end of the comment field of the dipole file.
Visualizing dipole files
Double click the M100 dipole file generated in the previous section. This will open up the 3D MRI viewer. For more information on usage and basic options of the 3D MRI viewer, see this tutorial.
Dipoles are coloured according to time by default, but since we've fit a dipole to a single time point in this case this option is not very useful. Under the Dipoles tab of the main Brainstorm window look for the "Color dipoles according to" subsection, and select "Goodness of fit". Larger values represent a better fit, but note that "goodness of fit" values computed using the "FieldTrip: ft_dipolefitting" process are not equivalent to those of imported CTF DipoleFit or Neuromag XFit dipoles. FieldTrip's ft_dipolefitting function computes residual variance as its measure of goodness of fit. In Brainstorm, we plot the explained variance (i.e. 1 - residual variance).
Click on the dipole to get detailed information about its position, amplitude and significance. This single dipole localizes correctly the left primary auditory cortex, but it shows a goodness of fit of ~70%, which is a relatively poor performance for an average response with such a high SNR. This is due to the fact that there are multiple simultaneous sources (more details in the following sections).
- Now close the current 3D MRI viewer, and double click the M50 dipole file. You'll now see a series of dipoles plotted on the 3d MRI viewer.
Switch between the "Time" and "Goodness of fit" options to get an idea of when the best fit occurs. You can also select the "Show max goodness of fit" option to display only the dipole with the best fit or move the "Goodness" slider to hide all dipoles with a goodness value under a selected threshold.
Single dipole with multiple sources
In the previous two examples, we fitted one single dipole at each time point. This approach is expected to work well if we assume that there is one active source only at each time point. This is not the case here, we expect a bilateral auditory response to this binaural sitmulus. We obtained results that look meaningful (dipoles close to the auditory regions) because the response we recorded is stronger on the left side, but this approach is globally wrong. This is why we had such low goodness of fit values (~50%).
If you expect to observe two sources of activity simultaneously, then you need to either fit two dipoles at the same time, or to use a distributed source model. However, there are difficult methodological problems that come with multiple dipole fitting: Do you fit first a dipole and then fit a second one to the residuals? Do you try to optimize the two dipoles at once? But then how do you write your optimization function to guarantee your fitting algorithm converges? Obtaining correct results with usually requires an accurate manual initialization of the dipoles parameters, and a lot of user supervision on the process.
Let's try to see what happens if we ask FieldTrip the FieldTrip function to fit two dipoles, to explain the activity of the left and right auditory cortices simultaneously.
Run the process Sources > FieldTrip: ft_dipolefitting: Time window=[40,60]ms, Sensors=MEG, Number of dipoles to fit: 2, Left-right symmertry=No
Merging dipole files
You may sometimes want to visualize multiple sets of dipoles together on the same MRI viewer. For instance, you may have fit dipoles to a series of individual epileptic spikes, and would like to see whether the dipoles form a cluster. In the context of this tutorial, we are going to merge the M50 dipole file with the M100 dipole file, so that we can see where they localise relative to each other.
- In the main Brainstorm window, select the dipole files to merge (hold down shift and click on each dipole file). Then right-click on any one of the dipole files and select "Merge dipoles". A new dipole file will be created in your database called "Merge: 2 files". Double click it to display.
In addition to the "Time" and "Goodness of fit" colouring options, you'll find that the "Group" option is useful when viewing merged dipole files. This option colours dipoles from each of the original dipole files in a different colour.
Additional documentation
Brainstorm tutorial: EEG and epilepsy: Dipole fitting
Brainstorm tutorial: Dipoles: Scanning and importing
FieldTrip reference: ft_dipolefitting
FieldTrip tutorial: Dipole fitting of combined MEG/EEG data