Archive

Archive for the ‘programming’ Category

A mistake in my False discovery rate (FDR) correction script

August 8th, 2016

I have posted an FDR script at http://www.alivelearn.net/?p=1840. I noticed that there is a small bug. In rare cases, this bug will cause the most significant voxel to be classified as ‘non-significant’ while other voxels are ’significant’.

Consider the following example:

p = [0.8147 0.9058 0.0030 0.9134 0.6324 0.0029 0.2785 0.5469 0.9575 0.9649 0.1576 0.9706 0.9572 0.4854 0.8003 0.1419 0.4218 0.9157];

The previous script will classify p(3) as significant but p(6) as non-significant.

Here is the updated version of the script:

function y = fdr0(p, q)
% y = fdr0(p, q)
%
% to calculate whether a pvalue survive FDR corrected q
%
% p: an array of p values. (e.g. p values for each channel)
% q: desired FDR threshold (typically 0.05)
% y: an array of the same size with p with only two possible values. 0
% means this position (channel) does not survive the threshold, 1 mean it
% survives
%
% Ref:
% Genovese et al. (2002). Thresholding statistical maps in functional
% neuroimaging using the false discovery rate. Neuroimage, 15:722-786.
%
% Example:
%   y = fdr0(rand(10,1),0.5);
%
% Xu Cui
% 2016/3/14
%

pvalue = p;
y = 0 * p;

[sortedpvalue, sortedposition] = sort(pvalue);
v = length(sortedposition);
for ii=1:v
    if q*ii/v >= sortedpvalue(ii)
        y(sortedposition(1:ii)) = 1;
    end
end

return;
Author: Xu Cui Categories: brain, matlab, nirs, programming Tags:

Some tips to use wavelet toolbox

June 13th, 2016

Wavelet toolbox is a useful tool to study hyperscanning data. Many recent publications on NIRS hyperscanning use wavelet coherence to quantify the relationship between two interacting brains (e.g. Baker et al 2016, Nozawa et al 2016). You can see more information about wavelet coherence at http://www.alivelearn.net/?p=1169

wavelet

wavelet

Here are some tips to use the toolbox:

1. It often takes a long time to run Monte Carlo simulation. You may use ‘mcc’=0 to disable it.

figure;wtc(signal(:,jj),signal(:,jj+22),'mcc',0);

2. If you need to get the values of the result (instead of the graphic), you may specify the return value

[Rsq,period,scale,coi,sig95] = wtc(signal1,signal2,'mcc',0); %Rsq is a complex matrix

3. If you are only interested in a certain band, you can specify the MaxScale (i.e. ms) parameter. More information at http://www.alivelearn.net/?p=1518

[Rsq,period,scale,coi,sig95] = wtc(signal1,signal2,'mcc',0, 'ms', 128);

4. If you are interested in finding the “phase” information (visualized by the arrows), you may use xwt function. The returned value is a complex matrix and you can calculate the phase.

[Rsq,period,scale,coi,sig95] = xwt(signal(:,jj),signal(:,jj+22));
figure;imagesc(angle(Rsq));

5. To visualize the power of a single signal, you may use wt, which I personally feel much better than FFT.

figure;wt(signal(:,jj));

6. To change the density of the arrows, you may specify the ArrowDensity parameter

figure;wtc(signal(:,jj),signal(:,jj+22),'mcc',0,'ArrowDensity',[30 30]);

Do you have any tips? Please let me know.

Author: Xu Cui Categories: brain, matlab, nirs, programming Tags:

Who cited my paper?

May 9th, 2016

Back in 2010 we published a paper titled “Functional Near Infrared Spectroscopy (NIRS) signal improvement based on negative correlation between oxygenated and deoxygenated hemoglobin dynamics“. It is about a really simple method which surprisingly works well in reducing motion artifact (noise) in NIRS data. As of today (2016-05-09), the paper has been cited by more than 130 times.

Who cited this paper? Well, we created this map to show where the authors are:

If you clicks the red dots you will find the detailed information about the paper, such as the author name and journal.

Then who are the top researchers who cited this paper? We count the number of citation for each author, and rank them by the number of papers. Here are the top authors who cited our 2010 paper:

Author Number of Papers
Fallgatter, AJ 9
Ehlis, AC 8
Hong, KS 8
Dresler, T 8
Herrmann, MJ 7
Scheutz, M 6
Strait, M 5
Boas, DA 5
Sato, H 4
Scholkmann, F 4
Herff, C 4
Seghouane, AK 4
Ge, SS 4
Shah, A 4
Katura, T 4
Molavi, B 4
Wolf, M 4
Author: Xu Cui Categories: brain, nirs, programming Tags:

Stork is my best research assistant (2): Grant alert

April 15th, 2016

Stork

Stork

  1. Does my boss have money?
  2. I am looking for a postdoc position; does my future boss have enough funding to support me?
  3. How much money was awarded to my field (e.g. NIRS)? And who got the money? What are they going to do with the money?

Have you ever wondered these questions? In the early years as a graduate students, I rarely asked “money” questions. It does not sound what a “true” scientist should care.  I was even puzzled when I realized my boss spent more than half of his time writing grant applications - shouldn’t he spend most of his time doing experiments and write papers?

As a postdoc I found myself spend a lot of time writing grant applications; and realized my career is critically depending on the success of securing enough funding. I also see a few colleagues had to leave academia due to lack of funding.  It would be nice if there is a tool which can notify me of the funding situation in a timely manner.

Stork is such a tool.

I entered some keywords into Stork, including “pearl chiu” (my former colleague) and “nirs brain” (my research field). Below is a letter I got from Stork:

Stork notifies me of awarded grants

Stork notifies me of awarded grants

With the information Stork provides, I know who in our field got grants and what they proposed. In fact the 3rd one is my colleague Manish who is interested in using NIRS in resting-state brain network study. I also got to know Pearl got a big gran, so I sent her a congratulation note.

Compared to journal papers alert, grants alert helps me to know the trend of my field much earlier. This is because publications are usually a few years delayed from grants.

If you also want to be the first one to know new grants in your field, why don’t you give Stork a try? I’m sure you’ll be delighted!

Author: Xu Cui Categories: brain, life, programming, stork, web, writing Tags:

Projection of a NIRS channel on a brain surface

April 11th, 2016

When analyzing the data in our concurrent NIRS-fMRI study, we are particularly interested in how the NIRS signals were correlated to the fMRI signal. To answer the question we need to create an ROI (region of interest) in brain which is directly underneath the NIRS channel (which is on the skull). So a projection of the NIRS channel on the brain surface is necessary.

It might be easy if the brain were a perfect sphere, or at least doable if it is smooth. But brain surface is anything but smooth. What we did is:

  1. Create a brain surface mask. This is easy using BET (http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/BET)
  2. Loop over all voxels on the surface, calculate the distance between the NIRS channel (point A) and the voxel
  3. Find the voxel which is closest to the NIRS channel (It is point B in the figure below)

Projection of NIRS channel on brain surface

Projection of NIRS channel on brain surface

Author: Xu Cui Categories: brain, matlab, nirs, programming Tags:

Finger tapping task MatLab script

February 29th, 2016

finger tapping

finger tapping

Finger tapping is probably the most used task in brain imaging studies (fMRI and NIRS). The task is simple and elicits robust brain signal in the motor cortex. We always use it to test new devices or develop a new method.

If you want to control your NIRS device (say Hitachi ETG 4000) to start/end, please refer http://www.alivelearn.net/?p=1260

If you want to see how blood flow increases in brain motor cortex during finger tapping, check out
http://www.alivelearn.net/?p=1686

To download, please fill the form below:






Author: Xu Cui Categories: brain, matlab, nirs, programming Tags:

Stork is my best research assistant

December 18th, 2015

Stork

Stork

When I was a graduate student at Baylor College of Medicine, I found myself often in an embarrassing situation — I felt completely lost when my fellow graduate students heatedly discussed a paper in our field but I never heard of this publication at all. Later a PubMed search revealed that this paper was indeed published more than a year ago!

There was even a time when I didn’t know my own boss had a new publication. It was in part because I was in a big lab and I was not involved in that project. But still, I felt like I didn’t fulfill my duty as an up-to-date young researcher.

My problem was finally resolved several years later when we developed the Eye function in Paperbox, which is now renamed Stork. Stork is pretty easy to use. What I need to do is to simply enter all my keywords and researchers’ names and Stork takes care of everything. Stork will help me perform the search every day and send me the results. After using Stork, now I’m the first one in the lab to know that “The most renowned David Boas has a new publication” or “There’s another group using NIRS to hyperscan”. I never embarrass myself again and gain a lot of confidence.

I have more than 50 keywords. You may ask “will Stork send you 50 emails a day?” Not at all because Stork respects my inbox. It will compile all results into one email.

Stork is also smart. As a researcher, I am sometimes overwhelmed by the flood of publications and have headache in determining which ones are worth reading. Stork helps! She will mark the impact factor of each publication with the yellow color. The more yellow, the higher the impact factor. Therefore I only need to read top publications when I am busy.

If you also want to be the first one to know new publications in your field, why don’t you give Stork a try? I’m sure you’ll be delighted!

Below is one sample email Stork sent to me.

Stork Sample Email

Stork Sample Email

Below are some of the key words I’ve been using. Anyone work on NIRS and fMRI can borrow:

  1. (fumiko hoeft) AND ((university of california) OR stanford)   
  2. (jian li) AND ((phelps) OR montague OR (Peking University psychology))   
  3. baldwin Philip   
  4. brooks king-casas   
  5. cell[ta] fmri   
  6. chao liu, beijing normal university   
  7. chess stetson   
  8. David Boas   
  9. David Hong stanford   
  10. dongni yang baylor   
  11. eagleman dm [au] baylor   
  12. fmri deception   
  13. fmri resting state parent child   
  14. hanli liu, university of texas   
  15. Hosseini, S M Hadi   
  16. hyperscanning   
  17. iphone   
  18. Jack Gallant   
  19. Kendrick Kay   
  20. koniku   
  21. lumosity   
  22. montague pr [au] baylor   
  23. montague pr[au] Virginia Tech   
  24. MyConnectome   
  25. nature[ta] fmri   
  26. ning gao, tsinghua   
  27. nirs brain   
  28. nirs deception   
  29. nu zhang, washington   
  30. pearl chiu   
  31. reiss al [au] stanford   
  32. rory sayres   
  33. Russell Poldrack, stanford   
  34. saggar manish   
  35. science[ta] fmri   
  36. signe bray   
  37. smart phone brain   
  38. social nirs   
  39. stanford kesler shelli   
  40. ting ni   
  41. xianchun li, “East China Normal University”   
  42. xiaolin zhou[au] peking   
  43. xu cui AND (stanford OR baylor OR Texas)   
  44. xu q[au] harvard   
  45. yan song[au] stanford   
  46. yangming wang, peking   
  47. yufeng shen [au]   
  48. yulong li (stanford or Peking)   
  49. zen meditation   
  50. zhu chao-zhe beijing   
Author: Xu Cui Categories: brain, life, programming, stork, web, writing Tags:

文献鸟Stork是我的科研好帮手

December 17th, 2015

我在Baylor College of Medicine读研究生的时候经常遇到一种尴尬局面,就是同学们在热烈讨论本领域某篇文献的时候,我一脸茫然 — 因为我压根就不知道这篇文章。回头PubMed查查,这篇文章其实已经发表有一年了。

更绝的一个例子是,有次我老板发了文章我都不知道。当然,实验室大,有许多项目,我没有涉及那个项目。不过还是有点说不过去。

若干年后,我们开发的PaperBox的眼睛功能,现在改名为文献鸟Stork,才彻底解决了我这个问题。文献鸟用起来蛮简单的,我把能想到的所有我想跟踪的关键词和人名都输进去,然后我什么都不需要管了。文献鸟Stork会每天帮我自动搜索,把结果发送给我。现在我都是实验室第一个知道“大牛David Boas发新文章了”或者“又有人用nirs做超扫描了”等等。有面子,还长自信 :)

我有50余个关键词,文献鸟Stork会不会给我一天发50封邮件呢?不会。文献鸟Stork不会滥用你的邮箱;她会把每天的结果总结一下,最多只发一封信。

另外她还很聪明。因为有时结果多,我需要快速知道那篇文章更值得一看,文献鸟Stork就会把每篇文章对应的期刊的影响因子用颜色标记出来。颜色越黄,说明期刊越好。我在时间紧张的时候就可以只看顶尖期刊的文章了。

Stork还支持从简单到复杂的关键词。如果我想了解某个领域,比如fMRI领域,那么我就可以用一个简单的关键词fMRI即可。如果我想了解用fMRI这种方法研究情绪的文献,则我的关键词就是fMRI emotion。默认情况下,不同单词之间的关系相当于逻辑符AND,因此只要文章中同时出现了fMRI和emotion(不管顺序,也不管两个词之间有没有其它词),就会被推送。但是,如果我只想要fMRI emotion连在一起的文章,这时候加个双引号就可以了:”fMRI emotion”。

当然,更加复杂的逻辑符Stork也是支持的。比如(Nature[Journal]) AND (fMRI OR EEG) AND emotion NOT facial, 这个关键词就说明我对发表在Nature杂志上、用fMRI或者EEG(两种方法都可以)、研究情绪、但是又不包含facial这样的文献。是不是很强大?

如果对某个研究人员的文献感兴趣,可以直接用他的全名作为关键词。比如David Boas。不要加引号。当然,有的名字实在是太普通了,会有许多重名的,这时候加上他所在的单位或者城市名即可。比如David Boas, Harvard University。如果这个人可能在两个地方都工作,可以用OR,比如(Fumiko Hoeft) AND ((university of california) OR stanford)。

如果不用全名而只用简写名,就要用下面格式,姓、空格、简写。比如Reiss AL。  不要加引号,中间也不要加逗号之类的。

请大家赶快用文献鸟Stork吧,相信你会眼睛一亮的!

附录:

下面是文献鸟Stork给我发的一封信样例:

Stork Sample Email

Stork Sample Email

下面是我自己的一些关键词,做近红外或fMRI的同学们可以借鉴呢!

  1. (fumiko hoeft) AND ((university of california) OR stanford)   
  2. (jian li) AND ((phelps) OR montague OR (Peking University psychology))   
  3. baldwin Philip   
  4. brooks king-casas   
  5. cell[ta] fmri   
  6. chao liu, beijing normal university   
  7. chess stetson   
  8. David Boas   
  9. David Hong stanford   
  10. dongni yang baylor   
  11. eagleman dm [au] baylor   
  12. fmri deception   
  13. fmri resting state parent child   
  14. hanli liu, university of texas   
  15. Hosseini, S M Hadi   
  16. hyperscanning   
  17. iphone   
  18. Jack Gallant   
  19. Kendrick Kay   
  20. koniku   
  21. lumosity   
  22. montague pr [au] baylor   
  23. montague pr[au] Virginia Tech   
  24. MyConnectome   
  25. nature[ta] fmri   
  26. ning gao, tsinghua   
  27. nirs brain   
  28. nirs deception   
  29. nu zhang, washington   
  30. pearl chiu   
  31. reiss al [au] stanford   
  32. rory sayres   
  33. Russell Poldrack, stanford   
  34. saggar manish   
  35. science[ta] fmri   
  36. signe bray   
  37. smart phone brain   
  38. social nirs   
  39. stanford kesler shelli   
  40. ting ni   
  41. xianchun li, “East China Normal University”   
  42. xiaolin zhou[au] peking   
  43. xu cui AND (stanford OR baylor OR Texas)   
  44. xu q[au] harvard   
  45. yan song[au] stanford   
  46. yangming wang, peking   
  47. yufeng shen [au]   
  48. yulong li (stanford or Peking)   
  49. zen meditation   
  50. zhu chao-zhe beijing   
Author: Xu Cui Categories: brain, life, paperbox, programming, stork, web Tags:

xjView 8.13 released. Allow to change the minimum of colorbar range

November 9th, 2015

xjView 8.14 just released. Download link: http://www.alivelearn.net/xjview

xjView 8.13 is released with the following new features:

  1. Allow to change the minimum value of the color bar range. This will enable you to do
    1. Create a symmetric color bar from negative to positive. For example, from -8 to 8
    2. Use cold color to show “negative” contrast. In this case, you simply set the max as 0, and min as a positive number such as 5
  2. Allow to resize the xjView window

A short tutorial video: https://youtu.be/jixQvi0ccHc
Download link: http://www.alivelearn.net/xjview

Author: Xu Cui Categories: matlab, programming 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: