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:

SVM regression on time series, is there a lag?

March 23rd, 2015

It would be nice if we can predict the future. For example, give the following time series, can we predict the next point?

Let’s use SVM regression, which is said to be powerful. We use the immediate past data point as the predictor. We train our model with the first 70% of data. Blue and Black are actual data, and Red and Pink are predicted data.

The prediction in general matches the trend. But if you look closely, you see that the predicted data is always lagging the actual data by one time step. See a zoom in below.

Why does this lag come from?

Let’s plot the predictor and the predicted (i.e. the current data point vs the next data point):

It looks normal to me.

It took me a few hours to think about this. Well, the reason turns out to be simple. It’s because our SVM model is too simple (only taking the last data point as predictor): if a data has a increasing trend, then the SVM model, which only consider the immediate history, will give a high predicted value if the current data value is high, a low value if the current data value is low. As a consequence, the predicted value is actually more similar to the current value - and that gives a lag if compared to the actual data.

To reduce the lag, you can build a more powerful SVM model - say use the past 2 data points as the predictor. It will make a more reliable prediction - if the data is not random. See below comparison: you can easily see the lag is much smaller.

Source code can be downloaded hereĀ test_svr. Part of the source code is adapted fromĀ http://stackoverflow.com/questions/18300270/lag-in-time-series-regression-using-libsvm

Author: Xu Cui Categories: brain, matlab Tags: