Tutorial: NIRS data importation, visualization and response estimate in the optode space


Author: Thomas Vincent, PERFORM Centre and physics dpt., Concordia University, Montreal, Canada
(thomas.vincent at concordia dot ca)


This tutorial illustrates how to import and process NIRS recordings in Brainstorm.

Presentation of the experiment

Download and installation

Import anatomy

Import NIRS functional data

The functional data used in this tutorial was produced by the Brainsight acquisition software and is available in the data subfolder of the nirs sample folder. It contains the following files:

To import this dataset in Brainstorm:


In the same way as in the tutorial "Channel file / MEG-MRI coregistration", the registration between the MRI and the NIRS is first based on three reference points Nasion, Left and Right ears. It can then be refined with the either the full head shape of the subject or with manual adjustment.

To review this registration:

As reference, the following figures show the position of fiducials [blue] (inion and nose tip are extra positions), sources [orange] and detectors [green] as they were digitized by Brainsight:

NIRSTORM_tut_nirs_tapping_brainsight_head_mesh_fiducials_1.gif NIRSTORM_tut_nirs_tapping_brainsight_head_mesh_fiducials_2.gif NIRSTORM_tut_nirs_tapping_brainsight_head_mesh_fiducials_3.gif

Review Channel information

The resulting data organization should be:


This indicates that the data comes from the Brainsight system (BRS) and comprises 97 channels (96 NIRS channels + 1 auxiliary signals).

To review the content of channels, right-click on the channel file > Edit channel file.


Visualize NIRS signals

Select "Subject01 |- S01_Block_FO_LH_Run01 |- Link to raw file -> NIRS -> Display time series". It will open a new figure with superimposed channels. If DC is enabled, the figure should look like:


Note that brainstorm uses a dynamical montage, called NIRS Overlay, to regroup and color-code nirs time-series depending on the wavelength (red: 830nm, green:686nm). The signals for a given pair of source and detectors are also grouped when using the selection tool. So clicking one curve for one wavelength will also select the other wavelength for the same pair.

To isolate the signals of a selected pair, the default behaviour of brainstorm can be used by pressing ENTER or right-click on the figure then "Channel > View selected". However, the NIRS overlay dynamic montage is not activated in this case. The alternative is to specify the selection by creating a custom montage.

In the figure control panel (main brainstorm window), select "NIRS Overlay > Edit Montages ..."


Then create a new custom montage with required channels, eg S1D1 et S2D1:


On the right panel, each line defines how to represent a given channel:

<label_name> | <color> : <channel_name>

Extract stimulation events

During the experiment, the stimulation paradigm was run under matlab and sent triggers through the parallel port to the acquisition device. These stimulation events are then stored as a box signal in channel AUX1: values above a certain threshold indicate a stimulation block.

To view the auxiliary data, select "Subject01 |- S01_Block_FO_LH_Run01 |- Link to raw file -> NIRS_AUX -> Display time series"


To transform this signal into Brainstorm events, drag and drop the NIRS data "S01_Block_FO_LH_Run01 |- Link to raw file" in the Brainstorm process window. Click on "Run" and select Process "Events -> Read from channel".


Use the following parameters:

Run the process.

Then right-click on "Link to raw file" under "S01_Block_FO_LH_Run01" then "NIRS -> Display time series". There should be an event group called "AUX1". Rename it to "MOTOR" using "Events -> Rename Group".


The "MOTOR" event group has 10 events which are shown in green on the top of the plot.

Movement correction

In fNIRS data, a movement usually induces a spiked signal variation and shifts the signal baseline. A movement artefact spreads to all channels as the whole head or several scalp muscles are moving. The correction process available is semi-atomatic as it requires the user to tag the movement events. The method used to correct movement is based on spline interpolation.

To tag specific events (see this tutorial for a complete presentation of event marking), double-click on "Link to raw file" under "S01_Block_FO_LH_Run01" then in the "Events" menu, select "Add group" and enter "NIRS_mvt".

On the time-series, we can identify 3 obvious movement events, highlighted in blue here:


Use shift-left-click to position the temporal marker at the beginning of the movement. Then use the middle mouse wheel to zoom on it and use shift-left-click again to precisely adjust the position of the start of the movement event. Drag until the end of the movement event and use CTRL+E to mark the event.


Repeat the operation for all 3 movement events. You should end up with the following event definitions:


After saving and closing all graphic windows, drag and drop "Link to raw file" into the process field and press "Run". In the process menu, select "NIRS > Motion correction".

In the process option window, set "Movement event name" to "NIRS_mvt" then click "Run". To check the result, open the obtained time-series "S01_Block_FO_LH_Run01 |- Motion-corrected NIRS" along with the raw one and zoom at the end of the time-series (shift+left-click then mouse wheel):


As we can see, the two last movement artefacts are well corrected but the first one is not. This highlights the fact that the motion correction method corrects for rather smooth variations in the signal and spiking events (very rapid movement) are not filtered. However, this is not troubling as spiking artefacts should be filtered out during bandpass filtering.

Note that marked movement events are removed in the resulting data set.

Bad channel tagging

NIRS measurement are heterogeneous (long distance measurements, movements, occlusion by hair) and the signal in several channels might not be properly analysed. A first pre-processing step hence consists in removing those channels.

The following criterions may be applied to reject channels:

Clear the Brainstorm process panel and drag and drop the NIRS data "S01_Block_FO_LH_Run01 |- Motion-corrected NIRS" in it. Click on "Run" and select Process "NIRS -> Detect bad channels".


This process is performed "in place": the channel flags of the given data are modified. To view the result, right-click on "S01_Block_FO_LH_Run01 |- Motion-corrected NIRS" then "Good/Bad Channels > View all bad channels" or "Edit good/bad channels".

Compute [Hb] variations - Modified Beer-Lambert Law

This process computes variations of concentration of oxy-hemoglobin (HbO), deoxy-hemoglobin (HbR) and total hemoglobin (HbT) from the measured light intensity time courses at different wavelengths.

Note that the channel definition will differ from the raw data. Previously there was one channel per wavelength, now there will be one channel per Hb type (HbO, HbR or HbT). The total number of channels may change.

For a given pair, the formula used is:



Make sure the item "S01_Block_FO_LH_Run01 |- Motion-corrected NIRS" is in the Brainstorm process panel. Then select Run and "NIRS > MBLL - OD to delta [HbO], [HbR] & [HbT]".

Process parameters:

This process creates a new condition folder, here "S01_Block_FO_LH_Run01_Hb", because the montage is redefined.

Under "S01_Block_FO_LH_Run01_Hb", double-click on "Hb [Topo]" to browse the delta [Hb] time-series. NIRSTORM_tut_nirs_tapping_view_hb.png

Linear detrend

This filter process removes any linear trend in the signal.

Clear the process window and drag and drop the item "S01_Block_FO_LH_Run01_Hb |- Hb [Topo]" into it. Click on "Run" then select "Pre-process -> Remove linear trend"



This process creates an item called "Hb | detrend"

Infinite Impulse Response filtering

So far, signals still contain a lot of physiological components of non-interest: heart beats, breathing and Mayer waves. As the evoked signal of interest should be distinct from those components in terms of frequency bands, we can get rid of them by filtering.

Make sure the item "S01_Block_FO_LH_Run01_Hb |- Hb [Topo]" is in the Brainstorm process panel. Then select Run and "Pre-process > Band-pass filter".



This process creates an item called "Hb [Topo] | detrend | band(0.005-0.08Hz)"

Here is the resulting filtered Hb data:


Window averaging

the goal is to get the response elicited by the motor paradigm. For this, we perform window-averaging time-locked on each motor onset while correcting for baseline differences across trials.

The first step is to split the data into chunks corresponding to the window over which we want to average. The average window is wider than the stimulation events: we'd like to see the return to baseline / undershoot after stimulation.

Right-click on "Hb [Topo] | detrend | IIR filtered -> Import in database"


Ensure that "Use events" is checked and that the MOTOR events are selected. The epoch time should be: -5000 to 55000 ms. This means that there will be 5 seconds prior to the stimulation event to check if the signal is steady. There will also be 25 seconds after the stimulation to check the return to baseline / undershoot. In the "Pre-processing" panel, check "Remove DC offset" and use a Time range of -5000 to -100 ms. This will set a reference window prior over which to remove chunk offsets. All signals will be zero-centered according to this window. Finally, ensure that the option "Create a separate folder for each event type" is unchecked".

After clicking on "import", we end up with 10 "MOTOR" data chunks.

The last step is to actually compute the average of these chunks. Clear the process panel then drag and drop the item "MOTOR (10 files)" into it. Click on "run" and select the process "Average -> Average files".


Use Group files: Everything and Function: Arithmetic average + Standard deviation.

To see the results, double click on the created item "AvgStd: MOTOR (10)". To view the values mapped on the channels, right-click on the curve figure and select "View topography". Views are temporally synchronized, so shift-clicking on the curve figure at a specific time position will update the topography view with the channel values at that instant.


By default, delta [HbO] is displayed in the topography. This can be changed by right-clicking on the 3D view and selecting "Montage > HbR" or "Montage > HbT".

Tutorials/NIRSFingerTapping (last edited 2017-08-21 01:11:04 by ?ThomasVincent)