13954
Comment:
|
16553
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
= Tutorial 2: Importing individual anatomy = Objectives: Import anatomy for CTF MEG tutorial. |
= Tutorial 3: Importing individual anatomy = ''Authors: Francois Tadel, Sylvain Baillet'' |
Line 4: | Line 4: |
<<TableOfContents(2)>> | <<TableOfContents(2,2)>> == Dataset description == The dataset that will be used for all the introduction tutorials is a somatotopy experiment recorded with a CTF MEG system (151 axial gradiometers, La Salpetriere Hospital, Paris): shuffled electrical stimulations of the thumb fingers from both hands. Data files contain averages of 400 trials for each side. The idea is to get a map of the primary sensory response on the cortex. Data provided courtesy of Sabine Meunier. Please download sample_ctf.zip from the [[http://neuroimage.usc.edu/brainstorm3_register/download.php|Download]] section. Unzip it in a folder you will dedicate to original data. It can be anywhere but __not__ in the Brainstorm database or program folder. Example: * '''Windows''': My documents\MEG\sample_ctf\ * '''Linux''': /home/username/MEG/sample_ctf/ * '''MacOS''': Documents/MEG/sample_ctf/ |
Line 9: | Line 18: |
* "No, use one channel file per condition (MEG)", because we are going to process regular MEG data in the next tutorial | * "No, use one channel file per condition (MEG)", because we have different runs with different head positions to import for the same subject |
Line 16: | Line 25: |
1. Right click on subject node, and select menu "''Import MRI...''"<<BR>><<BR>> {{attachment:menuImportMri.gif}} | 1. Right click on subject node, and select menu "''Import MRI''"<<BR>><<BR>> {{attachment:menuImportMri.gif}} |
Line 18: | Line 27: |
1. Select file "''TutorialCtf/Anatomy/01.mri''".<<BR>>If you didn't download the CTF tutorial data yet, go back to the [[Tutorials|Tutorials page]]. | 1. Select file "''sample_ctf/Anatomy/01.nii''"<<BR>>Make sure to select one of the correct file format: either ''"All MRI files"'' or ''"MRI: NIfTI-1 (*.nii)"'' |
Line 20: | Line 29: |
1. If you didn't modified any Brainstorm option yet, you should get an error message, saying "Unrecognized format, try switching byte order". This is because not all the computers process the binary data the same way. To learn more about endianness, you can consult [[http://en.wikipedia.org/wiki/Endianness|this Wikipedia page]]. Depending on the type of computer which wrote the binary files, you may need to read them as ''little-endian'' or ''big-endian''.<<BR>><<BR>>To change this setting, go to the ''File > Set preferences...'' menu in main window, and check "Big endian". You may need to modify this setting again to import other files.<<BR>><<BR>> {{attachment:menuByteOrder.gif}} | 1. The MRI viewer is displayed, together with a message box that tells you what to do. Follow the instructions. The MRI is already well oriented so you can directly process with the fiducials selection: Nasion, left ear, right ear, anterior commissure, posterior commissure, and inter-hemispheric point. * For instructions to find these points, read the following page: [[CoordinateSystems]]. |
Line 22: | Line 32: |
1. Try to import the MRI again. It should be working now. The MRI viewer is displayed, together with a message box that tells you what to do. Follow the instructions. The MRI is already well oriented so you can directly process with the fiducials selection. You will see that three fiducials were already identified in the MRI file (NAS, LPA, RPA); you just need to add the three other ones (AC, PC, IH). <<BR>>For instructions to find the fiducials, follow this link: CoordinateSystems. | * __Warning__: This acquisition was done a long time ago, and the person who digitized the position of the nasion and ears before the MEG acquisition did not follow the indications from the previous page. The person pointed at the three markers that we can easily see on the MRI, that appear next to the real anatomical points as little white dots. In this case, you have to mark the points on the MRI slices in the same way that it was done at the MEG acquisition. * The coordinates of the markers should be around the following coordinates (MRI, in mm) * NAS = [115.3 207.2 138.8] * LPA = [ 45.9 128.4 71.3] * RPA = [186.6 123.8 83.4] * AC = [115.3 130.3 132.2] * PC = [115.3 102.2 133.1] * IH = [113.4 109.7 184.7] * You can enter directly type the position of the fiducials with the following popup menu:<<BR>>right-click anywhere in the MRI Viewer figure > Edit fiducials positions... * Click on ''Save ''when you're done selecting the fiducials. * To check were the fiducials are or change their position later:<<BR>>right-click on the MRI file > Edit MRI... |
Line 25: | Line 54: |
The MRI is available in the anatomy folder for ''Subject01''. Let's now proceed with the surfaces. The envelopes we are going to import in this tutorial were extracted using BrainVISA software, and their names and types may differ from other software solutions. To learn how to get those surfaces by yourself: read the tutorials for [[Tutorials/SegBrainVisa|BrainVISA]], [[Tutorials/SegBrainSuite|BrainSuite]], and [[Tutorials/SegFreeSurfer|FreeSurfer]]. | The MRI is available in the anatomy folder for ''Subject01''. Let's now proceed with the surfaces. The envelopes we are going to import in this tutorial were extracted using BrainVISA, and their names and types may differ from other software solutions. To learn how to get these surfaces by yourself: read the tutorials for [[Tutorials/SegBrainVisa|BrainVISA]], [[Tutorials/LabelFreeSurfer|FreeSurfer]], [[Tutorials/SegBrainSuite|BrainSuite]] or [[Tutorials/SegCIVET|CIVET]]. |
Line 27: | Line 56: |
1. Right click on the subject node again, and click on "''Import surfaces...''". Select '''at the same time''' (holding ''Shift ''or ''Ctrl ''key) all the files in the directory "''TutorialCtf/Anatomy/BrainVISA''" (head, Lhemi, Rhemi). Click on "Open" and answer ''Yes ''to the question: "Align surfaces with MRI now?". * Note: The coordinate system used to localize in 3D the vertices of each surface depends on the software that created them. When importing the surfaces, Brainstorm registers them with the MRI using its fiducials points (NAS, LPA, RPA). This simple algorithm needs the head (ie. scalp) surface, so if you try to import only the cortical surface, it will not be well registered with the MRI, and all the following computations will fail. |
1. Right click on the subject node again, and click on "''Import surfaces...''". Select at the same time (holding the ''Shift,'' ''Ctrl'' or ''Cmd ''key) all the files in the directory "''sample_ctf/Anatomy/BrainVISA''" (head, Lhemi, Rhemi). Click on "Open". <<BR>>Make sure to select the correct file format: "All surface files (*.*)" or "BrainVISA (*.mesh)" |
Line 31: | Line 59: |
* The two other files where not identified automatically. They contain the envelopes of left and right hemispheres of the brain, but ''Lhemi ''and ''Rhemi ''are not keywords that are identified automatically by Brainstorm. | * The two other files were not identified automatically. They contain the envelopes of the left and right hemispheres of the brain, but ''Lhemi ''and ''Rhemi ''are not keywords that are identified automatically by Brainstorm. |
Line 35: | Line 63: |
In the ''Surfaces ''tab, you can see the numbers of faces and vertices for each surface, and also display their faces (wireframe) with the ''Edges ''button. They look great, but their resolution is too high for the algorithms we will apply on them later, they need to be downsampled. | At the bottom of the ''Surface ''tab, you can see the numbers of faces and vertices for each surface, and also display their faces (wireframe) with the ''Edge ''button. They look great, but their resolution is too high for the algorithms we will apply on them later, so they need to be resampled. |
Line 37: | Line 65: |
1. Downsample: * Right-click on the ''head ''surface > Less vertices...: enter 7000, and press ''Ok''. * Right-click on the ''Lhemi ''surface > Less vertices...: enter 7500, and press ''Ok''. * Right-click on the ''Rhemi ''surface > Less vertices...: enter 7500, and press ''Ok''. |
1. Downsampling: * Right-click on ''01_head ''> Less vertices... > 7000 vertices. Ok.<<BR>>Select the default resampling method: "Matlab's reducepatch". Ok. * Select simultaneously ''Lhemi ''and ''Rhemi ''> Right-click > Less vertices... > 7500 vertices. Ok.<<BR>>Select the default resampling method: "Matlab's reducepatch". Ok. |
Line 42: | Line 69: |
1. Group left and right hemisphere to build a ''Cortex ''surface: * Select ''Lhemi_7500V ''and ''Rhem''i_7500V'' ''files at once (hold Ctrl key and left-click on both) * Right-click > Merge surfaces * A file called ''New surface'' appeared at the end of the list, rename it in ''Cortex ''(F2 key, or click twice on it but waiting between the two clicks, or ''right-click > Rename''). Its icon should change automatically: the surface has been classified automatically as a ''Cortex ''(keyword that was recognized). * If you prefer calling it in an other way, you would have to specify manually that is a cortex envelope: ''right-click > Set surface type > Cortex'' |
1. Group the left and right hemispheres to build a ''Cortex ''surface: * Select simultaneously ''Lhemi_7500V ''and ''Rhemi_7500V ''> Right-click > Merge surfaces * A file called ''cortex_15000V'' appears in the list. Its icon is different from the Lhemi and Rhemi surfaces: the surface was classified automatically as a cortex envelope. * To set manually the type of a surface : ''right-click > Set surface type > Cortex'' * Like all the files in the database, the surface can be renamed: F2 key, or click twice on it (wait between the two clicks), or ''right-click > Rename.'' |
Line 49: | Line 76: |
* Here you are in configuration where you have two surfaces that are classified as ''head''. * The one which is displayed in green is considered as the default one. It would be used automatically by all the functions that would need the head surface for this subject. * Double-click on the other head surface to select it, it should turn green. * However, this is not the recommanded way to proceed, it might be confusing. To make things clear: always set as "''Other''" the surfaces you are not going to use in the source estimation process. |
* You are in a configuration where two surfaces are classified as ''head''. * The one displayed in green is considered as the default one. It will be used automatically by all the functions that need the head surface for this subject. * Double-click on the other head surface to select it (or right-click > Set as default scalp). It should turn green. * However, having multiple surfaces of the same type is not the recommanded way to proceed, as it might be confusing. To make things clear, always set as "''Other''" the surfaces you are not going to use in the source estimation process (their icon should be a gray dot). |
Line 54: | Line 81: |
* Rename the ''01_head_SCS_7000V'' in ''Head''. * Delete all the surfaces but the ''Head ''and ''Cortex ''(''Delete ''key, or right-click>Delete). |
* Rename the ''01_head_7000V'' to ''head''. Set it as the default scalp (green). * Delete all the surfaces but the ''MRI, head ''and ''cortex ''(''Delete ''key, or right-click>Delete). |
Line 58: | Line 85: |
=== Bug warning === __Description__: On some operating systems, it may happen that the tree is not refreshed well. Just after adding new files, the database tree can be displayed incompletely or can event appear completely empty. This bug occurs sometimes because the interactions between Matlab and Java are not always well synchronized. |
==== Bug warning ==== __Description__: On some operating systems, it may happen that the tree is not refreshed well. Just after adding new files, the database tree can be displayed incompletely or can even appear completely empty. This bug occurs sometimes because the interactions between Matlab and Java are not always well synchronized. |
Line 61: | Line 88: |
__Workaround__: If this happens, just refresh the tree display with by either pressing the F5 key, or by click on the menu ''File > Refresh tree display''. We'll try to fix this bug some day. | __Workaround__: If this happens, just refresh the tree display with either pressing the F5 key or changing the display mode. == Automatic import == The import of the MRI and the surfaces was done manually in the previous sections to introduce the tools. However, you will most likely not have to follow all these steps on your own data, as it is now possible to import the entire segmentation folders with just one click, with the menu "'''Import anatomy folder'''". It works for [[Tutorials/LabelFreeSurfer|FreeSurfer]], [[Tutorials/SegBrainVisa|BainVISA]], [[Tutorials/SegBrainSuite|BrainSuite]] and [[Tutorials/SegCIVET|CIVET]]. Additionally, new menus are available to generate head surfaces from the MRI. |
Line 64: | Line 94: |
Your Subject01 anatomy is ready for source estimation. But before going further, you should '''always '''check that surfaces and MRI are well registered. When performing those steps a bit too fast, it is really easy to end with a cortex envelope that is not aligned with the MRI. None of the following steps in source estimation will check that for you, and the sources estimated would be completely wrong. | Your Subject01 anatomy is ready for source estimation. But before going further, you should '''always''' check that surfaces and MRI are well registered. When performing these steps a bit too fast, it is really easy to end up with a cortex envelope that is not aligned with the MRI. None of the following steps in source estimation will check that for you, and the sources estimated would be completely wrong. |
Line 66: | Line 96: |
* Right-click on the ''Cortex ''surface ''> MRI Registration > Check MRI/surface registration''...<<BR>><<BR>> {{attachment:checkMriRegistration.gif}} | * Right-click on the ''Cortex ''surface ''> MRI Registration > Check MRI/surface registration''...<<BR>><<BR>> {{attachment:checkMriRegistration.gif||height="265px",width="332px"}} * The calculation of the interpolation MRI-surface takes a few seconds, but it is then saved in the database and will be reused later. |
Line 72: | Line 103: |
* If this happens, delete your MRI and surfaces and start again from scratch, it may be some manipulation process. * If the result is not better and you don't know what happens, it is likely that the coordinate system used in your surface file is not handled by Brainstorm. There are still two emergency options: pointing the fiducials on the head surface, and editing manually the surfaces. Both give really unprecise results, but might help if nothing else is possible... * You would not need to use this with this tutorial data, as the surfaces are already well registered with the MRI. But go through the following steps anyway, so that you know what to do in case this happens. |
* If this happens, delete your MRI and surfaces and start again from scratch, it may be a manipulation mistake. * If the result is not better and you don't know what happens, it is likely that the coordinate system used in your surface file is not handled by Brainstorm. There are still two emergency possibilities: pointing the fiducials on the head surface, and editing manually the surfaces. Both options give really imprecise results, but might help if nothing else is possible... * You would not need to use this with the present tutorial data, as the surfaces are already well registered with the MRI. But go through the following steps anyway, so that you know what to do in case it happens. |
Line 76: | Line 107: |
=== Defining the fiducials on head surface === * Of course it is possible only if you have the head surface. * Right-click on ''Cortex > MRI Registration > Advanced > Align all surfaces (with MRI fiducials)...'' * You will be asked to point on the scalp surface the same fiducials as in the MRI (NAS, LPA, RPA). Click on a button in the toolbar (NAS, LPA or LPA), and point it on the surface. Repeat this operation for each fiducial. <<BR>><<BR>> {{attachment:fixMriRegistrationHead.gif}} ''' ''' * Do not click on OK. Normally you would click on OK button in toolbar, and it would realign all the subject's surfaces. However, here we don't want to alter our perfect subject, so just close the "Align surfaces" window, and the modifications will be ignored.''' ''' |
==== Defining the fiducials on head surface ==== * Of course this is possible only if you have the head surface. * Right-click on the head surface > ''MRI Registration > Edit fiducials...'' * You will be asked to point on the scalp surface the same fiducials as in the MRI (NAS, LPA, RPA). Click on a button in the toolbar on the top (NAS, LPA or LPA) to ''activate'' it (grey shading), and point the right spot on the surface. Repeat this operation for each fiducial. <<BR>><<BR>> {{attachment:fixMriRegistrationHead.gif}} * '''Do not save the changes''' when closing the "Align surfaces" window. Normally you would save the changes to realign all the subject's surfaces. However, here we don't want to alter our perfect subject, so just answer ''No'' to the question "Would you like to save the changes ?" and the modifications will be ignored. |
Line 82: | Line 113: |
=== Manual alignment === * The goal is to realign graphically and interactively one surface on another. * Right-click on ''Cortex > MRI Registration > Advanced > Align manually on... > Head'' * The orange surface is the one you are modifying, the grey one is the target. Move your mouse over the buttons in the toolbar to see what they do, select one you like, and then right-click + move up/downBR>><<BR>> {{attachment:fixMriRegistrationManual.gif}} * '''Do not click on OK'''. Close the window, and answer ''No'' to the question "Would you like to save the changed ?" * Check one last time that we didn't modify anything: Right-click on ''Cortex > Check alignment with MRI...'' |
==== Manual alignment ==== * The goal is to realign graphically and interactively one surface based on another. * Right-click on ''Cortex > MRI Registration > Align manually on... > Head'' * The orange surface is the one you are modifying, the grey one is the target. Move your mouse over the buttons in the toolbar to see what they do, select one you like, and then use right-click + move up/down<<BR>><<BR>> {{attachment:fixMriRegistrationManual.gif}} * '''Do not click on OK''' (normally you would click on the OK button of the toolbar, and it would realign all the subject's surfaces). Close the window, and answer ''No'' to the question "Would you like to save the changes ?" * Check one last time that we didn't modify anything: Right-click on Cortex > MRI registration > Check. |
Line 90: | Line 121: |
For most manipulations, it is not necessary to know exactly what is going on at the level of the real files, in Brainstorm database directory. But many things are not accessible from the Brainstorm interface, and you may find useful to manipulate some piece of data directly from the Matlab command window. | For most manipulations, it is not necessary to know exactly what is going on at the level of the file system, in the Brainstorm database directory. However, many things are not accessible from the Brainstorm interface, you may find sometimes useful to manipulate some piece of data directly from the Matlab command window. |
Line 94: | Line 125: |
=== Where are the files ? === | ==== Where are the files ? ==== |
Line 97: | Line 128: |
* Leave your mouse during a few seconds over any node in the database explorer, and a tooltip will appear, with the name and path of the corresponding file on hard drive. <<BR>><<BR>> {{attachment:treeToolTip.gif}} * Note: Paths are relative to current protocol path (''brainstorm_database/TutorialCTF''). What is displayed in Brainstorm window is a comment and may have nothing to do with the real file name. Eg. the ''Scalp ''surface's real file name is ''tess_cortex_concat.mat''. * Right-click > ''File'': many menus can lead you to the files:<<BR>><<BR>> {{attachment:treeFileMenu.gif}} * ''View .mat file'': display file contents, but also its location at the top * ''Go to this directory (Matlab)'': changes Matlab path, so that you can access the file from the Matlab ''Command window'' or the Matlab ''Current directory'' window * ''Localize on disk'': Open an explorer window in this directory (Micorsoft Windows only) * ''X-term in this directory'': Open a terminal window in this directory (Linux, Unix, MacOS only) |
* Leave your mouse during a few seconds over any node in the database explorer, and a tooltip will appear, with the name and path of the corresponding file on the hard drive. <<BR>><<BR>> {{attachment:treeToolTip.gif}} * Paths are relative to current protocol path (''brainstorm_db/TutorialCTF''). What is displayed in the Brainstorm window is a comment and may have nothing to do with the real file name. Eg. the Cortex surface's real file name is ''tess_cortex_pial.mat''. * Almost all the files in the database (imported data or computation results) are in Matlab .mat format. As a consequence, you can load them really easily in the Matlab environment, where they appear as structures with several fields. |
Line 105: | Line 132: |
=== What is inside ? === Almost all the files in Brainstorm database (imported data or computation results) are in Matlab .mat format. As a consequence, you can load them really easily in the Matlab environment, where they appear as structures with several fields. |
==== Popup menu: File ==== Right-click on a surface file: many menus can lead you to the files and their contents: |
Line 108: | Line 135: |
* '''Right-click > File > View .mat file''' : Display all the fields available in the file<<BR>><<BR>> {{attachment:fileViewMat.gif}} * '''Right-click > File > Export to Matlab''': read the contents of the file, and export it to a variable in main Matlab workspace. Example with ''Cortex ''surface exported as "''surf''": output of Matlab command window.<<BR>> {{{ Data exported as "surf" >> surf surf = Vertices: {[3x15010 double]} Faces: {[29944x3 double]} Comment: {'Cortex'} VertConn: {[15010x15010 logical]} Curvature: {[15010x1 single]} tess2mri_interp: [16777216x15010 double] >> }}} * '''Right-click > File > Import from Matlab''': You can modify any field in this variable and then import it back in Brainstorm with this menu |
. {{attachment:treeFileMenu.gif}} |
Line 124: | Line 137: |
=== What are all those other files ? === * If you look in your ''brainstorm_database/TutorialCTF ''directory, you'll find many other directories and files that are apparently not displayed in Braistorm database explorer.<<BR>><<BR>><<BR>> {{attachment:protocolFolders.gif}} |
* '''View file contents''': Display all the fields in the corresponding Matlab .mat file and the file path<<BR>><<BR>> {{attachment:fileViewMat.gif}} * '''View file history''': Review the History field in the file, that records all the operations that were performed on the file since if was imported in Brainstorm<<BR>><<BR>> {{attachment:fileViewHistory.gif}} * '''Export to file''': Export in one of the supported mesh file format * '''Export to Matlab''': Load the contents of the .mat file in the Matlab base workspace. It is then accessible from the Matlab command window. * '''Import from Matlab''': Replace the selected file with the content of a variable from the Matlab base workspace. Useful to save back in the database some structures that where exported and modified manually with the Matlab command window. * '''Copy / Cut / Paste''': Allow you to copy/move files in the database explorer. Keyboard shortcuts for these menus are the standard Windows shortcuts (Ctrl+C, Ctrl+X, Ctrl+V). The tree also support drag-and-drop operations for moving files between different folders. * '''Delete''': Delete a file. Keyboard shortcuts: Delete key. * '''Rename''': Change the Comment field in the file ("renames" the file in the database explorer, but does not rename the actual file on the hard drive). Keyboard shortcut: F2 * '''Copy file path to clipboard''': Copies the full file name into the system clipboard, so that you can paste it in any other window (Ctrl+V or Paste menu) * '''Go to this directory (Matlab)''': Change the current Matlab path, so that you can access the file from the Matlab ''Command window'' or the Matlab ''Current directory'' window * '''Show in file explorer''': Open an explorer window in this directory (not working on all the systems...) * '''Open terminal in this folder''': Start a system console in the file directory (Linux, Unix, MacOS only) ==== What are all these other files ? ==== * If you look in your ''brainstorm_db/TutorialCTF ''directory with the file explorer of your operating system, you'll find many other directories and files that are not visible in Brainstorm database explorer.<<BR>><<BR>> {{attachment:protocolFolders.gif}} |
Line 128: | Line 154: |
* Each condition in ''data ''is described by an extra a file: ''brainstormstudy.mat'' * anat/@default_subject contains the files that are displayed in the ''(Default anatomy)'' node in database explorer * data/@default_study: used when files are shared between different subjects, node ''(Global common files)'' * data/@inter : results of inter-subject analysis * data/Subject01/@default_study: used when files are shared between different conditions in Subject01; node ''(Common files)'' * data/Subject01/@intra: results of intra-subject analysis (across different conditions) |
* Each condition in ''data ''is described by an extra file: ''brainstormstudy.mat'' * '''anat/@default_subject''': contains the files of the default anatomy ''(Default anatomy)'' * '''data/@default_study''': files shared between different subjects ''(Global common files)'' * '''data/@inter''': results of inter-subject analysis * '''data/Subject01/@default_study''': files shared between different conditions in Subject01 * '''data/Subject01/@intra''': results of intra-subject analysis (across different conditions) |
Line 136: | Line 162: |
The anatomy of our subject is ready for source estimation, the next tutorial will explain [[Tutorials/TutImportRecordings|how to import recordings]]. | The anatomy of our subject is ready for source estimation, the next tutorial explains [[Tutorials/TutImportRecordings|how to import recordings]]. <<EmbedContent(http://neuroimage.usc.edu/brainstorm3_register/get_feedback.php?Tutorials/TutImportAnatomy)>> |
Tutorial 3: Importing individual anatomy
Authors: Francois Tadel, Sylvain Baillet
Contents
Dataset description
The dataset that will be used for all the introduction tutorials is a somatotopy experiment recorded with a CTF MEG system (151 axial gradiometers, La Salpetriere Hospital, Paris): shuffled electrical stimulations of the thumb fingers from both hands. Data files contain averages of 400 trials for each side. The idea is to get a map of the primary sensory response on the cortex. Data provided courtesy of Sabine Meunier.
Please download sample_ctf.zip from the Download section. Unzip it in a folder you will dedicate to original data. It can be anywhere but not in the Brainstorm database or program folder. Example:
Windows: My documents\MEG\sample_ctf\
Linux: /home/username/MEG/sample_ctf/
MacOS: Documents/MEG/sample_ctf/
Create protocol
Create a new protocol called TutorialCTF with the following options:
- "No, use individual anatomy", because the individual subject anatomy is available
- "No, use one channel file per condition (MEG)", because we have different runs with different head positions to import for the same subject
Create a new subject (let's keep the default name: Subject01)
Import MRI
Go to the Anatomy view of the protocol files (very first button in Brainstorm window toolbar).
Right click on subject node, and select menu "Import MRI"
Select file "sample_ctf/Anatomy/01.nii"
Make sure to select one of the correct file format: either "All MRI files" or "MRI: NIfTI-1 (*.nii)"- The MRI viewer is displayed, together with a message box that tells you what to do. Follow the instructions. The MRI is already well oriented so you can directly process with the fiducials selection: Nasion, left ear, right ear, anterior commissure, posterior commissure, and inter-hemispheric point.
For instructions to find these points, read the following page: CoordinateSystems.
Warning: This acquisition was done a long time ago, and the person who digitized the position of the nasion and ears before the MEG acquisition did not follow the indications from the previous page. The person pointed at the three markers that we can easily see on the MRI, that appear next to the real anatomical points as little white dots. In this case, you have to mark the points on the MRI slices in the same way that it was done at the MEG acquisition.
- The coordinates of the markers should be around the following coordinates (MRI, in mm)
- NAS = [115.3 207.2 138.8]
- LPA = [ 45.9 128.4 71.3]
- RPA = [186.6 123.8 83.4]
- AC = [115.3 130.3 132.2]
- PC = [115.3 102.2 133.1]
- IH = [113.4 109.7 184.7]
You can enter directly type the position of the fiducials with the following popup menu:
right-click anywhere in the MRI Viewer figure > Edit fiducials positions...Click on Save when you're done selecting the fiducials.
To check were the fiducials are or change their position later:
right-click on the MRI file > Edit MRI...
Import surfaces
The MRI is available in the anatomy folder for Subject01. Let's now proceed with the surfaces. The envelopes we are going to import in this tutorial were extracted using BrainVISA, and their names and types may differ from other software solutions. To learn how to get these surfaces by yourself: read the tutorials for BrainVISA, FreeSurfer, BrainSuite or CIVET.
Right click on the subject node again, and click on "Import surfaces...". Select at the same time (holding the Shift, Ctrl or Cmd key) all the files in the directory "sample_ctf/Anatomy/BrainVISA" (head, Lhemi, Rhemi). Click on "Open".
Make sure to select the correct file format: "All surface files (*.*)" or "BrainVISA (*.mesh)"You should see the three surfaces in the database tree.
One has been identified automatically as a scalp (=head) surface, because its original filename contained the "scalp" keyword. Usually, Brainstorm identifies file types with this kind of tags in the file names.
The two other files were not identified automatically. They contain the envelopes of the left and right hemispheres of the brain, but Lhemi and Rhemi are not keywords that are identified automatically by Brainstorm.
Try to display the surfaces by double-clicking on them, or with the popup menu Display.
Downsample and merge surfaces
At the bottom of the Surface tab, you can see the numbers of faces and vertices for each surface, and also display their faces (wireframe) with the Edge button. They look great, but their resolution is too high for the algorithms we will apply on them later, so they need to be resampled.
- Downsampling:
Right-click on 01_head > Less vertices... > 7000 vertices. Ok.
Select the default resampling method: "Matlab's reducepatch". Ok.Select simultaneously Lhemi and Rhemi > Right-click > Less vertices... > 7500 vertices. Ok.
Select the default resampling method: "Matlab's reducepatch". Ok.- Three new surfaces appeared in the list, with the number of vertices as a suffix.
Group the left and right hemispheres to build a Cortex surface:
Select simultaneously Lhemi_7500V and Rhemi_7500V > Right-click > Merge surfaces
A file called cortex_15000V appears in the list. Its icon is different from the Lhemi and Rhemi surfaces: the surface was classified automatically as a cortex envelope.
To set manually the type of a surface : right-click > Set surface type > Cortex
Like all the files in the database, the surface can be renamed: F2 key, or click twice on it (wait between the two clicks), or right-click > Rename.
Double-click on it to display it (or right-click > Display), and check in the Surfaces tab that the number of vertices is about 15000.
- Multiple surfaces of the same type:
You are in a configuration where two surfaces are classified as head.
- The one displayed in green is considered as the default one. It will be used automatically by all the functions that need the head surface for this subject.
Double-click on the other head surface to select it (or right-click > Set as default scalp). It should turn green.
However, having multiple surfaces of the same type is not the recommanded way to proceed, as it might be confusing. To make things clear, always set as "Other" the surfaces you are not going to use in the source estimation process (their icon should be a gray dot).
- A bit of cleaning:
Rename the 01_head_7000V to head. Set it as the default scalp (green).
Delete all the surfaces but the MRI, head and cortex (Delete key, or right-click>Delete).
Before: After:
Bug warning
Description: On some operating systems, it may happen that the tree is not refreshed well. Just after adding new files, the database tree can be displayed incompletely or can even appear completely empty. This bug occurs sometimes because the interactions between Matlab and Java are not always well synchronized.
Workaround: If this happens, just refresh the tree display with either pressing the F5 key or changing the display mode.
Automatic import
The import of the MRI and the surfaces was done manually in the previous sections to introduce the tools. However, you will most likely not have to follow all these steps on your own data, as it is now possible to import the entire segmentation folders with just one click, with the menu "Import anatomy folder". It works for FreeSurfer, BainVISA, BrainSuite and CIVET. Additionally, new menus are available to generate head surfaces from the MRI.
Check registration with MRI
Your Subject01 anatomy is ready for source estimation. But before going further, you should always check that surfaces and MRI are well registered. When performing these steps a bit too fast, it is really easy to end up with a cortex envelope that is not aligned with the MRI. None of the following steps in source estimation will check that for you, and the sources estimated would be completely wrong.
Right-click on the Cortex surface > MRI Registration > Check MRI/surface registration...
- The calculation of the interpolation MRI-surface takes a few seconds, but it is then saved in the database and will be reused later.
- The yellow lines represent the re-interpolation of the surface in the MRI volume. The computation may take a while, but the result will be stored in the surface file, and will be useful for other operations anyway.
Fix registration with MRI
In some rare cases, the surfaces may not be registered correctly with the MRI.
- If this happens, delete your MRI and surfaces and start again from scratch, it may be a manipulation mistake.
- If the result is not better and you don't know what happens, it is likely that the coordinate system used in your surface file is not handled by Brainstorm. There are still two emergency possibilities: pointing the fiducials on the head surface, and editing manually the surfaces. Both options give really imprecise results, but might help if nothing else is possible...
- You would not need to use this with the present tutorial data, as the surfaces are already well registered with the MRI. But go through the following steps anyway, so that you know what to do in case it happens.
Defining the fiducials on head surface
- Of course this is possible only if you have the head surface.
Right-click on the head surface > MRI Registration > Edit fiducials...
You will be asked to point on the scalp surface the same fiducials as in the MRI (NAS, LPA, RPA). Click on a button in the toolbar on the top (NAS, LPA or LPA) to activate it (grey shading), and point the right spot on the surface. Repeat this operation for each fiducial.
Do not save the changes when closing the "Align surfaces" window. Normally you would save the changes to realign all the subject's surfaces. However, here we don't want to alter our perfect subject, so just answer No to the question "Would you like to save the changes ?" and the modifications will be ignored.
Manual alignment
- The goal is to realign graphically and interactively one surface based on another.
Right-click on Cortex > MRI Registration > Align manually on... > Head
The orange surface is the one you are modifying, the grey one is the target. Move your mouse over the buttons in the toolbar to see what they do, select one you like, and then use right-click + move up/down
Do not click on OK (normally you would click on the OK button of the toolbar, and it would realign all the subject's surfaces). Close the window, and answer No to the question "Would you like to save the changes ?"
Check one last time that we didn't modify anything: Right-click on Cortex > MRI registration > Check.
What happened on the hard drive
For most manipulations, it is not necessary to know exactly what is going on at the level of the file system, in the Brainstorm database directory. However, many things are not accessible from the Brainstorm interface, you may find sometimes useful to manipulate some piece of data directly from the Matlab command window.
The right-click > File menu, accessible on all the nodes in Brainstorm database explorer, offers many tools to interact with the file system and the Matlab environment.
Where are the files ?
Several ways to reach a file:
Leave your mouse during a few seconds over any node in the database explorer, and a tooltip will appear, with the name and path of the corresponding file on the hard drive.
Paths are relative to current protocol path (brainstorm_db/TutorialCTF). What is displayed in the Brainstorm window is a comment and may have nothing to do with the real file name. Eg. the Cortex surface's real file name is tess_cortex_pial.mat.
- Almost all the files in the database (imported data or computation results) are in Matlab .mat format. As a consequence, you can load them really easily in the Matlab environment, where they appear as structures with several fields.
Popup menu: File
Right-click on a surface file: many menus can lead you to the files and their contents:
View file contents: Display all the fields in the corresponding Matlab .mat file and the file path
View file history: Review the History field in the file, that records all the operations that were performed on the file since if was imported in Brainstorm
Export to file: Export in one of the supported mesh file format
Export to Matlab: Load the contents of the .mat file in the Matlab base workspace. It is then accessible from the Matlab command window.
Import from Matlab: Replace the selected file with the content of a variable from the Matlab base workspace. Useful to save back in the database some structures that where exported and modified manually with the Matlab command window.
Copy / Cut / Paste: Allow you to copy/move files in the database explorer. Keyboard shortcuts for these menus are the standard Windows shortcuts (Ctrl+C, Ctrl+X, Ctrl+V). The tree also support drag-and-drop operations for moving files between different folders.
Delete: Delete a file. Keyboard shortcuts: Delete key.
Rename: Change the Comment field in the file ("renames" the file in the database explorer, but does not rename the actual file on the hard drive). Keyboard shortcut: F2
Copy file path to clipboard: Copies the full file name into the system clipboard, so that you can paste it in any other window (Ctrl+V or Paste menu)
Go to this directory (Matlab): Change the current Matlab path, so that you can access the file from the Matlab Command window or the Matlab Current directory window
Show in file explorer: Open an explorer window in this directory (not working on all the systems...)
Open terminal in this folder: Start a system console in the file directory (Linux, Unix, MacOS only)
What are all these other files ?
If you look in your brainstorm_db/TutorialCTF directory with the file explorer of your operating system, you'll find many other directories and files that are not visible in Brainstorm database explorer.
The protocol TutorialCTF is divided in Anatomy and Datasets directories:
Each subject in anat is described by an extra file: brainstormsubject.mat
Each condition in data is described by an extra file: brainstormstudy.mat
anat/@default_subject: contains the files of the default anatomy (Default anatomy)
data/@default_study: files shared between different subjects (Global common files)
data/@inter: results of inter-subject analysis
data/Subject01/@default_study: files shared between different conditions in Subject01
data/Subject01/@intra: results of intra-subject analysis (across different conditions)
Next
The anatomy of our subject is ready for source estimation, the next tutorial explains ?how to import recordings.