NIRS hyperscanning data analysis (1)

August 24th, 2015

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:

How much money did I make from an app?

July 6th, 2015

Undoubtedly some people are very successful in making money by developing a smartphone app. Back in 2012 I developed an app called “Handbook of Brain” which is a collected resources of brain anatomy, function and diseases. I put the app in Google’s app store (Google Play) and priced it as $1.99. I also tried to put it in Apple’s app store but they rejected because the app references wiki a lot.

Here is the app’s page in Google Play:

handbook of brain

handbook of brain

3 years passed, how much money did I make? In total there are 10 purchases and the total revenue is $20.01 according to Google. So on average I made $6.7/year, or $0.5/month.

handbook of brain financial

handbook of brain financial

Author: Xu Cui Categories: adobe air, brain, life, programming, technology Tags:

Raspberry Pi for research labs (3) battery pack

July 6th, 2015

Raspberry Pi for research labs (2)
Raspberry Pi for research labs (1)

We used to power the Raspberry Pi using a USB cable connecting to a computer; to make the device more usable and portable, now we use a battery pack.

battery pack

battery pack

It is about 20 dollars. With 4x AA batteries it will power Raspberry Pi for 3-10 hours. It’s available at Amazon.

Author: Xu Cui Categories: brain, nirs Tags:

Raspberry Pi for research labs (2) Connecting an accelerometer

June 29th, 2015

Raspberry Pi for research labs (3)
Raspberry Pi for research labs (1)

We recently used a smartphone to measure participants’ head motion during an NIRS experiment and got decent results. Smartphone is easy to use, but its size is relatively bulky on participants’ head. Is it possible to use a much smaller device?

In this summer, Joe Baker and Semir Shafi in our lab at Stanford tackled this problem with Raspberry Pi and a standard alone accelerometer. Raspberry Pi costs ~$40 and the accelerometer costs ~$20. So the total investment is ~$60. Not bad.

Joe and Semir

Joe and Semir

The accelerometer was purchased from adafruit.com. The size of the accelerometer is like a quarter, fairly small and would have no effect on a participant’s head.

accelerometer

accelerometer

Semir connected Raspberry Pi, the accelerometer, a monitor and a keyboard/mouse. He then developed a python program to read the data from the accelerometer and displayed it in real time.

Raspberry pi and accelerometer

Raspberry pi and accelerometer

How did it work? Let’s see a real demonstration by Semir. As you see in the video, while the program is running, Semir took the accelerometer back and forth. The x, y, and z data from the accelerometer is displayed on the screen in the real time.

According to Joe, this accelerometer can capture data at 100Hz, much faster than a smartphone’s accelerometer. Besides, it’s easier to integrate with other devices because Raspberry Pi is highly programmable. For example, it is possible to trigger the measuring with an external program so different data sources can be synchronized.

What is more, it’s possible to integrate Raspberry Pi/Accelerometer system with a tablet (e.g. Microsoft Surface or iPad, or even a smartphone). This will make the system much easier to use.

Author: Xu Cui Categories: brain, nirs Tags:

Movie: blood flow increases in brain motor cortex during finger tapping

June 22nd, 2015

Ever wondered what happened to your brain when you tap your finger?

finger tapping

finger tapping

See this movie:

Link: http://youtu.be/KN3MPtXlOH8

In the above movie I used topo software (by Hitachi) to visualize the blood flow changes in the brain. The data was collected by Hitachi ETG 4000 and the subject was myself. I was doing a finger tapping task. The probe position was measure by 3D digitizer. You can see that during finger tapping (right hand) the blood flow in the left motor cortex increased.

The movie itself is made using http://www.screencast-o-matic.com/

Author: Xu Cui Categories: brain, nirs Tags:

Excel tip: how to unhide the first column

June 8th, 2015

When you hide column A, you may have assumed it’s very easy to unhide it later. It’s not true. Here is how you unhide column A:

1. Type “A1″ in the cell selector box, press Enter
2. click “Format” in the cells tool bar group
3. Click “hide&Unhide” in the menu, and select unhide.

unhide first column in Excel

Author: Xu Cui Categories: life Tags:

An interesting gamble

May 11th, 2015

The other day I was walking on a street, along which there are a lot of booths where people play games to gamble. I stopped in front of one booth. The host was warm and we started to talk.

“How to play?”, I asked.

“Well, simple.” He explained, “You pay $10 to play once. Then you toss a coin until you get a ‘head’ and the game is over. If you get a ‘head’ in the first toss, then I will pay you $1; if in the 2nd toss, I will pay you $2; 3rd I will pay you $4; … and nth I will pay 2^(n-1) dollars.”

“Interesting!” I then started to calculate if this game is fair to me. I needed to calculate the expected return from this game. If it’s larger than $10, then I win; otherwise I will lose. So what is the expected return?

The probability to get ‘head’ in the first toss is 1/2, 2nd time 1/4 and so on. So the expected return is 1×1/2 + 2×1/4 + 4×1/8 + … = 1/2 + 1/2 + 1/2 + 1/2 + … and the sum is infinity!

My return is infinity! And it’s much larger than $10 dollars. For sure I will play. I might become a millionaire today. I count my money in my wallet and I have $100.

“I am in!”, I told the host.

“Good decision.”, He similed.

Then I started to play. The first game I was unlucky. I got the head in the first toss. But it’s the risk I have to take to become a millionaire. So I keep playing.

Before I knew I already spent all my $100! I only won about $50. But at this point nothing could stop me from becoming a millionaire. So I keep playing until I lost all my money.

I was very disappointed, but I was more confused. The expected return is infinity, but why did I lose money? Did I make a mistake in the calculation?

Author: Xu Cui Categories: fun, life Tags:

How to label each point in MatLab plot?

April 27th, 2015

How to label each data point in a MatLab plot, like the following figure?

label data in MatLab plot

label data in MatLab plot

MatLab code:

x = [1:10];
y = x + rand(1,10);

figure('color','w'); plot(x,y,'o');
a = [1:10]'; b = num2str(a); c = cellstr(b);
dx = 0.1; dy = 0.1;
text(x+dx, y+dy, c);

It also works on 3D plot:

label data 3d

label data 3d

Adopted from http://www.mathworks.com/matlabcentral/answers/97277-how-can-i-apply-data-labels-to-each-point-in-a-scatter-plot-in-matlab-7-0-4-r14sp2

Author: Xu Cui Categories: matlab Tags: