= Tutorial 4: Channel file / MEG-MRI coregistration = ''Authors: Francois Tadel, Elizabeth Bock, Sylvain Baillet'' The anatomy of your subject is ready. Before we can start looking at the MEG/EEG recordings, we need to make sure that the sensors (electrodes, magnetometers or gradiometers) are properly aligned with the MRI and the surfaces of the subject. In this tutorial, we will start with a detailed description of the experiment and the files that were recorded, then we will link the original CTF files to the database in order to get access to the sensors positions, and finally we will explore the various options for aligning these sensors on the head of the subject. <> == Auditory dataset == This dataset used in the introduction tutorials is the same as the one used in the [[Tutorials/Auditory|MEG Auditory tutorial]]: * '''Downsampled''' at a lower sampling rate: from '''2400Hz to 600Hz''' * This makes the introduction tutorials easier to follow on a regular computer. <> <> == Link the raw files to the database == * Switch to the "functional data" view. <
><
> {{attachment:view_functional.gif||height="86",width="259"}} * Right-click on the subject folder > '''Review raw file''' * Select the file format: "'''MEG/EEG: CTF (*.ds...)'''" * Select __'''all'''__ the .ds folders in: '''sample_introduction/data''' * In the CTF file format, each session of recordings is saved in a folder with the extension "ds". The different types of information collected during each session are saved as different files in this folder (event markers, sensor definitions, bad segments, MEG recordings). * {{attachment:review_menu.gif||height="190",width="614"}} * Refine registration now? '''YES''' <
>This operation is detailed in the next section.<
><
> {{attachment:review_refine.gif||height="206",width="397"}} == Automatic registration == The registration between the MRI and the MEG (or EEG) is done in two steps. We start with a first approximation based on three reference points, then we refine it with the full head shape of the subject. ==== Step 1: Fiducials ==== * The initial registration is based on the three fiducial point that define the Subject Coordinate System ('''SCS'''): '''nasion''', '''left ear''', '''right ear'''. You have marked these three points in the MRI viewer in the previous tutorial. * These same three points have also been marked before the acquisition of the MEG recordings. The person who recorded this subject digitized their positions with a tracking device (such as a Polhemus FastTrak or Patriot). The position of these points are saved in the MEG datasets. * When we bring the MEG recordings into the Brainstorm database, we align them on the MRI using these fiducial points: we match the NAS/LPA/RPA points digitized with the Polhemus with the ones we placed in the MRI Viewer. * This registration method gives approximate results. It can be good enough in some cases, but not always because of the imprecision of the measures. The tracking system is not always very precise, the points are not always easy to identify on the MRI slides, and the very definition of these points does not offer a millimeter precision. All this combined, it is easy to end with an registration error of 1cm or more. * The quality of the source analysis we will perform later is highly dependent on the quality of the registration between the sensors and the anatomy. If we start with a 1cm error, this error will be propagated everywhere in the analysis.<
><
> {{attachment:polhemus_setup.gif||height="180",width="291"}} {{attachment:polhemus_beth.jpg||height="188",width="140"}} ==== Step 2: Head shape ==== * To improve this registration, we recommend our users to always digitize additional points on the head of the subjects: around '''100 points''' uniformly distributed on the hard parts of the head (skull from nasion to inion, eyebrows, ear contour, nose crest). Avoid marking points on the softer parts (cheeks or neck) because they may have a different shape when the subject is seated on the Polhemus chair or lying down in the MRI. More information on [[Tutorials/TutDigitize|digitizing head points]]. * We have two versions of the full head shape of the subject: one coming from the MRI (the head surface, represented in grey in the figures below) and one coming from the Polhemus digitizer at the time of the MEG/EEG acquisition (represented as green dots). * The algorithm that is executed when you chose the option "'''Refine registration with head points'''" is an iterative algorithm that tries to find a better fit between the two head shapes (grey surface and green dots), to improve the intial NAS/LPA/RPA registration. This technique usually improves significantly the registration between the MRI and the MEG/EEG sensors. * The two pictures below represent the registration before and after this automatic head shape registration (left=step 1, right=step 2). The yellow surface represents the MEG helmet: the solid plastic surface in which the subject places his/her head. If you ever see the grey head surface intersecting this yellow helmet surface, there is obviously something wrong with the registration. * At the end of the import process, you can close the figure that shows the final registration.<
><
> {{attachment:refine_before.gif||height="226",width="200"}} {{attachment:refine_after.gif||height="226",width="200"}} == New files and folders == Many new files are now visible in the database explorer: * Three folders representing the three MEG datasets that we linked to the database. Note the tag "raw" in the icon of the folders, this means that the files are considered as new continuous files. * '''S01_AEF_20131218_01_600Hz''': Subject01, Auditory Evoked Field, 18-Dec-2013, run #01 * '''S01_AEF_20131218_02_600Hz''': Subject01, Auditory Evoked Field, 18-Dec-2013, run #02 * '''S01_Noise_20131218_02_600Hz''': Subject01, Noise recordings (no subject in the MEG) * All three have been downsampled from 2400Hz to 600Hz. Each of these new folders show two elements: * '''Channel file''': Defines the types and names of channels that were recorded, the position of the sensors, the head shape and other various details. This information has been read from the MEG datasets and saved as a new file in the database. The total number of data channels recorded in the file is indicated between parenthesis (340). * '''Link to raw file''': Link to the original file that you imported. All the relevant meta-data was read from the MEG dataset and copied inside the link itself (sampling rate, number of samples, event markers and other details about the acquisition session). But no MEG/EEG recordings were read or copied to the database. If we open this file, the values are read directly from the original files in the .ds folder. <
><
> {{attachment:review_tree.gif}} == Review vs Import == When trying to bring external data into the Brainstorm environment, a common source of confusion is the difference between the two popup menus Review and Import: * '''Review raw file''': Allows you to create a link to your original data file. It reads the header and sensor information from the file but does not copy the recordings in the database. Most of the artifact cleaning should be done directly using these links. * '''Import MEG/EEG''': Extract segments of recordings (epochs) from an external file and saves copies of them in the Brainstorm database. You should not be using this menu until you have fully pre-processed your recordings. == Display the sensors == Right-click on the ''CTF channels'' file and try all the display menus: * '''CTF Helmet''': Shows a surface that represents the inner surface of the MEG helmet. * '''CTF coils (MEG)''': Display the MEG head coils of this CTF system: they are all axial gradiometers, only the coils close to the head are represented. The small squares do not represent the real shape of the sensors (the CTF coils are circular loops) but an approximation made in the forward model computation. * '''CTF coils (ALL)''': Display all the MEG sensors, including the reference magnetometers and gradiometers. The orientation of the coils is represented with a red segment. * '''MEG''': MEG sensors are represented as small white dots and can be selected by clicking on them. * '''ECG / EOG''': Ignore these menus, we do not have proper positions for these electrodes. * '''Misc''': Shows the approximate positions of the EEG electrodes (Cz and Pz). * Use the ['''Close all'''] button to close all the figures when you are done.<
><
> {{attachment:channel_menu.gif||height="227",width="459"}} <
><
> {{attachment:channel_display.gif||height="192",width="702"}} <> == Sensor map == Here is a map with the full list of sensor names for this CTF system, it could be useful for navigating in the recordings. Click on the image for a larger version. [[http://neuroimage.usc.edu/brainstorm/Tutorials/ChannelFile?action=AttachFile&do=get&target=channel_map.gif|{{attachment:channel_map_small.gif|?action=AttachFile&do=view&target=snap_3conditions.jpg}}]] <> == Manual registration == If the registration you get with the automatic alignment is incorrect, or if there was an issue when you digitized the position of the fiducials or the head shape, you may have to realign manually the sensors on the head. Right-click on the channel file > '''MRI Registration''': * '''Check''': Show all the possible information that may help to verify the registration. * '''Edit''': Opens a window where you can move manually the MEG helmet relative to the head. <
>Read the tooltips of the buttons in the toolbar to see what is available, select an operation and then right-click+move up/down to apply it. From a scientific point of view this is not exactly a rigorous operation, but sometimes it is much better than using wrong default positions. <
>'''IMPORTANT''': this refinement can only be used to better align the headshape with the digitized points - it cannot be used to correct for a subject who is poorly positioned in the helmet (i.e. you cannot move the helmet closer to the subjects head if they were not seated that way to begin with!) <
><
> {{attachment:channel_manual.gif||height="181",width="231"}} * '''Refine using head points''': Runs the automatic registration described earlier. There is nothing to change here, but remember to '''always '''check the registration scalp/sensors. <> == Multiple runs and head positions == Between two acquisition runs the subject may move in the MEG helmet, the relative position of the MEG sensors with the head surface changes. At the beginning of each MEG run, the positions of the head localization coils are detected and used to update the position of the MEG sensors. * The two AEF runs 01 and 02 were acquired successively. The position of the subject's head in the MEG helmet was estimated twice, once at the beginning of each run. * To evaluate visually the displacement between the two runs, select at the same time all the channel files you want to compare (the ones for run 01 and 02), right-click > Display sensors > MEG.<
><
> {{attachment:channel_multiple.gif||height="218",width="438"}} * Typically, we would like to group the trials coming from multiple acquisition runs. However, because of the subject's movements between runs, it is usually not possible to directly compare the MEG values between runs. The sensors may not capture the activity coming from the same regions of the brain. * You have three options if you consider grouping information from multiple runs: * '''Method 1''': Process all the runs separately and average between runs at the source level: The more accurate option, but requires more work, computation time and storage. * '''Method 2''': Ignore movements between runs: This can be acceptable if the displacements are really minimal, less accurate but much faster to process and easier to manipulate. * '''Method 3''': Co-register properly the runs using the process Standardize > Co-register MEG runs: Can be a good option for displacements under 2cm.<
>Warning: This method has not be been fully evaluated on our side, use at your own risk. Also, it does not work correctly if you have different SSP projectors calculated for multiple runs. * In this tutorial, we will illustrate only method 1: runs are not co-registered. <> == Edit the channel file == Display a table with all the information about the individual channels. You can edit all the values. * Right-click on the channel of the first folder (AEF#01) > '''Edit channel file''': <
><
> {{attachment:channel_edit.gif||height="147",width="596"}} * '''Index''': Index of the channel in the data matrix. Can be edited to reorder the channels. * '''Name''': Name that was given to the channel by the acquisition device. * '''Type''': Type of information recordeded (MEG, EEG, EOG, ECG, EMG, Stim, Other, "Delete", etc) * You may have to change the Type for some channels. For instance if an EOG channel was saved as a regular EEG channel, you have to change its type to prevent it from being used in the source estimation. * To delete a channel from this file: select "(Delete)" in the type column. * '''Group''': Used to define sub-group of channels of the same type. * SEEG/ECOG: Each group of contacts can represent a depth electrode or a grid, and it can be plotted separately. A separate average reference montage is calculated for each group. * MEG/EEG: Not used. * '''Comment''': Additional description of the channel. * MEG sensors: Do not edit this information if it is not empty. * '''Loc''': Position of the sensor (x,y,z) in SCS coordinates. Do not modify this interface. <
>One column per coil and per integration point (information useful for the forward modeling). * '''Orient''': Orientation of the MEG coils (x,y,z) in SCS coordinates). One column per Loc column. * '''Weight''': When there is more than one coil or integration point, the Weight field indicates the multiplication factor to apply to each of these points. * To edit the type or the comment for multiple sensors at once, select them all then right-click. * Close this figure, do not save the modifications if you made any. <> == On the hard drive == Some other fields are present in the channel file that cannot be accessed with the ''Channel editor'' window. You can explore these other fields with the ''File ''menu, selecting ''View file contents'' or ''Export to Matlab'', as presented in the previous tutorial. . {{attachment:channel_contents.gif||height="317",width="566"}} ==== Structure of the channel files: channel_*.mat ==== * '''Comment ''': String that is displayed in the Brainstorm database explorer. * '''MegRefCoef''': Noise compensation matrix for CTF and 4D MEG recordings, based on some other sensors that are located far away from the head. * '''Projector''': SSP/ICA projectors used for artifact cleaning purposes. * '''TransfMeg / TransfMegLabel''': Transformations that were applied to the positions of the MEG sensors to bring them in the Brainstorm coordinate system. * '''TransfEeg'''''' / TransfEegLabel''': Same for the position of the EEG electrodes. * '''HeadPoints''': Extra head points that were digitized with a tracking system. * '''Channel''': An array that defines each channel individually (see previous section). * '''History''': Describes all the operations that were performed with Brainstorm on this file. To get a better view of this piece of information, use the menu File > View file history. ==== Useful functions ==== * /toolbox/io/'''import_channel.m''': Read a channel file and save it in the database. * /toolbox/io/'''in_channel_*.m''': Low-level functions for reading all the file formats. * /toolbox/io/'''in_bst_channel.m''': Read a channel file saved in the database. * /toolbox/sensors/'''channel_*.m''': Routines for manipulating channel files. * /toolbox/gui/'''view_channels'''(ChannelFile, Modality, ...): Display the sensors in a 3D figure. <> == Additional documentation == * Forum: [[http://neuroimage.usc.edu/forums/showthread.php?2100-co-registration-evaluation-and-Polhemus-vs-Vit-E|Polhemus headshape vs. vitamin E markers]] * Forum: [[http://neuroimage.usc.edu/forums/showthread.php?2528|Match known EEG locations to the MRI image]] <)>> <> <>