= Tutorial 7: Event markers = ''Authors: Francois Tadel, Elizabeth Bock, John C Mosher'' <> = From Continuous = == 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. {{http://neuroimage.usc.edu/brainstorm/Tutorials/TutRawViewer?action=AttachFile&do=get&target=eventSelect.gif|eventSelect.gif|class="attachment"}} 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). {{http://neuroimage.usc.edu/brainstorm/Tutorials/TutRawViewer?action=AttachFile&do=get&target=addGroup.gif|addGroup.gif|class="attachment"}} 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. {{http://neuroimage.usc.edu/brainstorm/Tutorials/TutRawViewer?action=AttachFile&do=get&target=addEvent_done.gif|addEvent_done.gif|class="attachment"}} 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. {{http://neuroimage.usc.edu/brainstorm/Tutorials/TutRawViewer?action=AttachFile&do=get&target=extEventSel.gif|extEventSel.gif|class="attachment"}} {{http://neuroimage.usc.edu/brainstorm/Tutorials/TutRawViewer?action=AttachFile&do=get&target=extEvent.gif|extEvent.gif|class="attachment"}} == 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. {{http://neuroimage.usc.edu/brainstorm/Tutorials/TutRawViewer?action=AttachFile&do=get&target=evtCustom.gif|evtCustom.gif|class="attachment"}} == 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 rest of the analysis. {{http://neuroimage.usc.edu/brainstorm/Tutorials/TutRawViewer?action=AttachFile&do=get&target=bad.gif|bad.gif|class="attachment"}} == 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. {{http://neuroimage.usc.edu/brainstorm/Tutorials/TutRawViewer?action=AttachFile&do=get&target=saveModif.gif|saveModif.gif|class="attachment"}} Note that events you edit are not saved automatically 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 == {{http://neuroimage.usc.edu/brainstorm/Tutorials/TutRawViewer?action=AttachFile&do=get&target=menuFile.gif|menuFile.gif|class="attachment"}} ==== 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''' <> <>