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:

NIRS can’t measure deep brain, … maybe it can!

February 27th, 2015

Is NIRS able to measure signal from deep brain structure, such as amygdala? The short answer is no. NIRS is only able to measure the surface of the brain. This is a serious limitation of NIRS compared to fMRI which is able to measure the entire brain.

However, brain is a highly connected network. Deep brain is not isolated from the surface. So maybe we can infer the deep brain activity based on the surface. And this is exactly what we have done.

In a recent publication titled “Inferring deep-brain activity from cortical activity using functional near-infrared spectroscopy”, we used concurrent fMRI-NIRS technology to measure both deep and surface brain activity and explored the possibility to infer deep brain based on surface brain activity measure by NIRS. The result is very encouraging - we are able to infer deep brain from surface activity (correlation ~0.7).

This paper is published in Biomedical Optics Express with Dr Ning Liu, a NIRS expert, as the first author. You can find the paper at http://www.opticsinfobase.org/boe/fulltext.cfm?uri=boe-6-3-1074&id=312512

Abstract:

Functional near-infrared spectroscopy (fNIRS) is an increasingly popular technology for studying brain function because it is non-invasive, non-irradiating and relatively inexpensive. Further, fNIRS potentially allows measurement of hemodynamic activity with high temporal resolution (milliseconds) and in naturalistic settings. However, in comparison with other imaging modalities, namely fMRI, fNIRS has a significant drawback: limited sensitivity to hemodynamic changes in deep-brain regions. To overcome this limitation, we developed a computational method to infer deep-brain activity using fNIRS measurements of cortical activity. Using simultaneous fNIRS and fMRI, we measured brain activity in 17 participants as they completed three cognitive tasks. A support vector regression (SVR) learning algorithm was used to predict activity in twelve deep-brain regions using information from surface fNIRS measurements. We compared these predictions against actual fMRI-measured activity using Pearson’s correlation to quantify prediction performance. To provide a benchmark for comparison, we also used fMRI measurements of cortical activity to infer deep-brain activity. When using fMRI-measured activity from the entire cortex, we were able to predict deep-brain activity in the fusiform cortex with an average correlation coefficient of 0.80 and in all deep-brain regions with an average correlation coefficient of 0.67. The top 15% of predictions using fNIRS signal achieved an accuracy of 0.7. To our knowledge, this study is the first to investigate the feasibility of using cortical activity to infer deep-brain activity. This new method has the potential to extend fNIRS applications in cognitive and clinical neuroscience research.

Author: Xu Cui Categories: brain, nirs Tags:

How to download emails in Gmail?

February 20th, 2015
  1. Log in to your gmail
  2. On the top-right corner, you will find your own icon, click it. A pop up window will show
  3. Click “Account”
  4. You will see a page with a lot of options. Scroll down and find Account tools, then click “Download data”
  5. Select Mail and download your emails in mbox format. The file can be opened with any text editor (e.g. Notepad ++).
Author: Xu Cui Categories: life Tags:

Using a smartphone to measure head motion in a NIRS experiment

February 14th, 2015

Sensitivity of fNIRS measurement to head motion: An applied use of smartphones in the lab

Sensitivity of fNIRS measurement to head motion: An applied use of smartphones in the lab

Is it possible to use a smartphone to measure head motion in a NIRS study? Is it reliable? After all, smartphones are so popular right now and everybody has it. It would make head motion measurement much more convenient than a traditional stand-alone accelerometer if the answers to the above questions are yes.

The good news is, the answers are YES!

In our recently published paper, we demonstrated that a NIRS researcher can easily attach a smartphone to a participant’s head, measure the motion data (3-D), export and analyze the data, and integrate with NIRS measurement.

The title of the paper is “Sensitivity of fNIRS measurement to head motion: An applied use of smartphones in the lab“. The full-text can be found here.

Abstract

Background

Powerful computing capabilities in small, easy to use hand-held devices have made smart technologies such as smartphones and tablets ubiquitous in today’s society. The capabilities of these devices provide scientists with many tools that can be used to improve the scientific method.

Method

Here, we demonstrate how smartphones may be used to quantify the sensitivity of functional near-infrared spectroscopy (fNIRS) signal to head motion. By attaching a smartphone to participants’ heads during the fNIRS scan, we were able to capture data describing the degree of head motion.

Results

Our results demonstrate that data recorded from an off-the-shelf smartphone accelerometer may be used to identify correlations between head-movement and fNIRS signal change. Furthermore, our results identify correlations between the magnitudes of head-movement and signal artifact, as well as a relationship between the direction of head movement and the location of the resulting signal noise.

Conclusions

These data provide a valuable proof-of-concept for the use of off-the-shelf smart technologies in neuroimaging applications.

Keywords

  • Near-infrared spectroscopy;
  • fNIRS;
  • smartphone;
  • technology;
  • neuroimaging;
  • accelerometer
Author: Xu Cui Categories: brain, nirs Tags:

How to split a PDF file for free?

February 13th, 2015

I have a PDF file which contains many pages. For some reason I need to send only page 3 and 5 to a friend. How can I create a PDF which contains only page 3 and 5?

It turns out using Google Chrome is very easy (and free)! I simply open the big PDF in Chrome (drag-n-drop the file to Chrome) and then print the file to a new PDF with only page 3 and 5.

Below is a video tutorial.

Author: Xu Cui Categories: life Tags:

How long is fMRI or NIRS signal delayed?

December 8th, 2014

We know the hemodynamic signal measured by fMRI (or NIRS) is delayed respective to the onset of stimuli. But how long is the delay? Many people think it takes about 2s for the signal to arise. Actually the delay varies from region to region. As shown in this figure, signal in motor cortex (including SMA) arises very quickly (no delay); but the signal in visual cortex arises slow (2s delay).

fmri or nirs signal onset delay

The figure above is adapted from Cui et al, PLoS Biology (2009) Ready…Go: Amplitude of the fMRI Signal Encodes Expectation of Cue Arrival Time

Author: Xu Cui Categories: fmri, nirs Tags:

Driver Detective

August 25th, 2014

I had been using a Lenovo Edge laptop, and one day it died. The operation system (windows 7) was corrupted. After installing a new Windows 7, I found the computer is impossible to use - it does not find the wireless adapter and the screen resolution is low. I did a lot of google but Lenovo apparently has a lot of special hardware and it’s hard to find the correct drivers. I almost gave up.

I then tried an external USB wireless adapter from another computer and it works. So I was going to purchase an external USB wireless adapter. Then I did another search to fix the screen resolution and at this time I found Driver Detective, a program which claimed to be able to fix all driver issues. I hesitated for a few minutes when I found out the program is not free (about 30 dollars). But eventually I convinced myself to pay. To my joy, it fixed all problems, including the wireless adapter driver. So I do not need to buy an USB wireless driver anymore.

Author: Xu Cui Categories: life Tags:

Apply a Formula to an Entire Column in Excel

June 9th, 2014

Two Ways to Apply a Formula to an Entire Column in Excel

This small trick can be handy if you have a lot of rows. The most commonly used method - dragging down - will be too time consuming in this case.

Author: Xu Cui Categories: life Tags:

Sample NIRS finger tapping data

May 24th, 2014

Description:

The subject is myself. I did a simple finger tapping task. I continuously tapped my right hand on the table for 10s, then rest for 20s. Then repeat this tapping-rest cycle for 20 times.

NIRS signals were recorded by Hitachi ETG-4000.

The data is very good: you can see the changes of HbO and HbR in the individual trials in motor cortex (channel 13 this case). See figure below:

(click to zoom)

The data is available for download (fill the form below). Here is the description:

1. This data file can be loaded in MatLab (using the load command).

2. After loading the data, there are 3 variables, hbo,hbr,marker. hbo is oxy-Hb data, hbr is deoxy-Hb data, and marker indicates the timing of the finger tapping event.

3. hbo and hbr are 7562×24 matrices. Each column is for a channel (and we totally have 24 channels), each row is for one time point. The sampling frequency is 10Hz.

4. mark is a 40×2 matrix. The first column can be ignored. The 2nd column is the timing of the onset and offset of finger tapping alternatingly.

To download the data, fill the following form and click Submit button. You will receive a download link shortly.






Author: Xu Cui Categories: nirs Tags:

Format a date the way you want in Excel

April 29th, 2014

In one column of your excel your date is formatted as “03/06/2001″. How do you format it to “2001 Mar 6″?

See:

Reference: http://office.microsoft.com/en-us/excel-help/format-a-date-the-way-you-want-HA102809474.aspx

Author: Xu Cui Categories: Uncategorized Tags: