MRI fiducial markers

November 10th, 2015

In concurrent NIRS-MRI experiments, you often need to know exactly where the NIRS probes are in the MRI iamges. In this case, a fiducial marker becomes important.

In our 2011 publication titled “A quantitative comparison of NIRS and fMRI across multiple cognitive tasks“, we used some fiducial markers and they work really well. Below you will find a picture (see B, C and E) where the fiducial markers are shown clearly in MRI images.

MRI fiducial markers

MRI fiducial markers

Please be sure to use ring-shaped markers as you will know exactly where the markers are.

Where did we buy the markers? They are from MRIEquip (

(MRIEquip, SKU: BP-103X, Model: BP-1015, 15-mm 233 outer diameter, 3.5 mm thick, 5-mm central axis hole)

And below is a sentense in our paper:

MRI fiducial markers were affixed to the inner side of the measurement patch at the location of each of the 24 channels (i.e., between every emitter–detector pair) to identify the positions of NIRS cannels in the MRI structural images.

Author: Xu Cui Categories: brain, nirs Tags:

xjView 8.13 released. Allow to change the minimum of colorbar range

November 9th, 2015

xjView 8.14 just released. Download link:

xjView 8.13 is released with the following new features:

  1. Allow to change the minimum value of the color bar range. This will enable you to do
    1. Create a symmetric color bar from negative to positive. For example, from -8 to 8
    2. Use cold color to show “negative” contrast. In this case, you simply set the max as 0, and min as a positive number such as 5
  2. Allow to resize the xjView window

A short tutorial video:
Download link:

Author: Xu Cui Categories: matlab, programming Tags:

NIRS hyperscanning data analysis (4) coherence analysis

November 2nd, 2015

NIRS hyperscanning data analysis (1)
NIRS hyperscanning data analysis (2)
NIRS hyperscanning data analysis (3)
NIRS hyperscanning data analysis (4)

How do we analyze hyperscanning data to find out the relationship between two brains? Obviously correlation is the first thought. However, raw correlation analysis might be susceptible to noise in the data (e.g. physiological noise such as heart beating, or motion noise). Wavelet coherence is a great way to find correlation between two signals - at the same time not affected by physiological noises. To understand wavelet coherence, you might want to read:

  1. Wavelet coherence
  2. What does a wavelet coherence plot tell you?

Let’s look at the data of a pair of subjects (please click the image to zoom):

Wavelet coherence of a pair of subjects

Wavelet coherence of a pair of subjects

There are 22 channels in total in each participant. Each small plot in the figure above is for one channel. The plots are arranged following the real position of the channel on the participant’s head. How did I arrange them? I cut and paste and arrange in PowerPoint :) You can imagine it took me some time. I wish there is a handy tool.

By looking at this figure, a pattern pops out - there is a band in the period 6.4s in multiple channels. Maybe this band (increase of coherence) is a signature of collaboration. To quantify this, we average the coherence value around the band (between periods 3.2 and 12.8s in the task block, and the rest period in between):

[Rsq,period,scale,coi,sig95] = wtc(signal1,signal2,'mcc',0, 'ms',128);
period32 = find(period>32);
period32 = period32(1);
b1 = mean(mean(Rsq(period32:end, marktime(1):marktime(2))));
bi = mean(mean(Rsq(period32:end, marktime(2):marktime(3))));
b2 = mean(mean(Rsq(period32:end, marktime(3):marktime(4))));

Now we get a 3 values for each channel. I normally define “coherence increase” as the average of the coherence during task minus the coherence in rest. So CI = (b1+b2)/2 - bi

For each channel in each subject pair, we got a single value (CI). Then for each channel, we can do a group analysis using T-test. After we get all the T-values for all channels, then we can plot the map using plotTopoMap

Group coherence T map

Group coherence T map

This is basic analysis. You can go much deeper from here. Below are some examples:

  1. Is there a learning effect? i.e. is the performance during the 2nd block better than the 1st block? Is the coherence increase higher than the 1st block?
  2. Does coherence increase in the collaboration block differ from other blocks (such as competition, independent blocks)?
  3. Does the phase of the coherence carry any information?
Author: Xu Cui Categories: brain, matlab, nirs Tags:

Using the anti-correlation between oxy and deoxy hemoglobin for NIRS data quality

October 12th, 2015

Back in 2009 we published a paper titled “Functional near infrared spectroscopy (NIRS) signal improvement based on negative correlation between oxygenated and deoxygenated hemoglobin dynamics“. In a nutshell, we found the oxy- and deoxy-Hb are negatively correlated when noise level is low. When noise level increases, their correlation becomes more and more positive.

Correlation between oxy and deoxy-Hb

Correlation between oxy and deoxy-Hb

Based on this phenomenon we can check the noise level of a channel using the correlation. Below is the script. You simply input the hbo and hbr data (both matrix), and the output is the bad channels.

function badChannels = checkDataQuality(hbo,hbr)

% function badChannels = checkDataQuality(hbo,hbr)
% Check data quality using correlation between hbo and hbr as indicator
% if the correlation is strictly -1, then bad channel
% if the correlation is > 0.5, then bad channel
% Input: hbo and hbr are NxM matrix, N is number of scan, and M number of
% channels
% output: array of bad channels
% Xu Cui
% 2009/11/25

n = size(hbo,2);
for ii=1:n
    tmp = corrcoef(hbo(:,ii), hbr(:,ii));
    c(ii) = tmp(2);

pos = find(c==-1);
if ~isempty(pos)
    disp(['Channels with -1 correlation: ' num2str(pos)])

pos2 = find(c>0.5);
if ~isempty(pos2)
    disp(['Channels with >0.5 correlation: ' num2str(pos2)])

badChannels = [pos pos2];
Author: Xu Cui Categories: nirs Tags:

Fisher transformation

September 21st, 2015

Assume you are doing a correlation study between two brain areas, A and B. For each subject, you get a single value, the correlation between A and B. And you have 100 subjects.

How do you know if the mean of the correlation is significantly different from 0? And how do you perform statistic tests on these correlation values?

Prior to do the statistics on correlation value, you need to convert them to something which is more “normally” behaved. Fisher’s transformation will do the work:

Author: Xu Cui Categories: brain Tags:

NIRS hyperscanning data analysis (3) quality check

September 21st, 2015

NIRS hyperscanning data analysis (1)
NIRS hyperscanning data analysis (2)
NIRS hyperscanning data analysis (3)
NIRS hyperscanning data analysis (4)

Data quality check

1. Behavior data

To identify behavior abnormalities, we need to plot the behavior data for each individual subject. In this case, we plotted the reaction time vs trial. An example is shown below. It apparent that subject 2 (red) did something strange in trial 20.

behavior data (reaction time)

behavior data (reaction time)

We can also plot the difference of reaction time and the threshold to win. Obviously they only win 1 trial and this is unusual.

Reaction time different and threshold

Reaction time different and threshold

We can also find the mean, min and max of the reaction times. Below is the script:

hold on;plot([1:40],subjectData.reaction2,'s-r')

hold on;plot([1:40],subjectData.winthreshold,'s-m')
legend({'reaction time difference','threshold'})

winNum = sum((subjectData.winthreshold - abs(subjectData.reaction1-subjectData.reaction2))>0);
disp('winning trials = ')




2. NIRS data

The 1st way to identify abnormalities in NIRS data is to plot all channel’s time series in one figure, like the figure below. In the following figure, the time series for each channel is plotted and aligned vertically. It’s easy to identify that the green channel (channel #44) has much more noise than others.

NIRS time series

Another way is to use wavelet transform. If the NIRS signal was acquired well, then the heart beating signal should be captured, leaving a bright brand in the frequency ~1Hz in the wavelet transform plot, just like the left plot in the figure below (the band close to period 8). If there is no such band, it does not necessarily mean the signal is trash, but you need to be cautious.

NIRS wavelet

NIRS wavelet

The third way is to check the correlation between hbo and hbr. They are supposed to have negative correlation. If not, or if they have perfect negative correlation (-1), then they might contain too much noise. We have a separate article on this method. Please check out




for ii=1:52; wt(hbo(:,ii)); pause; end

[badchannels] = checkDataQuality(hbo,hbr);

3. Digitizer data

You want to make sure the measure digitizer data is reasonable by looking at the probe positions in a 3D space.

Digitizer data

Digitizer data

figure;plot3(pos_data(:,1),pos_data(:,2),pos_data(:,3),'o');axis equal;
Author: Xu Cui Categories: Uncategorized Tags:

NIRS hyperscanning data analysis (2)

August 31st, 2015

NIRS hyperscanning data analysis (1)
NIRS hyperscanning data analysis (2)
NIRS hyperscanning data analysis (3)
NIRS hyperscanning data analysis (4)

Data collection

We used Hitachi’s ETG 4000 to collect data. This device normally collects data from a single head. In some of the configurations, it has a set of fibers collecting the signal from the left brain, the other set from the right brain. We thought, why don’t we use the second set to collect signal on another person?

That’s what we did. The ETG 4000 system still treated the two streams of signals from a single brain, but later when we do the data analysis, we separated them.

We used one 3×5 patch on one person’s head, and the other 3×5 patch on the 2nd person’s head. The patch covers only a small area of the brains, so we need to pick up which brain region we need to measure. We chose the frontal cortex. Frankly speaking we don’t have a solid reason to do so, except:

(1) for a high level cognitive task like collaboration, frontal cortex is probably involved;
(2) the frontal region is easier to place the NIRS patch (there is no hair! Separating hair to get a better signal drives me crazy!), and the signal-to-noise ratio is higher compared to other brain areas (the skull is thinner in this region, as demonstrated by our other publications, see figure below).

Skull thickness

Skull thickness

So we put the caps on the frontal lobe - mostly for easier of experiment. You can see a picture below. In the picture are Dan (researcher assistant at that time) and me.

NIRS cap on head

NIRS cap on head

We tried to put the cap in the same position for all subjects. Of course, everybody’s head shape is different, so it’s not possible to precisely put the cap in the same location. But we follow some standard techniques such as using the eyebrow and midline as the landmark. In the end, we find this approach works reasonably well.

For this experiment, we did not collect the 3D digitizer data (to localize the channel location more precisely). The current method of collecting 3D digitizer data is tedious and prone to errors. I wish in the future the NIRS device can automatically tell the locations of each probe.

Author: Xu Cui Categories: nirs Tags:

NIRS hyperscanning data analysis (1)

August 24th, 2015

NIRS hyperscanning data analysis (1)
NIRS hyperscanning data analysis (2)
NIRS hyperscanning data analysis (3)
NIRS hyperscanning data analysis (4)

In this series I will introduce how we analyzed NIRS hyperscanning data. NIRS hyperscanning is a technology where you can measure two (or more) people’s brains at the same time. This is useful in studying the brain basis of social behavior.

We will cover:

  1. Experiment design
  2. Data collection
  3. Data quality check
  4. Wavelet coherence analysis
  5. Group level statistics

Experiment design

11 pairs of participants (total 22)
Each pair run 4 experiments: cooperation, competition, single 1, and single 2
Cooperation (our main task): In each trial, a gray circle appears on the screen. After 0.6-1.5s, the gray circle is filled with green (‘go’ signal). The participants were instructed to press their corresponding keys after the ‘go’ signal. If the difference between of two timing of pressing is smaller than a threshold, then they both gain a point; otherwise they both lose a point. They were instructed to maximize the points.
Competition: Similar to the cooperation experiment, except that the participant who press the key earlier will win a point (and the other will lose a point).
Single 1: participant 1 press button while participant 2 observes.
Single 2: participant 2 press button while participant 1 observes.
In each experiment, participants performed the task in two blocks, separated by a 30s rest period.

Cooperation game in a NIRS hyperscanning experiment

Cooperation game in a NIRS hyperscanning experiment

I myself played this game for quite some times and it’s not a very easy game. The two players have to press the buttons at the same time to win.

You can find the source MatLab code for the experiment below. These scripts are adopted from a previous experiment when I was in Baylor College of Medicine. You will see that the scripts are in no way well commented and it’s probably difficult to read. But in any case it might be helpful. Also note that the scripts require PsychToolbox.

Please fill the form and download the scripts:

Author: Xu Cui Categories: brain, nirs Tags:

NIRS: project digitizer data on brain using NFRI tool

July 13th, 2015

If you have digitizer data, then NFRI tool can be very useful to visualize these data on a brain.

If you can’t access youtube, see below:

Author: Xu Cui Categories: brain, nirs Tags:

Can we control a robot by thought?

July 6th, 2015

Honda has developed new brain-machine interface (BMI) technology that allows humans to control the Asimo humanoid robot simply by thinking certain thoughts. The technology is based on combined EEG and NIRS. The system reportedly has an accuracy rate of more than 90%.

Thought controls robot

Thought controls robot

You can see a live video here.

Author: Xu Cui Categories: nirs Tags: