Fix narginchk Error using SPM

May 7th, 2019

Today I downloaded SPM 12 latest version, and when I tried to start it complained:

Error using narginchk (line 10)
too many input arguments

This error is caused by the conflict of multiple narginchk functions. To find out where they are, type

>> which -all narginchk
C:\Users\Xu Cui\Dropbox\spm12\external\fieldtrip\compat\matlablt2011b\narginchk.m
built-in (C:\MATLAB\R2015b\toolbox\matlab\lang\narginchk)

Then I simply renamed the first narginchk.m to a different name (e.g. _narginchk.m), and now it works.

Author: Xu Cui Categories: brain, fmri Tags:

How to fix bluetooth mouse not working under windows 10?

May 3rd, 2019

I am using a Dell laptop with Windows 10. It’s been working great, but occasionally my bluetooth mouse won’t work. Sometimes I need to re-install the driver, sometimes I need to restart the computer. But it does not always resume working.

Below is a method which solved my problem (it’s a youtube video):

In a nutshell, you need to disable “fast boot” in power options, and delete the blooth device in device manager, and then shut down (not restart) your computer, and then start your computer. Hope it works for you.

Author: Xu Cui Categories: life Tags:

Interview with Drs. Chenbo Wang and Xianchun Li

April 26th, 2019

A group of scientists in East China Normal University has published a paper earlier this month titled “Dynamic interpersonal neural synchronization underlying pain-induced cooperation in females” in HBM. They studied how pain affected cooperation between female students using fNIRS hyperscanning. We interviewed the authors Chenbo Wang and Xianchun Li and they are generous in sharing their experience about this study.

Chenbo Wang

Chenbo Wang

Xianchun Li

Xianchun Li

Congratulations on your recent paper in HBM.

1. What motivated you to study the effect of pain on cooperation? And why to study female only?
Response: Dr. Chenbo Wang is interested in how physical pain influences human cognition and social behaviors. In one of his previous studies, results indicated that acute pain promotes cooperative behavior in social interaction (Wang et al., 2018). On the other hand, Dr. Xianchun Li’s previous works provided an interpersonal neural mechanism of cooperative behavior (Cheng et al., 2015; Pan et al., 2017). Thus, it was a perfect collaboration between the two teams that allowed us to further elucidate the underlying neural basis of pain-induced cooperation.
Female participants only were recruited due to that in previous study, an increased effect of pain on cooperative behavior was observed only in females but not in males (Wang et al., 2018). Although gender differences in pain perception and prosocial behavior was well-documented, we realized that having also males measured would then have made it possible to check the measured results if they comply with this previous finding.

2. 33 pairs of participants is not a small number. How long did it take to collect the data?
Response: It took nearly five months to collect all the data, from the fall of 2016 to spring 2017. Before that, we spent two months to set up the experimental equipment.

3. Compared to 1 person experiment, what are the unique challenges in hyperscanning experiment?
Response: One challenge is related to the experimental design. The paradigm chosen for an experiment should be subtle to interpersonal interaction, either socially or mentally. It should be very cautious to interpret the meaning of the observed interpersonal neural synchronization. Another challenge is regarded to conducting the experiment. It should be verified that the two participants understand the task similarly and perform it on the same page.

4. Why did you not use fMRI hyperscanning?
Response: In our experiment, each pair of two participants sat face-to-face during the cooperative task, which ensured a real social interaction that they performed the task in each other’s presence. However, this real social interaction would be prevented if the two participants lay in two separate fMRI scanners.

5. What was participants’ reaction when they found this would be a “painful” experiment? Do you have any particular example?
Response: Before decided to participate, it was informed that they would receive by a half-chance a moderate pain induced by capsaicin cream. With this expectation, most participants controlled themselves well throughout the whole experiment, although they would feel a little bit annoying.

6. How long did it take to analyze the data?
Response: It took nearly six months to analyze the data.

7. Compared to single subject data analysis, what are the unique challenges in hyperscanning data analysis?
Response: Hyperscanning data analysis depends on an estimator to quantify brain-to-brain synchrony. The most frequently used method is wavelet transform coherence (WTC). Different with that of single subject data analysis, the amplitude of the complex coherence value from two participants is calculated as an index of interpersonal neural synchronization (INS). This method requires choosing a frequency band of interest in which the task-related brain-to-brain synchrony is expected to occur based on previous studies and visual inspection of the data. So how to choose the best and accurate frequency band and how to explain it are unique challenges in hyperscanning data analysis.

8. What software did you use to create figure 5? If you used in-house program, do you mind sharing it?
Response: We applied to an open-source software package called circularGraph, based on MATLAB® (The MathWorks Inc., Natick, Massachusetts) scripts. It can be downloaded for free at

9. From the initial submission to the acceptance of the paper, how long did it take? Were the reviewers friendly?
Response: It took 2 months to get the first revision and in total 4 months to receive the notice of acceptance.
Both reviewers provided us with positive comments. One reviewer remarked our experimental paradigm (pain + cognitive task + fNIRS hyperscanning) as being novel. The other reviewer commented that this work could make good contributions to the field. The reviewers raised some concerns regarding to the experimental settings and the procedure, the approach of preprocessing, and the method of FDR correction, all of which significantly helped improve the manuscript. For example, we conducted additional artifact rejection procedures (PCA method) to remove flow oscillations or other global systematic components and reanalyzed our data.

10. Can you use one sentence to summarize your finding in this study?
Response: When a dyad in painful state performing a cooperation task, their cooperation rate was improved across time; simultaneously, the interpersonal neural synchronization (INS) occurred successively at bilateral prefrontal cortex and right parietal cortex, along with increased fronto-parietal associations.

11. What is your plan for future research?
Response: There are three lines of future research. First, to replicate this finding by using EEG-based hyperscanning technique, providing extra information with ERP components and frequency band of high temporal resolution. Second, as we proposed in the current study that individuals in pain was “motivated” to cooperate; we were particularly interested in how pain would modulate neural activities in brain regions including ventral striatum and medial prefrontal cortex in the motivation and reward system, with fMRI technique. Third, it is encouraged to critically compare the effect of acute pain with chronic pain, by using the identical cooperative task.

Author: Xu Cui Categories: brain, nirs, writing Tags:

6 experiments you should do with NIRS (vs fMRI)

February 19th, 2019

[last update: 2019-02-20]

Let’s be frank. Compared to fMRI, NIRS has a number of intrinsic weaknesses. The signal to noise ratio is lower, the spatial resolution is (10x) lower, it can’t measure the deep brain, and it only covers a portion of the brain surface. As a result, fMRI, when possible, is still the preferred method to elucidate brain mechanisms. So if we do use NIRS, we’d better do experiments fMRI can’t, or at least very difficult to, do.

Below are 6 experiments NIRS can do, but fMRI can’t (or difficult to do):

  1. Study of the mechanism of BOLD signal
    1. Study of the relationship between oxygenated and deoxygenated hemoglobin concentration
      For a given voxel, fMRI only gives you a single number at a time. The number (BOLD signal) depends on many factors. On the other hand, NIRS can give you two numbers, the concentrations of both oxygenated and deoxygenated hemoglobin. So if you ever want to study the relationship between them, we should use NIRS. For an example, please check out
    2. Study of the fine temporal change of BOLD signal
      In most fMRI settings the temporal resolution of BOLD signal is low (about 2 seconds, or 0.5Hz). That means we only get a number every two seconds. If we want to know the rise and fall of the BOLD signal in much higher temporal resolution, e.g. 10Hz, then NIRS would be a good choice.
  2. Study in naturalistic settings
    If you ever participate in a fMRI study, you will feel the room far from friendly. The scanner is loud, and it looks scary. During the entire experiment, you are lonely inside the confined space. You can’t move, can’t talk (for most experiments), and feel guilty when you swallow saliva as the experimenter probably told you in advance that any motion might distort the signal. What you often see is much simple visuals (such as blocks and circles) on a computer screen. Do we live such a life in reality? On the contrary, NIRS is small, even portable, and can be used in a naturalistic environment.

    1. Sports and exercise
      As long as the optodes are attached to the head nicely to ensure proper signal collection, the participants can move freely. NIRS has been used in a number of sports or exercises studies such as running, squatting, biking, ping-pong, piano playing, and stretching etc. Be sure to check out the videos in

    2. Face to face communication
      You might see other people’s face on a screen in fMRI, but with NIRS, you can see a real face. We humans are fundamentally social, and to study social behavior in a naturalistic environment is important. NIRS allows you to study face-to-face gaming (video or board), talking, brain storming, cooperation or competition, etc. For example, in one of our studies ( participants played a video game together. my colleague Ning Liu et al has an experiment when two people play Jenga games (
    3. Study in a moving environment
      Many NIRS devices are small enough so you can carry it in a car or even a backpack. That means you can study the driver’s brain when he is actually driving! An example would be
  3. Hyperscanning
    fMRI can be used in hyperscanning studies, and in fact the first hyperscanning is done with fMRI by my former advisor Dr Montague ( However, seeing it with first hand, I know hyperscanning with fMRI is technically challenging. You need two fMRI scanners, each costs a few million dollars; and you also need to synchronize them. On the other hand, many NIRS devices are able to do hyperscanning natually. For example, when we used ETG 4000, we simply use one patch on one participant and the other on another participant. It does not add complexity on the hardware part.
    To date there are a number of hyperscanning studies with NIRS. For a list, please refer to If you are patient enough to scroll to the last page, you will find our paper!
  4. Real time (feedback), brain computer interface
    Let’s say you want your participants to move a bar in a computer game mentally (brain computer interface), or you provide a real time neural feedback to your participants to improve cognitive function, in both cases you need the brain signal in real time.  fMRI can do this too, but first you will need to get the data in real time, and second, due to poorer time resolution (2s), there will be some lag. Many NIRS devices allows you to get the measured signal out without delay, and of course the temporal resolution of NIRS is typically much higher (e.g. 10Hz). An recent example can be found at
    Some may argue that higher temporal resolution is not that useful because the BOLD signal is already slow (usually 4-6s from onset to peak). However, with finer temporal resolution, we can use algorithms (e.g. machine learning) to detect signal with much smaller delay. For example, in one of our studies the delay can be reduced by 50% (
  5. Field studies, large scale studies
    You can’t carry an fMRI scanner around for sure, but with NIRS’ portability, you can collect neural data in the field. My colleague Dr Baker took a NIRS device to the rural places in Costa Rica, and scanned the local farmers. Check out his paper.

    In addition, since you may carry NIRS devices around, you can scan a lot of participants, e.g. a few hundred or even thousand. Imagine you are to study the brain and cognitive development of children in rural areas in China in a large scale (say 10,000 participants), then NIRS will become your top choice.
  6. Study on special participants
    Due to safety reason, the following people should not do fMRI experiments (source):

    1. with shrapnel or other metal or electronic implants in their bodies (such as pacemakers, aneurysm clips, surgical devices, metallic tattoos on the head, etc.)
    2. pregnant
    3. with a history of head trauma or fainting
    4. currently using sleeping aids, painkillers (including aspirin), or other agents known to affect brain function (for instance, antihistamines, decongestants, etc.)
    5. with major medical, neurological, or psychological disorders (including depression, generalized anxiety, panic attacks, AD(H)D, strokes, tumors, heart conditions, claustrophobia, etc.)

    In addition to this list, fMRI is also not friendly to infants (but still can be done in fMRI). In contrast, NIRS does not have issues with the participants in the list. Imagine you can do an experiment on claustrophobia with NIRS, but probably not with fMRI.

So, what is the ideal experiment with NIRS? Based on the above list, if one is to use hyperscanning to study the face-to-face communication when two claustrophobia participants are running together along a mountain trail, I would say it’s pretty hard for fMRI to catch on.
Author: Xu Cui Categories: brain, nirs Tags:

New Mac OSX Mojave on old Mac

January 31st, 2019

Back in 2009, When I got my first MacBook Pro I was excited. It had the best configuration at that time (8G memory and 250G storage - SSD!). I still use it today.

As I am developing Stork’s mobile app, I need to use the latest xcode. But Apple does not allow me to upgrade to its latest OSX, apparently my computer is too old.

So I found this webpage with detailed instructions on how to install new OSX to old Mac. The guy is a genius. It worked perfectly. What you need is a USB drive (16G or bigger). Then just follow the steps. The link is:

(click the image below to enlarge)

Author: Xu Cui Categories: technology, web Tags:

Mac on Windows?

January 30th, 2019

If you need to play with Mac OSX but do not own a Mac computer, you might wish you could install Mac OSX on your Windows 10 computer as a virtual machine. Luckily I found this useful webpage with detailed instructions on how to do it. The link also provides a download link of the macOS Mojave image file.

The webpage is at

With the instruction I was able to run Mac OSX Mojave successfully on my Windows 10 via VirtualBox. In the beginning the mouse/keyboard does not work, so I followed another link: which solved the problem.

During Mac OSX setup I also encountered the apple ID login issue. In the end I did not sign in my apple ID during the setup phase - I created a local account instead.

Currently the resolution seems to be low, resulting in a rather small window for Mac OSX. I do not know how to fix it yet. update 2019-02-01 Found a way to fix. In command line window, run the following command:

cd "C:\Program Files\Oracle\Virtualbox"
VBoxManage setextradata "Mac OSX Mojave" VBoxInternal2/EfiGraphicsResolution 1920x1080

Click the image below to zoom in:

Author: Xu Cui Categories: technology, web Tags:

fNIRS中基线的做法和注意事项 (Baseline in fNIRS)

November 5th, 2018

This article is a guest post by Rui Chen. An English version can be downloaded here









现在使用近红外光来对大脑的研究,利用了近红外光在大脑组织中血红蛋白对光的特性,近红外光进入大脑组织大部分的吸收是由血红蛋白引起的,这就是为什么我们可以利用NIRS进行测量的原因。然而,光也会被其他组织(例如脂肪组织,毛发,皮肤、颅骨、脑积液等无关组织)吸收,但这是无法避免的。所以,我们假设在测量期间这种吸收是恒定的,并且接收光的任何变化都是由血红蛋白吸收的变化引起的。既然血红蛋白发生了变化,那么就会存在“起始状态”,对于CW-NIRS使用探测器接收到近红外光的变化,根据Mod Beer-Lambert定律来计算血红蛋白浓度的变化,那么,对于这个变化来说总是相对于“起始状态”或基线的。

CW-NIRS只能测量浓度的变化,因此无法提供起始浓度(通常设置为任意零点)。但是,它可以提供由任何任务或研究的状态引起的基线变化(例如收缩肌肉或增加大脑某部分的活动)。这种变化以毫摩尔每升(mmol/liter or mM)定量。有可能是正值,意味着来自任务或研究状态的激活;也有可能是负值,意味着自任务或研究状态的相对浓度降低或抑制。








This article is a guest post by Rui Chen. An English version can be downloaded here

Author: Xu Cui Categories: nirs Tags:

mergefile.m - a MatLab script to merge CSV files

October 10th, 2018

My wife asked me to write a script to merge some csv files she has. Usually this can be accomplished by a simple command in Mac or Linux:

cat *.csv >all0.csv

In Windows, it is:

copy *.csv all0.csv

But my wife needs more. She wanted the merged file have a column indicating the name of the source file. So I have to write a MatLab script, called mergefile.m. Here is the description.

mergefile merge csv files in a directory to all0.csv
mergefile merges the content of all the csv files in a directory into a
single file all0.csv. It also adds a column indicating the original
file name.

It assumes the files to be merged have the same header, and only the
header of the first file will be kept (i.e. the first row of the files
- except for the 1st file, will be ignored).

Author: Xu Cui (

Download mergefile.m

Author: Xu Cui Categories: matlab Tags:


September 12th, 2018


  1. 高亮标记了高影响因子的文献,并且文献按影响因子排列
  2. 显示中科院期刊分区信息,并用不同的颜色标识不同分区






Author: Xu Cui Categories: stork, web, writing Tags:

BOLD5000, A public fMRI dataset of 5000 images

September 11th, 2018

Official website and download
Full text paper link

Good news for brain imaging researchers. There is a new dataset available for you to play with.

BOLD5000 is a large-scale, slow event-related fMRI dataset collected on 4 subjects, each observing 5,254 images over 15 scanning sessions. The images are selected from three computer vision datasets.

  1. 1,000 images from Scene Images (with scene categories based on SUN categories)
  2. 2,000 images from the COCO dataset
  3. 1,916 images from the ImageNet dataset

BOLD5000 image data

BOLD5000 image data

Author: Xu Cui Categories: brain, web Tags: