6149
Comment:
|
24522
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
= Raw recordings viewer = This tutorial describes how to review a continuous file and edit the markers before importing it in the Brainstorm database. It is based on median nerve stimulation acquired at MGH in 2005 with a Neuromag Vectorview 306 system. The sample dataset contains the results for one subject for both arms. The basic tutorials you read before explain how to import recordings in the database: this operation creates a copy of all the data in Matlab .mat files in the Brainstorm database folders. You could process continuous recordings in the same way, but the .mat format has this limitation that the entire file has to be read even when you want to access just a portion of it. Long recordings usually cannot fit in memory and have to be split in small blocks of a few seconds, which makes it very difficult to review and to process. Brainstorm offer the possibility to visualize continuous MEG/EEG recordings in any of the supported file formats without having to fully "import" them. A link to the native file is created in the database, which can be then manipulated almost like the "imported" recording blocks. Only the description of the file is saved in the database, and when displaying it the recording values are read directly from the native file. In addition, an interface allows to edit the time markers that are saved in the file. Those markers can then be used to import the recordings in the database (ie. to do the segmentation of the continous recordings in epochs/trials). Only the imported epochs/trials (hard copies in .mat format) can be pre-processed and averaged. |
= C1. Review continuous recordings and edit markers = This tutorial describes how to review a continuous file and add time markers. It is based on a median nerve stimulation experiment recorded at the Montreal Neurological Institute in 2011 with a CTF MEG 275 system. The sample dataset contains 6 minutes of recordings at 1200Hz for one subject and includes 100 stimulations of each arm. The segmentation of the T1 MRI of the subject was performed using [[Tutorials/LabelFreeSurfer|FreeSurfer]]. <<TableOfContents(2,2)>> |
Line 11: | Line 7: |
* It is considered that you followed all the basic tutorials and that you already have a fully working copy of Brainstorm installed on your computer. * Go to the [[http://neuroimage.usc.edu/brainstorm3_register/download.php|Download]] page of this website, and dowload the file "bst_sample_mind_neuromag.zip". |
* Requirements: You have already followed all the basic tutorials and you have a working copy of Brainstorm installed on your computer. * Go to the [[http://neuroimage.usc.edu/brainstorm3_register/download.php|Download]] page of this website, and dowload the file: '''sample_raw.zip ''' |
Line 15: | Line 11: |
* Select the menu File > Create new protocol. Name it "!TutorialRawViewer", set "MNI Colin27" as the default anatomy, and select the options: "Yes, use protocol's default anatomy", "No, use one channel file per condition". * Just close the MRI Viewer window and the dialog box that asks to define the fiducials, there is no need for fine registration in this tutorial. == Access to the raw file == * Select the "Anatomy" exploration mode (first button in the toolbar above the database explorer). * Right-click on the protocol node and select "New subject". Leave the default name and options and click on Save. * Right-click on the subject node, and select: "Review raw file". Select the "Neuromag FIFF" file type, and open the only .fif file in the folder sample_mind_neuromag/data.<<BR>><<BR>> {{attachment:menuReview.gif}} * A dialog window appears asking where to get the time markers (=events) from. Select "Event channel", and then "STI 001", to create a list of events based on the inputs that were recorded on the channel "STI 001".<<BR>><<BR>> {{attachment:fifEventsDialog1.gif}} {{attachment:fifEventsDialog2.gif}} * Answer "No" to the question "Save the events extract from this channel?". Or you can say "yes" if you prefer, it doesn't really matter.<<BR>><<BR>> {{attachment:fifEventsDialog3.gif}} * A new folder with two files appears in the database explorer:<<BR>><<BR>> {{attachment:linkInTree.gif}} * The channel file contains the definition of the sensors, exactly as when importing the files in the database with the "Import MEG/EEG" menu. * The node named "Link to raw file" contains all the information that was read from the continous file (file format, time vector, sampling frequency, events, bad channels, path to the original file, etc.), but no recordings. The MEG and EEG values recorded will be read directly from the native file, using the function in_fread. |
* Select the menu File > Create new protocol. Name it "'''!TutorialRaw'''" and select the options: * "'''No, use individual anatomy'''", * "'''Yes, use one channel file per subject'''". == Import the anatomy == * Create a new subject Subject01 * In the anatomy view, right-click on the subject > Import anatomy folder, select the file format "!FreeSurfer folder" and select the folder "sample_raw/Anatomy". This imports automatically all the available files in a segmentation folder generated with !FreeSurfer, as illustrated in [[Tutorials/LabelFreeSurfer|this page]]. * Leave the default number of vertices of the cortex surface (15000) * When the MRI Viewer window shows up, you have to define the position of the 6 fiducial points, as described in CoordinateSystems (set the SCS fiducials as the read anatomical nasion/left/right, not the position of the CTF coils). At the end, you should have the following MRI coordinates (+/- a few millimeters): * NAS: x=127, y=212, z=123 * LPA: x=55, y=124, z=119 * RPA: x=200, y=129, z=114 * AC: x=129, y=137, z=157 * PC: x=129, y=113, z=157 * IH: x=129, y=118, z=209 (anywhere on the midsagittal plane) * Click on Save when you're done, and wait until the process is over. At the end, a figure shows the surfaces that were generated. Close it.<<BR>><<BR>> {{attachment:anat.gif}} * Four files are now available as the anatomy of Subject01: a T1 MRI, a head surface, and two cortex surfaces (high and low resolution). The anatomy of the subject is ready. == Access the raw file == The basic tutorials you read before explain how to import recordings in the database: this operation creates a copy of all the data in Matlab .mat files in the Brainstorm database folders. You could process continuous recordings in the same way, but the .mat format has this limitation that the entire file has to be read even when you want to access just a portion of it. Long recordings usually cannot fit in memory and have to be split in small blocks of a few seconds, which makes it very difficult to review and process. Brainstorm offers the possibility to visualize continuous MEG/EEG recordings in any of the supported file formats without having to fully "import" them. A link to the native file is created in the database, which can be then manipulated almost like the "imported" recording blocks. Only the description of the file is saved in the database, and when displaying it the values are read directly from the native file. In addition, an interface allows to edit the time markers that are saved in the file. Those markers can then be used to import the recordings in the database (ie. to do the segmentation of the continous recordings in epochs/trials). Then the imported epochs/trials (hard copies in .mat format) can be pre-processed and averaged. * Select the "Functional data (sorted by subject)" exploration mode (second button in the toolbar above the database explorer). * Right-click on the subject node, and select: "Review raw file". Select the "MEG: CTF" file type, and pick the ds folder in "/sample_raw/Data".<<BR>><<BR>> {{attachment:menuReview.gif}} * Then you're asked if you want to "Refine the registration with the head points". This operation improves the initial MRI/MEG registration by fitting the head points digitized before the MEG acquisition on the scalp surface with an ICP algorithm. Answer yes. Even if the result is not perfect, it usually improves the positioning of the head in the MEG helmet. The grey surface represents the head extracted from the MRI, the yellow surface represents the inside of the MEG helmet, and the green dots are the head shape points digitized with the Polhemus device; the goal is to align the green points on the grey surface.<<BR>><<BR>> {{attachment:refine.gif}} <<BR>> {{attachment:refineBefore.gif}} {{attachment:refineAfter.gif}} * Two new files appeared in the database explorer:<<BR>><<BR>> {{attachment:linkInTree.gif}} * The channel file contains the definition of the sensors, exactly as when importing the files in the database with the "Import MEG/EEG" menu. It is saved in the folder ''(Common files)'', because the subject was created using the option "Yes, use one channel file per subject". Therefore, the same channel file will be used for all the folders of Subject01. * The node named "Link to raw file" contains all the information that was read from the continous file (file format, time vector, sampling frequency, events, bad channels, path to the original file, etc.), but no recordings. The MEG and EEG values recorded will be read directly from the native file. |
Line 32: | Line 48: |
Line 36: | Line 50: |
You can see a new tab "Event" and a time series figure. | You can see new information in the tab "Record" and a figure showing the recordings. |
Line 40: | Line 54: |
* Only a small block of the continuous recordings has been loaded in memory. This small time window can be modified with the tab "Event": the slider "Start" represents the beginning of the time window, and the text box "Samples" its length in number of time samples. The usual Brainstorm time controls (right-left corner of the main window) can be used to move the current time within that reduced time window. * The panel "Recordings" in the Event tab lists the events that were detected on the "STI 001" input channel: * on the left, the groups of events (only one group here, Event #5, representing the electric stimulation of the right arm); * on the right, all the occurrences of the selected event group, described by the time instant at which they occur (here, the arm was stimulated 323 times). * The time series figure is similar to the ones that were presented in the previous tutorials, with two new elements: * the events occurring in the current time window are shown at the top of the figure: if you click on a marker, it gets selected in the Event tab as well; * the navigation bar at the bottom represents the time of the entire raw file, where the events are also represented by smaller dots: The '<<' and '>>' buttons jump to the pervious/next segments, clicking on the bar change the current time window. === Channel setup === Let's switch to a nicer representation of the recordings time series: click on the "Display mode" button in the toolbar of the main Brainstorm window. {{attachment:tsColumn.gif}} Online filter Topography |
=== Navigate in time === As described in the basic tutorials, you can set the current time by using either the time panel (buttons and text field), or the figure (click on the white or grey areas of the figure). But you can notice that only a few seconds are visible in the figure, while the time panel (top left of the previous figure), indicates that we have 360s of recordings. Only a small block of the continuous file has been loaded in memory. This small time window can be configured with the tab '''Record/Page settings''', with the text boxes '''Start''' and '''Duration'''. The time series figure is similar to the ones that were presented in the previous tutorials, with a few new elements. The navigation bar at the bottom represents the time of the entire raw file, where the events are also represented by dots. The ''''<<<'''' and ''''>>>'''' buttons are the same as the ones in the time panel, and jump to the previous/next segment in the file. Clicking on the bar or dragging the red cursor change the current time window as well. === Sensor selection === Let's switch to a nicer representation of the recordings time series: click on the "Display mode" button in the toolbar of the Record tab. {{attachment:tsColumn.gif}} Now the traces are displayed in columns, but all the channels are displayed in the same figure, which makes it unreadable. Select a subset of channels by right-clicking on the figure > '''Montages''', with the drop-down menu in the Record tab or with a keyboard shortcut ('''Shift+A, B, C'''...). Default groups of sensors are available for some MEG systems, but you can also create your own groups of sensors with the menu "Edit montages". {{attachment:tsChannelSelection.gif}} === Amplitude scale === In this display mode, the amplitude scale is represented on the right of the figure. You can adjust this vertical scale: * Use the buttons "'''^'''" and "'''v'''" on the right side of the figure. The shortcuts for those buttons are indicated in the tooltips (leave the mouse for a short while over a button) * Hold the '''Shift key''' and move the mouse wheel, or use the keys "'''+'''" and "'''-'''". * Use the button "'''...'''" on the right side of the figure ("Set scale manually") to set the scale to a precise level. When scrolling in time to a different page, the amplitude scale is by default kept. You can change this behavior to re-evaluate automatically an optimal scale each time you change the current time window. This option is called "Auto-scale amplitude" and is disabled by default. To activate it: click on the "'''AS'''" button on the right of the figure, or check the menu "'''Display > Auto-scale amplitude'''" in the Record tab. === Display options === . {{attachment:displayOptions.gif}} * '''Remove DC offset''': Button [DC] in the Record tab. When selected, for each channel, the average value over the entire current time window is subtracted from the channel values. This means that if you change the length of the time window, the value that is removed from each channel may change. It doesn't make much sense to disable this option for unprocessed MEG recordings. * '''Apply CTF compensation''': Button [CTF] in the Record tab. Enable/disable the CTF noise correction based on the reference sensors, when it is not already applied in the file. In the current file, the CTF 3rd order gradient compensation is already applied, therefore this option is not available. * '''Flip +/-''': Button in the right part of the time series figure. Exchange the direction of the Y axis, useful mostly for clinical EEG. * '''Set scale manually''': Button [...] in the figure. Forces a defined amplitude scaling. * '''Auto-scale amplitude''': Button [AS] in the figure. When selected, the vertical scale is adapted to the maximum value over the time window when the time window changes. When not selected: the vertical scales keeps its last value when you jump to another part of the file. === Online filter === With the Filter tab, you can apply a band-pass filter to the recordings, or remove a set of specific frequencies (example: the 50Hz or 60Hz power lines contamination and their harmonics). The filters are applied only to the time window that is currently loaded; hence if the segment is too short for the required filters, the results could be inaccurate. The option "'''Mirror signal before filtering'''" triples artifically the length of the signal with a mirror symmetry on each side, to avoid the strong edge effects that those filters can generate. Those online filters are not very accurate, they just provide a quick estimate for visualization only, the results are not saved anywhere. To filter properly the continuous files, please use the Process1 tab. After testing the high-pass and low-pass filters and the sinusoid removal, uncheck them. If not you will probably forget about them, and they will stay on until you restart Brainstorm. {{attachment:onlineFilter.gif}} === EEG Average reference === When reviewing EEG recordings, you can switch between the original values and the average reference by clicking on the "AVG REF" button in the toolbar of the main Brainstorm window. In this case, there is no EEG recorded in the file, so selecting this option or not does not change anything. Average reference computation: at each time point, the average of all the electrodes values is subtracted from each electrode. {{attachment:avgRef.gif}} == Events, markers, triggers == === Lists of events === You probably noticed little green and blue dots on top of the recordings in the MEG figure. They represent the triggers of the electric stimulation. The stimulation computer sent those triggers simultaneously to the electric stimulator, which converted them into electric pulses sent to the wrists of the subject, and to the acquisition computer, which recorded them together with the values of the MEG sensors. All the temporal markers that are available in the file are listed in the Recordings section of the Record tab: * on the left, the groups of events and the number of occurrence for each group (102 stimulations on the left, 98 on the right); * on the right, all the occurrences of the selected event group, described by the time instant at which they occur. {{attachment:eventSelect.gif}} Those two lists are interactive. If you click on a event group (left list), it shows the occurrences for the selected event group in the right list. If you click on one particular event in the right list, the current time is set in the MEG figure to the selected event. If you click on a dot representing an event in the MEG figure, the corresponding event group and occurrence are selected in the Record tab. Those "events" can represent either stimulation triggers that were recorded during the acquisition, or additional markers that were placed by the user during the analysis (eye blinks, epileptic spikes). === Adding events === First create a new group of events called "Test", with the menu "'''Events > Add group'''". It creates a new event group with no occurrences (x0). {{attachment:addGroup.gif}} {{attachment:addGroup_done.gif}} Then select the event group "Test", and set the current time were you want to add a new Test even, by clicking on the figure (current time = where the vertical red line is). Add a few occurrences with any of the three methods: * In the Record tab: select the menu Events > '''Add / delete event ''' * In the time series figure: right-click > '''Add / delete event ''' * In the time series figure: press '''Ctrl + E ''' * Note that you can click outside of the white area to select the time (on top of the figure), or use the shortcut '''Shift+click'''. If the display is too dense, it can be difficult to set the current time instead of selecting a channel. {{attachment:addEvent_done.gif}} Now remove all the events occurrences, but not the group "Test": * In the Record tab: select one or more event occurrences (hold Shift or Control + mouse click), and press the '''Delete''' '''key'''. * In the time series figure: click on the event to delete (on the blue dot), and right-click > '''Add / delete event ''' * In the time series figure: click on the event to delete, and press '''Ctrl + E''' === Extended events === You can also use this interface to create events that have a temporal extension, ie. they last for more than one time sample. This is usually used to define bad/artifacted segments in the recordings. * In the time series window, select a time range (click + move) instead of just setting the current time. * Note that you can click outside of the white area to select the time (on top of the figure). If the display is too dense, it can be difficult to select a time window instead of a channel. * Add an event (menus or Control+E): note the way it is represented in the figure and in the Event panel. * The first occurrence you add in an event group defines the event type: single time point, or time range. You cannot mix different types of events in a group. {{attachment:extEventSel.gif}} {{attachment:extEvent.gif}} === Custom shortcuts === When reviewing long recordings and adding manually lots of events (eg. when marking manually epileptic spikes), using the menus presented previously is not very convenient because they require many mouse clicks. Using the menu '''Events > Edit keyboard shortcuts''', you can associate custom events to the key 1 to 9 of the keyboard. Define the name of the event type to create for each key, and then simply press the corresponding key to add/delete a marker at the current time position. {{attachment:evtCustom.gif}} === Bad segments === It is very common to have portions of the recordings heavily contaminated by events coming from the subject (eye blinks, movements, heartbeats, teeth clenching...) or from the environment (stimulation equipment, elevators, cars, trains, building vibrations...). Some of them are well defined and can be removed efficiently, it is the purpose of the next tutorial, some cannot. For this last category, it is usually safer to mark the noisy segments as bad, and ignore them for the rest of the analysis. To mark a segment of recordings as bad, the procedure is the same as for defining an extended event: select a time window, and then tag it as bad with one of the following methods. * In the Record tab: select the menu '''Events > Reject time segment''', * In the time series figure: right-click > '''Reject time segment''', * In the time series figure: press '''Ctrl + B''' It creates a new event group BAD, and add an extended event to it. Later, when epoching this file (extracting time blocks around the markers and saving them in the database), the trials that contain a segment marked as bad will be imported but marked as bad, and ignored in the reste of the analysis. {{attachment:bad.gif}} === Saving modifications === Now you can delete all the event groups that you've just created and leave only the "left" and "right" triggers: select the unwanted event groups and press the '''Delete key''', or use the menu '''Events > Delete group'''. When you close the raw file viewer, or the last figure that shows a part of the raw file, the dataset is unloaded, the file is released and the memory is freed. If you edited the events for this file, you are asked whether to save the modifications or not. If you answer "Yes", the modifications are saved only in the database link (Link to raw file), not in the original file itself. Therefore, you would see the changes the next time you double-click on the "link to raw file" again, but not if you open the original .ds file in another protocol or with an external program. {{attachment:saveModif.gif}} Note that events you edit are not saved automically until that moment. As you would do with any other type of computer work, save your work regularly, to limit the damages of a program or computer crash. In the Record tab, use the menu ''' File > Save modifications'''. === Other menus === {{attachment:menuFile.gif}} ==== File ==== * '''Import in database''': Import blocks of the current continuous file into the database. Equivalent to a right click on the "Link to raw file" in the database explorer > Import in database. * '''Save modifications''': Save the modifications made to the events in the database link (Link to raw file) * '''Add events from file''': Import events from an external file. Many file formats from various software are supported. * '''Read events from channel''': Read the information saved during the acquisition in an digital auxiliary channel (eg. a stimulus channel) and generate events. Generation of events based on an analog channel is not supported yet. * '''Export all events''': Save all the events in an external file, to use them in an external software or for another continuous file. * '''Export selected events''': Same as "Export all events" but exports only the selected event groups or event occurrences. ==== Events ==== * '''Rename group''': Rename the selected group of events. Shortcut: double-click. * '''Set color''': Change the color associated with an event group. * '''Merge groups''': Merge to event groups into a new group. Initial groups are deleted; to keep them, duplicate them before merging. * '''Combine stim/response''': Shortcut to call the process "Import recordings > Combine stim/response", to create new groups of events based on stim/response logic.<<BR>>Example: Stimulus A can be followed by response B or C. Use this process to split the group A in two groups: AB, followed by B; and AC, followed by C. * '''Duplicate groups''': Make a copy of the selected event groups. * '''Convert to simple events''': Convert a group of extended events (several time points for each event), to simple events (one time point). An option window asks you whether to keep the first or the last sample only of the extended events. * '''Edit keyboard shortcuts''': Custom associations between keys 1..9 and events * '''Reject time segment''': Mark the current time selection as bad (ie. create a new event type called BAD) * '''Jump to previous/next event''': Convenient way of browsing through all the occurrences of a event group. Shortcut: '''Shift + left/right''' == Shortcut summary == === Keyboard shortcuts === * '''Left / right arrows''': * No other key: Change current time, sample by sample * With '''Control '''key: Jump to previous/next time segment (same as the "<<<" and ">>>" buttons) * With '''Shift '''key: Jump to next event of the selected group * On MacOS, these shortcuts are different: please read the tooltips from the buttons ">", ">>", and ">>>" in the time panel to get the appropriate shortcuts. * '''Page-up / page-down''': * Same as left/right arrows, but faster (10 samples at a time) * If epochs are defined in the file: '''Control + page-up/page-down''' jumps to the next/previous epoch. * '''F3/Shift+F3''': Jump to the next/previous epoch or page * '''F4/Shift+F4''': Jump to the next/previous half-page * '''Plus / minus''': Adjust the vertical scale of the time series * '''Control + E''': Add / delete event occurrence * '''Control + T''': Open a 2D topography window at the current time * '''Shift + Letter''': Changes the set of electrodes currently displayed in the figure (list available by right-clicking on the figure > Display setup > ...) * '''Enter''': Display the selected channels in a separate figure (selected channels = lines on which you clicked, that are shown in red) * '''Escape''': Un-select all the selected channels * '''Delete''': Mark the selected channels as bad === Mouse shortcuts === * '''Mouse click on a channel''': Select the channel * '''Mouse click''': Change current time * '''Mouse click + Shift''': For the selection of the current time (do not select any sensor, even when clicking on a line) * '''Mouse click + move''': Select time range * '''Mouse wheel''': Zoom around current time * '''Control + mouse wheel''': Zoom vertically * '''Shift + mouse wheel''': Adjust the vertical scale of the time series * '''Right-click''': Display popup menu * '''Right-click + move''': Move in a zoomed figure * '''Double click''': Restore initial zoom settings (but do not restore the vertical scale of the time series) == Other views == === Topography views === Exactly as introduced in the [[Tutorials/TutExploreRecodings|tutorial #5 "Exploring the recordings"]], you can display a variety of 2D/3D maps of those recordings. Right-click on the node "Link to raw file" > MEG > ... {{attachment:topo.gif}} === Cortical sources === As presented in tutorial #6 to #8, you can compute successively for this raw file: a head model, a noise covariance matrix, and an inverse model. Right-click on the folder "Subject01" to get all the menus. * '''Head model''': The goal of this tutorial is only to illustrate what you can do with the raw file viewer in Brainstorm, not to localize anything for real. Keep all the default options''' '''for the head model computation. * '''Noise covariance matrix''': Set as the baseline section the entire window before the first electric stimuation (the first occurrence of event "left"): [0, 4.6] seconds. Leave the other options to the default values. * '''Sources''': Keep the default options for the minimum norm method (wMNE). At the end you can see four new files in the database. Right-click on the source file associated with the "Link to raw file" and try the different visualization menus. Delete all those new files before you move on to the next tutorial, keep only the channel file and the "Link to raw file". {{attachment:sourcesTree.gif}} {{attachment:sourcesView.gif}} == Feedback == <<EmbedContent(http://neuroimage.usc.edu/brainstorm3_register/get_feedback.php?Tutorials/TutRawViewer)>> == Next == Learn how to correct the artifacts caused by eye blinks and the heartbeats on those recordings using [[Tutorials/TutRawSsp|Signal Space Projections]]. |
C1. Review continuous recordings and edit markers
This tutorial describes how to review a continuous file and add time markers. It is based on a median nerve stimulation experiment recorded at the Montreal Neurological Institute in 2011 with a CTF MEG 275 system. The sample dataset contains 6 minutes of recordings at 1200Hz for one subject and includes 100 stimulations of each arm. The segmentation of the T1 MRI of the subject was performed using FreeSurfer.
Contents
Download and installation
- Requirements: You have already followed all the basic tutorials and you have a working copy of Brainstorm installed on your computer.
Go to the Download page of this website, and dowload the file: sample_raw.zip
- Unzip it in a folder that is not in any of the Brainstorm folders (program folder or database folder). This is really important that you always keep your original data files in a separate folder: the program folder can be deleted when updating the software, and the contents of the database folder is supposed to be manipulated only by the program itself.
- Start Brainstorm (Matlab scripts or stand-alone version)
Select the menu File > Create new protocol. Name it "TutorialRaw" and select the options:
"No, use individual anatomy",
"Yes, use one channel file per subject".
Import the anatomy
- Create a new subject Subject01
In the anatomy view, right-click on the subject > Import anatomy folder, select the file format "FreeSurfer folder" and select the folder "sample_raw/Anatomy". This imports automatically all the available files in a segmentation folder generated with FreeSurfer, as illustrated in this page.
- Leave the default number of vertices of the cortex surface (15000)
When the MRI Viewer window shows up, you have to define the position of the 6 fiducial points, as described in CoordinateSystems (set the SCS fiducials as the read anatomical nasion/left/right, not the position of the CTF coils). At the end, you should have the following MRI coordinates (+/- a few millimeters):
- NAS: x=127, y=212, z=123
- LPA: x=55, y=124, z=119
- RPA: x=200, y=129, z=114
- AC: x=129, y=137, z=157
- PC: x=129, y=113, z=157
- IH: x=129, y=118, z=209 (anywhere on the midsagittal plane)
Click on Save when you're done, and wait until the process is over. At the end, a figure shows the surfaces that were generated. Close it.
- Four files are now available as the anatomy of Subject01: a T1 MRI, a head surface, and two cortex surfaces (high and low resolution). The anatomy of the subject is ready.
Access the raw file
The basic tutorials you read before explain how to import recordings in the database: this operation creates a copy of all the data in Matlab .mat files in the Brainstorm database folders. You could process continuous recordings in the same way, but the .mat format has this limitation that the entire file has to be read even when you want to access just a portion of it. Long recordings usually cannot fit in memory and have to be split in small blocks of a few seconds, which makes it very difficult to review and process.
Brainstorm offers the possibility to visualize continuous MEG/EEG recordings in any of the supported file formats without having to fully "import" them. A link to the native file is created in the database, which can be then manipulated almost like the "imported" recording blocks. Only the description of the file is saved in the database, and when displaying it the values are read directly from the native file.
In addition, an interface allows to edit the time markers that are saved in the file. Those markers can then be used to import the recordings in the database (ie. to do the segmentation of the continous recordings in epochs/trials). Then the imported epochs/trials (hard copies in .mat format) can be pre-processed and averaged.
- Select the "Functional data (sorted by subject)" exploration mode (second button in the toolbar above the database explorer).
Right-click on the subject node, and select: "Review raw file". Select the "MEG: CTF" file type, and pick the ds folder in "/sample_raw/Data".
Then you're asked if you want to "Refine the registration with the head points". This operation improves the initial MRI/MEG registration by fitting the head points digitized before the MEG acquisition on the scalp surface with an ICP algorithm. Answer yes. Even if the result is not perfect, it usually improves the positioning of the head in the MEG helmet. The grey surface represents the head extracted from the MRI, the yellow surface represents the inside of the MEG helmet, and the green dots are the head shape points digitized with the Polhemus device; the goal is to align the green points on the grey surface.
Two new files appeared in the database explorer:
The channel file contains the definition of the sensors, exactly as when importing the files in the database with the "Import MEG/EEG" menu. It is saved in the folder (Common files), because the subject was created using the option "Yes, use one channel file per subject". Therefore, the same channel file will be used for all the folders of Subject01.
- The node named "Link to raw file" contains all the information that was read from the continous file (file format, time vector, sampling frequency, events, bad channels, path to the original file, etc.), but no recordings. The MEG and EEG values recorded will be read directly from the native file.
Review the recordings
Open the file
Right-click on the data file > MEG (all) > Display time series.
You can see new information in the tab "Record" and a figure showing the recordings.
Navigate in time
As described in the basic tutorials, you can set the current time by using either the time panel (buttons and text field), or the figure (click on the white or grey areas of the figure). But you can notice that only a few seconds are visible in the figure, while the time panel (top left of the previous figure), indicates that we have 360s of recordings. Only a small block of the continuous file has been loaded in memory. This small time window can be configured with the tab Record/Page settings, with the text boxes Start and Duration.
The time series figure is similar to the ones that were presented in the previous tutorials, with a few new elements. The navigation bar at the bottom represents the time of the entire raw file, where the events are also represented by dots. The '<<<' and '>>>' buttons are the same as the ones in the time panel, and jump to the previous/next segment in the file. Clicking on the bar or dragging the red cursor change the current time window as well.
Sensor selection
Let's switch to a nicer representation of the recordings time series: click on the "Display mode" button in the toolbar of the Record tab.
Now the traces are displayed in columns, but all the channels are displayed in the same figure, which makes it unreadable. Select a subset of channels by right-clicking on the figure > Montages, with the drop-down menu in the Record tab or with a keyboard shortcut (Shift+A, B, C...). Default groups of sensors are available for some MEG systems, but you can also create your own groups of sensors with the menu "Edit montages".
Amplitude scale
In this display mode, the amplitude scale is represented on the right of the figure. You can adjust this vertical scale:
Use the buttons "^" and "v" on the right side of the figure. The shortcuts for those buttons are indicated in the tooltips (leave the mouse for a short while over a button)
Hold the Shift key and move the mouse wheel, or use the keys "+" and "-".
Use the button "..." on the right side of the figure ("Set scale manually") to set the scale to a precise level.
When scrolling in time to a different page, the amplitude scale is by default kept. You can change this behavior to re-evaluate automatically an optimal scale each time you change the current time window. This option is called "Auto-scale amplitude" and is disabled by default. To activate it: click on the "AS" button on the right of the figure, or check the menu "Display > Auto-scale amplitude" in the Record tab.
Display options
Remove DC offset: Button [DC] in the Record tab. When selected, for each channel, the average value over the entire current time window is subtracted from the channel values. This means that if you change the length of the time window, the value that is removed from each channel may change. It doesn't make much sense to disable this option for unprocessed MEG recordings.
Apply CTF compensation: Button [CTF] in the Record tab. Enable/disable the CTF noise correction based on the reference sensors, when it is not already applied in the file. In the current file, the CTF 3rd order gradient compensation is already applied, therefore this option is not available.
Flip +/-: Button in the right part of the time series figure. Exchange the direction of the Y axis, useful mostly for clinical EEG.
Set scale manually: Button [...] in the figure. Forces a defined amplitude scaling.
Auto-scale amplitude: Button [AS] in the figure. When selected, the vertical scale is adapted to the maximum value over the time window when the time window changes. When not selected: the vertical scales keeps its last value when you jump to another part of the file.
Online filter
With the Filter tab, you can apply a band-pass filter to the recordings, or remove a set of specific frequencies (example: the 50Hz or 60Hz power lines contamination and their harmonics). The filters are applied only to the time window that is currently loaded; hence if the segment is too short for the required filters, the results could be inaccurate.
The option "Mirror signal before filtering" triples artifically the length of the signal with a mirror symmetry on each side, to avoid the strong edge effects that those filters can generate. Those online filters are not very accurate, they just provide a quick estimate for visualization only, the results are not saved anywhere. To filter properly the continuous files, please use the Process1 tab.
After testing the high-pass and low-pass filters and the sinusoid removal, uncheck them. If not you will probably forget about them, and they will stay on until you restart Brainstorm.
EEG Average reference
When reviewing EEG recordings, you can switch between the original values and the average reference by clicking on the "AVG REF" button in the toolbar of the main Brainstorm window. In this case, there is no EEG recorded in the file, so selecting this option or not does not change anything.
Average reference computation: at each time point, the average of all the electrodes values is subtracted from each electrode.
Events, markers, triggers
Lists of events
You probably noticed little green and blue dots on top of the recordings in the MEG figure. They represent the triggers of the electric stimulation. The stimulation computer sent those triggers simultaneously to the electric stimulator, which converted them into electric pulses sent to the wrists of the subject, and to the acquisition computer, which recorded them together with the values of the MEG sensors.
All the temporal markers that are available in the file are listed in the Recordings section of the Record tab:
- on the left, the groups of events and the number of occurrence for each group (102 stimulations on the left, 98 on the right);
- on the right, all the occurrences of the selected event group, described by the time instant at which they occur.
Those two lists are interactive. If you click on a event group (left list), it shows the occurrences for the selected event group in the right list. If you click on one particular event in the right list, the current time is set in the MEG figure to the selected event. If you click on a dot representing an event in the MEG figure, the corresponding event group and occurrence are selected in the Record tab.
Those "events" can represent either stimulation triggers that were recorded during the acquisition, or additional markers that were placed by the user during the analysis (eye blinks, epileptic spikes).
Adding events
First create a new group of events called "Test", with the menu "Events > Add group". It creates a new event group with no occurrences (x0).
Then select the event group "Test", and set the current time were you want to add a new Test even, by clicking on the figure (current time = where the vertical red line is). Add a few occurrences with any of the three methods:
In the Record tab: select the menu Events > Add / delete event
In the time series figure: right-click > Add / delete event
In the time series figure: press Ctrl + E
Note that you can click outside of the white area to select the time (on top of the figure), or use the shortcut Shift+click. If the display is too dense, it can be difficult to set the current time instead of selecting a channel.
Now remove all the events occurrences, but not the group "Test":
In the Record tab: select one or more event occurrences (hold Shift or Control + mouse click), and press the Delete key.
In the time series figure: click on the event to delete (on the blue dot), and right-click > Add / delete event
In the time series figure: click on the event to delete, and press Ctrl + E
Extended events
You can also use this interface to create events that have a temporal extension, ie. they last for more than one time sample. This is usually used to define bad/artifacted segments in the recordings.
- In the time series window, select a time range (click + move) instead of just setting the current time.
- Note that you can click outside of the white area to select the time (on top of the figure). If the display is too dense, it can be difficult to select a time window instead of a channel.
- Add an event (menus or Control+E): note the way it is represented in the figure and in the Event panel.
- The first occurrence you add in an event group defines the event type: single time point, or time range. You cannot mix different types of events in a group.
Custom shortcuts
When reviewing long recordings and adding manually lots of events (eg. when marking manually epileptic spikes), using the menus presented previously is not very convenient because they require many mouse clicks. Using the menu Events > Edit keyboard shortcuts, you can associate custom events to the key 1 to 9 of the keyboard. Define the name of the event type to create for each key, and then simply press the corresponding key to add/delete a marker at the current time position.
Bad segments
It is very common to have portions of the recordings heavily contaminated by events coming from the subject (eye blinks, movements, heartbeats, teeth clenching...) or from the environment (stimulation equipment, elevators, cars, trains, building vibrations...). Some of them are well defined and can be removed efficiently, it is the purpose of the next tutorial, some cannot. For this last category, it is usually safer to mark the noisy segments as bad, and ignore them for the rest of the analysis.
To mark a segment of recordings as bad, the procedure is the same as for defining an extended event: select a time window, and then tag it as bad with one of the following methods.
In the Record tab: select the menu Events > Reject time segment,
In the time series figure: right-click > Reject time segment,
In the time series figure: press Ctrl + B
It creates a new event group BAD, and add an extended event to it. Later, when epoching this file (extracting time blocks around the markers and saving them in the database), the trials that contain a segment marked as bad will be imported but marked as bad, and ignored in the reste of the analysis.
Saving modifications
Now you can delete all the event groups that you've just created and leave only the "left" and "right" triggers: select the unwanted event groups and press the Delete key, or use the menu Events > Delete group.
When you close the raw file viewer, or the last figure that shows a part of the raw file, the dataset is unloaded, the file is released and the memory is freed.
If you edited the events for this file, you are asked whether to save the modifications or not. If you answer "Yes", the modifications are saved only in the database link (Link to raw file), not in the original file itself. Therefore, you would see the changes the next time you double-click on the "link to raw file" again, but not if you open the original .ds file in another protocol or with an external program.
Note that events you edit are not saved automically until that moment. As you would do with any other type of computer work, save your work regularly, to limit the damages of a program or computer crash. In the Record tab, use the menu File > Save modifications.
Other menus
File
Import in database: Import blocks of the current continuous file into the database. Equivalent to a right click on the "Link to raw file" in the database explorer > Import in database.
Save modifications: Save the modifications made to the events in the database link (Link to raw file)
Add events from file: Import events from an external file. Many file formats from various software are supported.
Read events from channel: Read the information saved during the acquisition in an digital auxiliary channel (eg. a stimulus channel) and generate events. Generation of events based on an analog channel is not supported yet.
Export all events: Save all the events in an external file, to use them in an external software or for another continuous file.
Export selected events: Same as "Export all events" but exports only the selected event groups or event occurrences.
Events
Rename group: Rename the selected group of events. Shortcut: double-click.
Set color: Change the color associated with an event group.
Merge groups: Merge to event groups into a new group. Initial groups are deleted; to keep them, duplicate them before merging.
Combine stim/response: Shortcut to call the process "Import recordings > Combine stim/response", to create new groups of events based on stim/response logic.
Example: Stimulus A can be followed by response B or C. Use this process to split the group A in two groups: AB, followed by B; and AC, followed by C.Duplicate groups: Make a copy of the selected event groups.
Convert to simple events: Convert a group of extended events (several time points for each event), to simple events (one time point). An option window asks you whether to keep the first or the last sample only of the extended events.
Edit keyboard shortcuts: Custom associations between keys 1..9 and events
Reject time segment: Mark the current time selection as bad (ie. create a new event type called BAD)
Jump to previous/next event: Convenient way of browsing through all the occurrences of a event group. Shortcut: Shift + left/right
Shortcut summary
Keyboard shortcuts
Left / right arrows:
- No other key: Change current time, sample by sample
With Control key: Jump to previous/next time segment (same as the "<<<" and ">>>" buttons)
With Shift key: Jump to next event of the selected group
On MacOS, these shortcuts are different: please read the tooltips from the buttons ">", ">>", and ">>>" in the time panel to get the appropriate shortcuts.
Page-up / page-down:
- Same as left/right arrows, but faster (10 samples at a time)
If epochs are defined in the file: Control + page-up/page-down jumps to the next/previous epoch.
F3/Shift+F3: Jump to the next/previous epoch or page
F4/Shift+F4: Jump to the next/previous half-page
Plus / minus: Adjust the vertical scale of the time series
Control + E: Add / delete event occurrence
Control + T: Open a 2D topography window at the current time
Shift + Letter: Changes the set of electrodes currently displayed in the figure (list available by right-clicking on the figure > Display setup > ...)
Enter: Display the selected channels in a separate figure (selected channels = lines on which you clicked, that are shown in red)
Escape: Un-select all the selected channels
Delete: Mark the selected channels as bad
Mouse shortcuts
Mouse click on a channel: Select the channel
Mouse click: Change current time
Mouse click + Shift: For the selection of the current time (do not select any sensor, even when clicking on a line)
Mouse click + move: Select time range
Mouse wheel: Zoom around current time
Control + mouse wheel: Zoom vertically
Shift + mouse wheel: Adjust the vertical scale of the time series
Right-click: Display popup menu
Right-click + move: Move in a zoomed figure
Double click: Restore initial zoom settings (but do not restore the vertical scale of the time series)
Other views
Topography views
Exactly as introduced in the ?tutorial #5 "Exploring the recordings", you can display a variety of 2D/3D maps of those recordings. Right-click on the node "Link to raw file" > MEG > ...
Cortical sources
As presented in tutorial #6 to #8, you can compute successively for this raw file: a head model, a noise covariance matrix, and an inverse model. Right-click on the folder "Subject01" to get all the menus.
Head model: The goal of this tutorial is only to illustrate what you can do with the raw file viewer in Brainstorm, not to localize anything for real. Keep all the default options for the head model computation.
Noise covariance matrix: Set as the baseline section the entire window before the first electric stimuation (the first occurrence of event "left"): [0, 4.6] seconds. Leave the other options to the default values.
Sources: Keep the default options for the minimum norm method (wMNE).
At the end you can see four new files in the database. Right-click on the source file associated with the "Link to raw file" and try the different visualization menus.
Delete all those new files before you move on to the next tutorial, keep only the channel file and the "Link to raw file".
Feedback
Next
Learn how to correct the artifacts caused by eye blinks and the heartbeats on those recordings using ?Signal Space Projections.