Temporal resolution of CW fNIRS devices

August 10th, 2018

This is a guest post by Ning Liu from Stanford University.

Temporal resolution provides information on the distance of time between the acquisitions of two images (data) of the same area. It is the reciprocal of sampling rate (or acquisition rate) of an fNIRS device. For some devices, sampling rate is a fixed number; for some other ones, sampling rate may depend on number of sources or detectors to use. Why is that? It is because they have different instrumental design. For those with unfixed sampling rate, multiple sources time-share an optical detector by means of a multiplexing circuit that turns the sources on and off in sequence, so that only one source within the detector range is on at any given time. The NIRx system, for instance, are using this type of design. For those with fixed sampling rate, they usually use low frequency modulated light source to provide the excitation light, thus one detector can ‘see’ only one source.

For instance, Hitachi ETG4000 system has sampling rate of 10Hz (from http://www.hitachi.com/businesses/healthcare/products-support/opt/etg4000/contents2.html), thus its temporal resolution is 100ms. Some other device, such as NIRScout, has sampling rate from 2.5 – 62.5 Hz (from https://nirx.net/nirscout/), thus its temporal resolution is 16 - 400ms. Why the sampling rate is changing from 2.5 – 62.5 Hz? That’s because users can choose different number of sources and detectors in their configuration. The more number of sources and detectors to use, the smaller the sampling rate. The following table is from a review article (Scholkmann, et al., 2014) on NeuroImaging volume 85 (2104), a special issue of functional near-infrared spectroscopy. It summarizes the specifications of some popular commercially available fNIRS devices, mainly focused on continuous wave devices.

Time resolution of NIRS devices

Time resolution of NIRS devices (click to enlarge, F. Scholkmann et al. / NeuroImage 85 (2014) 6–27)


Author: Xu Cui Categories: nirs Tags:

Deep learning training speed with 1080 Ti and M1200

June 19th, 2018

I compared the speed of Nvidia’s 1080 Ti on a desktop (Intel i5-3470 CPU, 3.2G Hz, 32G memory) and NVIDIA Quadro M1200 w/4GB GDDR5, 640 CUDA cores on a laptop (CPU: Intel Core i7-7920HQ (Quad Core 3.10GHz, 4.10GHz Turbo, 8MB 45W, Memory: 64G).

The code I used is Keras’ own example (mnist_cnn.py) to classiy MNIST dataset:

MNIST dataset

MNIST dataset

'''Trains a simple convnet on the MNIST dataset.

Gets to 99.25% test accuracy after 12 epochs
(there is still a lot of margin for parameter tuning).
16 seconds per epoch on a GRID K520 GPU.

from __future__ import print_function
import keras
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Dense, Dropout, Flatten
from keras.layers import Conv2D, MaxPooling2D
from keras import backend as K

batch_size = 128
num_classes = 10
epochs = 12

# input image dimensions
img_rows, img_cols = 28, 28

# the data, shuffled and split between train and test sets
(x_train, y_train), (x_test, y_test) = mnist.load_data()

if K.image_data_format() == 'channels_first':
    x_train = x_train.reshape(x_train.shape[0], 1, img_rows, img_cols)
    x_test = x_test.reshape(x_test.shape[0], 1, img_rows, img_cols)
    input_shape = (1, img_rows, img_cols)
    x_train = x_train.reshape(x_train.shape[0], img_rows, img_cols, 1)
    x_test = x_test.reshape(x_test.shape[0], img_rows, img_cols, 1)
    input_shape = (img_rows, img_cols, 1)

x_train = x_train.astype('float32')
x_test = x_test.astype('float32')
x_train /= 255
x_test /= 255
print('x_train shape:', x_train.shape)
print(x_train.shape[0], 'train samples')
print(x_test.shape[0], 'test samples')

# convert class vectors to binary class matrices
y_train = keras.utils.to_categorical(y_train, num_classes)
y_test = keras.utils.to_categorical(y_test, num_classes)

model = Sequential()
model.add(Conv2D(32, kernel_size=(3, 3),
model.add(Conv2D(64, (3, 3), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dense(128, activation='relu'))
model.add(Dense(num_classes, activation='softmax'))


model.fit(x_train, y_train, batch_size=batch_size, epochs=epochs,
          verbose=1, validation_data=(x_test, y_test))
score = model.evaluate(x_test, y_test, verbose=0)
print('Test loss:', score[0])
print('Test accuracy:', score[1])

The result is that 1080 Ti is 3 times faster than M1200:

M1200 (1 epoch) 1080 Ti (1 epoch)
18s 6s
Author: Xu Cui Categories: deep learning, programming Tags:

You can start to use Stork in 10s!

May 21st, 2018

Stork is a simple app for researchers to follow up scientific publications. It only takes me 10s to start.


Author: Xu Cui Categories: stork, writing Tags:

Find cheapest flight

April 26th, 2018

I booked a direct flight (non-stop) from San Francisco to Beijing for my father last October. The cost is ~$300. It’s fairly cheap.

The tool I used was https://matrix.itasoftware.com/. If your departure date can be flexible, this website will give you the price on a range of days. Then I would pick up the cheapest date, and view details such as airline names/time.

You can’t book tickets on this website directly; but with the names of airlines you can go to the website of airlines and book there.

ITA software

ITA software

Author: Xu Cui Categories: life Tags:

Recommend 3blue1brown

April 24th, 2018

When I was in high school and saw the following equation, my mind was blown!

Why is Pi here? Isn’t it supposed to show up only in circle related problem? But the left-hand has nothing to do with circle. And it’s Pi squared!

Even today I still do not have an intuitive understanding why the above equation is true, until I watched a visual explanation from 3blue1brown. This video provide an elegant and visual proof of the equation. Go ahead and watch it:

The link is:

Author: Xu Cui Categories: life, math Tags:

To beginner: task-based fNIRS study design (2)

March 19th, 2018

This is a guest post by Ning Liu from Stanford University.

A basic block design includes two conditions: task condition and control condition. The two conditions present alternatively, thus is also called ‘AB block’ (Fig. 1A). This design assumes that the two conditions can be cognitively added, implying no interactions among the cognitive components of a task. A subtraction comparison strategy then can be used in the data analysis to assess the brain regions involved in the performance of the task. Although, in most cases, this assumption is invalid, many people still use it because it usually produces robust and reproducible results. A block design task often includes more than five epochs per condition, and each epoch lasts 10 to 30 seconds. As an example, we used the following block-designed emotional face task in one of our studies: R-F-S-F-S-F-S-F-S-F-S-F-S-R, where R, F and S represent rest, fearful face and scrambled face epochs respectively. Each task epoch (both F and S) lasts 20 s, and each rest epoch lasts 30 s. (Liu, et al. 2015)
Event-related design (Fig.1B) allows the order of conditions present randomly and the time intervals between stimuli vary. This design is more naturalistic and allows for detecting transient variations in hemodynamic responses (HRF). However, event-related design usually needs more number of stimuli in order to enhance the statistical power, and the experiments are often longer than blocked designs.
Mixed design (Fig. 1C) combines block and event-related designs. It alternates two conditions (task and control) as in a block design. Within a block, the interstimulus interval (ISI) varies as in an event-related design. It allows for extracting brain regions either exhibiting transient neural activity (item-related information processing) or sustained neural activity (task-related information processing). However, it involves more assumptions than other designs, and the estimation of the HRF is poorer than event-related design.

experiment design

Fig. 1. Experiment design (A)Block design (B)Event design (C)Mixed design (ref Edson et al. 2006)

Amaro E Jr, Barker GJ, “Study design in fMRI: basic principle”, Brain and Cognition, 2006, 60(3):220-32.
Liu N, Cui X, Bryant DM., Glover GH, Reiss AL, “Inferring deep-brain activity from cortical activity using functional near-infrared spectroscopy”, Biomedical Optics Express, 2015, 6(3): 1074-89. doi: 10.1364/BOE.6.001074.

Author: Xu Cui Categories: brain, nirs Tags:


March 19th, 2018


传统的组块设计(block design)通常包括两种组块: 任务组块和控制组块,又被称为“AB block”设计(如图1A)。这种设计基于一个假设: 两种组块条件下的意识态是线性叠加的,它们之间没有相互作用。因此可以用两种条件下的意识态相减。 尽管这种假设往往是不成立的,但是这种实验设计通常可以得到比较强的信号,易于寻找被任务激活的脑区,并得到比较稳健的实验结果,所以这种设计还是一直得到广泛使用。常用的组块设计,每种条件包括六个以上的实验组块(epoch), 一个实验组块持续10到30秒时间。例如,我们用过下面这种组块设计的面部表情实验: R-F-S-F-S-F-S-F-S-F-S-F-S-R。其中, R 代表安静状态组块,F代表恐惧的面部表情组块,S代表模糊化的面部表情组块。每个刺激组块(both F and S)持续20秒,安静组块(R) 持续30秒(Liu, et al. 2015)。

事件设计(event-related design, 如图1B)能够呈现单个的刺激而不是以组块的形式呈现,单个的刺激之间有长短变化的时间间隔,设计更加灵活,可以提供比组块设计更多的信息,例如血流动力学响应函数(HRF)的信息,因此也经常被使用。但为了得到较稳定的结果需要刺激重复次数较多,因此事件设计总的实验时间通常较长。

另一种比较常见的设计是混合设计(mixed design,如图1C),就是把组块设计和事件设计结合起来,既有任务组块和控制组块的区分,单个刺激之间的时间间隔又是长短变化的。这种设计的优点是既易于得到被任务激活的脑区,又能得到HRF的信息。缺点是需要基于更多的假设,对HRF的估算也较事件设计差一些。

experiment design

Fig. 1. 任务设计示意图。(A) 组块设计; (B)事件设计; (C)混合设计。(此图转自Edson et al. 2006)

Author: Xu Cui Categories: brain, nirs Tags:

To beginner: task-based fNIRS study design (1)

March 10th, 2018

This is a guest post by Ning Liu from Stanford University.

For someone who has no imaging background and just began to use fNIRS, s/he might be surprised to find out that the imaging study design is so different with study designs in other fields. For instance, task-based imaging studies usually involve bunch of repeated stimuli. This is quite different with what we usually do in a naturalistic environment in our daily life. Why not use just one stimulus? This is due to the difficulty in detecting signal changes against a much stronger background physiological noise. Thus, in order to measure brain actives, one needs to carefully design the experiment and use some clever method to analysis the data.

For task-based study, there are two types of basic design. One is called block-design and the other event-design. It worth noticing that they have something in common — the same stimulus needs to be repeated many times, and the detected signal changes are statistically tested for significance.

Another aspect that beginners usually ignore is the design of control condition. A typical task design usually contains epochs or events of interest along with control epochs or events, such that a cognitive subtraction (for instance) can be performed and resulting in robust and reproducible results.

Author: Xu Cui Categories: brain, nirs Tags:


March 10th, 2018


对于一个近红外初学者,特别是没有任何脑成像背景的初学者,他们往往没有想到脑成像的实验设计和别的学科的实验设计,诸如行为科学或者生物实验等有很大不同。通过一些文献阅读或者相关培训,初学者可能注意到脑成像的任务态实验设计往往有很多重复的环节。那么,为什么脑成像的实验需要这样的设计?究其根本原因,其实是因为现有的无侵入式脑成像技术,无论是核磁共振脑功能成像(fMRI) 还是近红外脑功能成像(fNIRS), 其直接测量到的信号变化与噪音相比都太小(~1%量级)。换言之,巨大的生理噪音掩盖了信号的变化。因此,为了能测量到与大脑活动相关的信号,具体到近红外成像中就是测量到氧合血红蛋白和脱氧血红蛋白的浓度变化,就需要巧妙的设计实验和分析数据。

对于任务态实验,有两种基本的实验设计:一种是采用组块设计(block design),另一种是采用事件设计(event design)。然而,无论哪种,它们的共同点是:实验中多次重复同一个任务/操作,数据处理时通过建立模型,用统计的办法找出具有统计意义的相关活跃脑区。

任务态的实验设计中常常被初学者忽略的另一个重要环节就是对照条件(control condition)的设计。刺激任务除了设计能激活相关脑区的任务以外,一般还应该设计一个好的对照条件,进而可以通过两种条件下脑信号的对比,找出真正与任务相关的脑区。

Author: Xu Cui Categories: brain, nirs Tags:

近红外成像入门培训 —— 小型私人辅导

February 23rd, 2018

代朋友发布这个培训信息。有兴趣直接联系 fnirs_studio@outlook.com

近红外成像入门培训 —— 小型私人辅导
专门针对初学者,不需要任何近红外成像经验和背景。 近红外专家用最浅显易懂
包括医生(精神科、儿科、脑外科 等)、大学本科生、研究生、以及高中生等,得
(1) 近红外脑功能成像技术原理及理论基础
(2) 数据采集基本流程
(3) 单人扫描实验设计及数据处理
(4) 双人同步扫描(超扫描)实验设计及数据处理
培训老师: 刘宁,生物医学工程博士(近红外成像方向),现任斯坦福大学助理
人群 脑功能成像。

Author: Xu Cui Categories: nirs Tags: