NIRS data analysis (time series)

1 min read

[last updated: 2009/06/15]

Also check out NIRS data analysis (GLM and visualization)

Environment requirement

  1. MatLab
  2. SPM
  3. xTopo under xjView
    xjview is located in /fs/fmrihome/fMRItools/Xjview
    Add xjview to path by addpath(genpath('/fs/fmrihome/fMRItools/Xjview'))
    xTopo is based on topo program provided by Hitachi. It is modified by me. You can download xTopo at https://www.alivelearn.net/nirs/xtopo.zip

Preparation

  1. convert NIRS data file to csv format using ETG4000 program.
  2. copy the 3D positioning data (00X.pos).
  3. If you don’t have 3D positioning data, you may use the template channel positions located in xjview/nirs_data_sample/?x??.pos

Procedure

  1. In MatLab command window, run topo
  2. Click button “Data Load” and select the data csv file. You only need to select the 1st (or left) file if you use 4×4 or 3×5 bilateral configurations. After a pause you will find the data information (such as subject name and marker timing etc)
  3. To view the overall time series, click button “Continuous Hb”. You will see the HbO, HbR and total traces for each channel. Colorful vertical lines indicates marker timing. To see more detailedly the trace of a certain channel, enter the channel number in CH box and click button “Zoom”.

  4. To see activation in a topographic view, click on any channel. You can also see the animation by click button “Play”.
  5. To see activation in 3D topo, in xTopo main window click “3D Topography”. You need to select the ???.pos file. You can rotate the brain.
  6. To average time series across trials, you need to select the markers (event) you are interested in (by clicking button “Select Mark”) and input proper parameters for Pre time, relax time and post time, then click either button “Integral Hb” or “cuixu Integral Hb” (I will explain the difference later).
  7. You can also zoom, plot topo, 3D topo like what you do for continuous time series.

Explanations

  1. The difference between “Integral Hb” (IH) and “cuixu Integral Hb” (cH):
    IH: cut and collect the time series for each occurence of the event. Then do detrending based on pre time and post time for each individual time series. Finally average across occurences. Both pre and post time parameters are important.
    cH: Do detrending/smoothing with filter pass for the entire time series first, then cut and collect the time series for each occurence, then average. Pre time, relax time and post time is used when cutting the time series. The data used is from (Pre time) seconds before event onset, to (Relax + Post time) seconds after onset.  Relax and Post time are not that important. As long as the sum is the same, the result won’t change.
  2. Obtaining the data used in plot: You will find a variable called hb_data in the workspace. It contains the data used to plot. It’s an array. The 1st one is for probe set 1, 2nd for set 2. raw means raw data and fil means filtered data. The first dimension is hb species (oxy, dxy and total), second is time, 3rd is channel.

>> hb_data(1)

ana_mode: 2
calc_flg: 2
raw: [3x251x24 double]
fil: [3x251x24 double]

第十六期 fNIRS Journal Club 视频

北京时间2021年1月23日周日下午1点, 瑞典 Karolinska Institutet的潘亚峰博士为大家讲解了他们最近发布的一篇用超扫描研究教师学生关系的文章。视频如下: Youtube: https://youtu.be/SrqU60b6lyk Youku: https://v.youku.com/v_show/id_XNTA4MDc2NjIwNA==.html
Xu Cui
5 sec read

第十六期 fNIRS Journal Club 通知 2021/01/23,1pm

瑞典 Karolinska Institutet的潘亚峰博士将为大家讲解他们最近发布的一篇用超扫描研究教师学生关系的文章。热烈欢迎大家参与讨论。潘博士为了这次报告,需要一大早就起床。因此本次报告的时间比过去要稍晚一点。 时间: 北京时间2021年1月23日周六下午1点地点: https://zoom.com房间号: 815 4986 9861密码: 796475 Pan, Guyon, Borragán, Hu, Peigneux (2020) Interpersonal brain synchronization with instructor compensates for learner’s...
Xu Cui
53 sec read

第十五期 fNIRS Journal Club 视频

北京时间2020年12月27日周日上午10点, 香港中文大学二年级博士生胡玥讲了一篇用神经网络去除运动伪迹的文章。视频如下: Youtube: https://youtu.be/mZkGzm1R7ak Youku: https://v.youku.com/v_show/id_XNTAyODUyMTEyOA==.html
Xu Cui
4 sec read

13 Replies to “NIRS data analysis (time series)”

  1. I’m struggling to get your code running an Matlab 2010a. SPM is installed and in the path, as is xjview.m. yet I see this error:
    ??? Undefined function or method ‘passfilter’ for input arguments of type ‘double’.

    Error in ==> cuixu_calc_int at 175
    dsignal = passfilter(continuous_data(p_cnt).raw(1,:,hb_ch), [0.3 0.01],
    10);

    ??? Error while evaluating uicontrol Callback

    where does passfilter come from? Do I need any other packages installed? Any hints?

  2. passfilter function is not included in the public version of xjview. Here is the function:

    function y = passfilter(x, threshold, samplingFrequency)
    % function y = passfilter(x, threshold, samplingFrequency)
    % low or/and high pass filter
    %
    % x: orginal signal
    % threshold: the frequency thresholds. It should be an array of length 2.
    % The first component corresponds to the low pass filter threshold and the
    % 2nd one corresponds to the high pass threshold. If you don’t want to
    % set the threshold, put nan.
    % samplingFrequency: the sampling frequency of the original signal x.
    % Default 10 Hz
    %
    % y: the result signal
    %
    % Note: this script needs signal toolbox
    %
    % Example:
    % y=humps([0:.01:1])+randn(1,101)*10;
    % figure;plot(y)
    % hold on; plot(passfilter(y, [0.5, nan], 10), ‘r’)
    %
    % Xu Cui
    % 2007-10-02

    if nargin < 2 error('At least two arguments are required.'); end if nargin < 3 samplingFrequency = 10; end if ~isfinite(threshold(1)) && ~isfinite(threshold(2)) y = x; return end if isfinite(threshold(1)) && isfinite(threshold(2)) [b,a]=ellip(4,0.1,40,[threshold(2) threshold(1)]*2/samplingFrequency); elseif isfinite(threshold(1)) [b,a]=ellip(4,0.1,40,[threshold(1)]*2/samplingFrequency); elseif isfinite(threshold(2)) [b,a]=ellip(4,0.1,40,[threshold(2)]*2/samplingFrequency, 'high'); end y = filtfilt(b,a,x); return

  3. thanks for the passfilter function. it seems though there are some more functions missing (now choking on ellip and Maximize).
    Also there is a little glitch when running on a Unix system (case-sensitive filesystem) – in input_para.m you try to fopen a file ‘ALL_E_coef.txt’ but after unziping xtopo.zip it is called All_E_coef.txt (lower case Ls).
    Do you plan on releasing an xjview version that has the needed functions?
    Thanks again for your help!

  4. I am trying to load my data sampled from fNIRS machine which has .csv

    However each time I try it, I get this error :

    Error in load_ad_etg7000 (line 25)
    load_flg = 0;

    Output argument “ad_data” (and maybe others) not assigned during call to
    “C:\Users\AhmetCakir\Desktop\MRes\SPM8\cuixuTSP\load_ad_etg7000.m>load_ad_etg7000”.

    Error in load_ad (line 81)
    [info, ad_data, mark,para,para_p] =
    load_ad_etg7000(fname,MainFigure,para,para_p,para_h,dis_no);

    Error in OnDataLoad (line 64)
    [info,ad_data,mark,para,para_p] =
    load_ad(strcat(pname,fname),MainFigure,para,para_p,para_h,dis_no);

    Error while evaluating uicontrol Callback

    I cannot understand why I have this error.

    I have cross checked it with the sample data that you have provided and could not see any differences. Could you please let me know why I am getting this kind of error ?

    Thanks

  5. I created the csv file from the Hitachi’s own program. I remembered that once I tried to change the csv file and then it failed. So I guess you have to create the csv in Hitachi’s way.

  6. I have problems with fileOut, it doesn’t save measurements data into the file. Only the information about subjects.
    any ideas?
    thanks

  7. Hi Dr. Xu Cui,

    I wonder if you have a paper reference for your “cuixu Integral Hb”?

    Thanks,
    Guoqing

  8. Excuse me,
    May I ask how do you create the .pos file in your sampling data?
    Which instrument(Ex: ISOTRAK II) and software(Ex: Brainstorm) did you use to create the .pos file?
    Thanks for replying

Leave a Reply

Your email address will not be published. Required fields are marked *

Loading