Analyze NIRS data with NIRS-SPM

4 min read

being updated for v01_r14 …

NIRS-SPM is a SPM5 and MATLAB-based software package for statistical analysis of near-infrared spectroscopy (NIRS) signals, developed at the Bio Imaging Signal Processing (BISP) lab. at KAIST in Korea.

prepare files needed by NIRS-SPM

  1. NIRS data (in csv format or nii format. For Hitachi ETG4000, you need “File out” the measurement data, not the Hb data, into csv format)
  2. (optional) Structural image (e.g. xu.img). I use SPM2 to do normalization and segmentation (below), but you can choose whatever tool you prefer.
    1. normalize the image (use template T1.mnc) and get two files, wxu.img and xu_sn.img. This step takes 2 min.
    2. segment the image (not the normalized image) into gray and white volumes and get 3 files (xu_seg1.img, xu_seg2.img and xu_seg3.img). They are gray, white, and CSF volumes. The first two images will be used in NIRS-SPM. This step takes ~6 min.
  3. (optional) Coordinate file (a plain text file, e.g. RealCoordinate.txt), from probe positioning system
    This file contains 3 columns, with each row a 3-D coordinate of a point measured with 3D digitizer. The total number of rows is the sum of landmarker points (nasion, inion, etc)  plus the number of optodes. You will have to specify the two numbers in NIRS-SPM.

    • If you don’t have 3d digitizer at all but you know the positions of each optodes in your structural image (e.g. you used vitamin E marker), you can simply find the positions using SPM’s display functionality and put into the file.
    • If you don’t have MRI image at all, you can use a standard brain image. You need to check how well the registration is visually.
    • If you don’t have MRI image, and you didn’t measure optode positions with 3D digitizer, but you take a picture of the subject, you can use a standard brain, and “guess” the optode coordinate with the picture.
    • If you don’t have MRI image, or 3D digitizer measurement, or a picture, then you can use a standard brain, and guess, and cross your finger.
  4. The event onset timing and duration (in seconds). For example, [12 34 55 67] etc.

NIRS-SPM system requirement:

  1. MatLab (with graphic display)
  2. SPM5 (note: not SPM2)

steps:

  1. (optional) Login scuttlebutt (even you are on scuttlebutt computer)
    ssh fmri@scuttlebutt -Y
  2. Start matlab with graphic support and spm5 in path
    e.g.
    ml7spm5 -jvm &
  3. add NIRS-SPM folder into MatLab path
    addpath('/net/cibsrdata/Volumes/SPNLData05/quarry/cuixu/NIRS/NIRS_SPM_v01_r14');
    (You need to replace NIRS-SPM path to your own path)
  4. Enter sample_data directory (optional)
    cd /net/cibsrdata/Volumes/SPNLData05/quarry/cuixu/NIRS/sample_data
  5. run NIRS-SPM and the main window pops up
    nirs_spm
  6. Click “Convert” button, data conversion window pops up
  7. Select Hitachi ETG-4000
    Select the csv file, conversion begins automatically. It will take ~20s
    Click “Save .mat file” button, and save the file as “converted_NIRS.mat”
    Close data conversion window.
  8. (optional) Display NIRS data.
    Click “Display NIRS Time Series” button in the main window. NIRS_TimeSeries_Viewer window pops up.
    Click “Specify NIRS(.mat) file” button and select “converted_NIRS.mat”. Time series of channel 1 is displayed.
    Click “Specify model parameter” button and input the vector of onsets and duration
    Close NIRS_TimeSeries_Viewer window
  9. Select “With MRI” and Click “Spatial registration” button, two windows pops up.
    Select “T1_MRimage/uniform.img” as T1 image
    Select “wuniform.img” as normalized T1 image
    Then a SPM big window pops up and the subject’s T1 is shown.
    Find point (-70 34 36) and click + (you will see the point is added into “Indicator Locations” window)
    Repeat for other points (-82 -31 36), (-1 85 -15 nasion), (-8 -86 -58 inion)
    In “Indicator Locations” window, enter 4 and 16 for “Indicator #” and “Optode #”
    Click “Select Real Coordinate File” button and select file “RealCoordinate_txt_format.txt”. The locations will be displayed.
    Click “Get Optode Pos. in MRI” button and select “T1_MRimage/uniform_sn.mat” file. Also select the gray and white file (“T1_MRimage/c1uniform.img” and “T1_MRimage/c2uniform.img”)
    After ~30s the coordinates in MRI is calculated.
    Click “View Channel Pos” button you will see the positions of channels
    Click Save button and save the position as “channel_position.mat”
  10. Click “Specify 1st Level” button and “NIRS_Specification” window pops up
    Select nirs data file “converted_NIRS.mat”
    Create directory “spm” and Select it
    Select “Oxy-Hb”.
    Click “Specification” and specify the following parameters
    “hrf (with time and dispersion derivatives”
    number of conditions: 1
    name for condition 1: right finger tapping
    vector of onsets: [42:51:501]*9.75
    duration: 21*9.75
    high-pass filter: 60
    low-pass filter: Gaussian
    Gaussian FWHM: 4
    Correct for serial correlations? none
    Then a big SPM window pops up with design matrix
    Close the windows except for the main window
  11. Click “Estimate” button in the main window, NIRS_Estimation window pops up
    Select “Individual Analysis”
    Select “SPM_indiv_HbO.mat” as SPM.mat
    Click “Estimation” button. It will take 7 min. File “V_indiv_HbO.mat” is saved.
  12. Click “Result NIRS” and NIRS_Results_Viewer window pops up
    Select SPM_indiv_HbO.mat
    Select channel_positoin.mat
    Click “Contrast”, SPM contrast manager window pops up
    Click “Define new contrast”. name: finger, type: t, contrast 1 0 0 0, click OK, click “Done”
    After ~20s T map is shown. Click “View the thresholded T-statistic” and try different p-values.
  13. Click “Result fMRI” and select SPM.mat in fMRI_result folder
    (can’t get this to work now)

files required:

  1. NIRS_data_finger_tapping.nir
  2. RealCoordinates_txt_format.txt
  3. uniform.img : subject’s structural image
  4. wuniform.img : subject’s structural image after normalization
  5. uniform_sn.mat : the mat file produced by SPM during structural image normalization
  6. c1uniform.img : gray volume of segmentation
  7. c2uniform.img : white volume of segmentation
  8. SPM.mat (for fMRI and NIRS comparison)
  9. spmT_0001.img (for fMRI and NIRS comparison)

inside the files:

  1. .nir file is simply a text file. Row is time and column is channel.
  2. .csv file is also text file exported from Hitachi ETG4000
  3. RealCoordinates.txt is a text file with each row a point coordinate.
  4. converted_NIRS, or nirs data after conversion is a mat file with a single variable nirs_data. nirs_data is a struct. An example is:
              oxyData: [5384x24 double]
              dxyData: [5384x24 double]
                   fs: 9.7500
           timeLength: 14
                  nch: 24
             lightNum: 2
        rawdataLength: 5384
  5. channel_position.mat, or the channel’s position after calculation is a mat file with a single variable, preproc_info. An example is:
           wT1_info: [1x1 struct]
        rend_ch_pos: {1x6 cell}
    

    wT1_info is the volume information of the normalized brain (you can get this info by spm_vol). rend_ch_pos is a cellarray. Each element contains a different view of the brain. Try
    figure;imagesc(preproc_info.rend_ch_pos{4}.ren)
    hold on;plot(preproc_info.rend_ch_pos{4}.rchn,preproc_info.rend_ch_pos{4}.cchn,'o')
    You will see how the channel positions are displayed.

  6. SPM_indiv_HbO.mat, containing estimation parameters and info
  7. V_indiv_HbO.mat, a matlab mat file containing variable V_nirs, which is a sparse matrix.

related links:

第十九期 fNIRS Journal Club 通知 2021/05/29,9:30am

美国普渡大学童云杰助理教授,将为大家讲解他们组最近被接受的一篇使用近红外相位信息研究脑血流变化的文章。热烈欢迎大家参与讨论。 时间: 北京时间2021年5月29日上午9:30地点: https://zoom.com房间号: 846 8391 7517密码: 805190 童云杰教授简介:普渡大学 生物医学工程助理教授、博士生导师。主攻方向是多模态脑成像, 包括核磁,fNIRS, EEG。关注脑功能及生理信号的提取与研究。发表论文九十余篇,引用上千次(H-index = 20)。 童教授要讲解的文章如下: Liang Z, Tian H, Yang HC, Arimitsu T, Takahashi...
Xu Cui
12 sec read

第十八期 fNIRS Journal Club 视频

北京时间2021年4月25日10点,北京师范大学的朱朝喆教授为大家讲解了他们最近几年在经颅脑图谱(Transcranial brain Atlas) 方面做的工作。视频如下: Youtube: https://youtu.be/EhYPuBPQ5uI Youku: 该视频在优酷上传后被优酷屏蔽,不清楚什么原因。申诉无效。
Xu Cui
3 sec read

第七届全国近红外光谱脑功能成像学术会议

会议日期:2021年5月22日-24日会议地点:天津师范大学 一、 会议简介       近红外光谱脑功能成像(fNIRS)具有设备购买与使用成本低、可在自然环境条件下使用、具有较高的时间分辨率和空间定位能力等特点,受到了脑科学研究的高度重视。“近红外光谱脑功能成像学术会议”是由北京师范大学认知神经科学与学习国家重点实验室朱朝喆教授发起并组织的全国性学术会议。已连续成功举办六届,共吸引全国近百家高校、科研院所及医院的六百余名学者参加。该会议已成为国内规模和影响力最大的fNIRS脑成像学术活动。       本届会议由北京师范大学与天津师范大学联合主办。会议将延用往届会议将学术报告与研究方法工作坊相结合的模式。学术报告模块(5月22日周六)将邀请心理学与认知神经科学领域、基础与临床医学领域以及工程技术领域知名学者汇报其fNIRS最新研究成果;工作坊模块(5月23-24日)由fNIRS领域一线研究者系统讲授fNIRS成像原理、fNIRS实验设计、fNIRS数据分析与统计、fNIRS论文写作以及fNIRS前沿技术等。除理论讲授外,还设置了fNIRS空间定位与数据分析操作(NIRS-KIT软件)环节,此外还安排充足的研讨答疑时间以便与会人员交流互动。       具体日程与详细内容等最新消息请关注后续通知,可通过天津师范大学心理部网站http://psych.tjnu.edu.cn/或北京师范大学国家重点实验室网站http://brain.bnu.edu.cn/,或者扫描下方二维码关注微信公众号-“fNIRS脑成像实验室”查阅更新信息,期盼在天津师范大学与您相聚! 二、会议组织机构 主办单位:教育部人文社会科学重点研究基地天津师范大学心理与行为研究院、天津师范大学心理学部、北京师范大学认知神经科学与学习国家重点实验室会议主席:白学军、朱朝喆组织委员会:赵春健、杨邵峰、侯鑫、曹正操 三、说明1.        学术报告模块注册费:人民币500元/人;工作坊模块注册费:人民币2500元/人。发票为电子发票,内容均为:“会议费”。两个模块各自独立收费,参会者可根据自己需要进行选择。2.        注册费包括各自模块的资料费、午餐费;其他费用自理。3.        会议报告人免除会议模块注册费,其他费用请自理。4.       ...
Xu Cui
18 sec read

16 Replies to “Analyze NIRS data with NIRS-SPM”

  1. Hi Xu,

    This looks really great!

    Is the NIRS-SPM script for converting raw data to hemoglobin specific to continuous wave nirs devices, or can it be adapted for frequency domain?

    Thanks!

  2. Hi Cui,

    thanks for these detailed instructions.
    I have another question:
    how about the baseline correction. i have more than one time point that i measure a baseline to use it as a contrast to a motor condition. in the dialog in NIRS-SPM “enter baseline”: can I enter there a vector for many baselines and does NIRS-SPM calculate a mean baseline then?

    thank you, ingo

  3. Thank you a lot for this work, is very useful, specially when you are a beginner. I have a question about the group analysis: I am trying to do the group analysis and there is an option that I have not clear what is the minimum number of overlapped individual subjects. If I have already 9 subjects, how should I determinate ?
    Thank you

  4. Hello Xu,
    I’m using SPM5/8 and NIRS_SPM software and ETG-4000, I’m having trouble to find the SPM_indiv_HbO.mat for SPM_nirs.mat function in the Results NIRS button. can you tell me where to find it?

  5. @Eidan
    Eidan, I suggest you contact NIRS SPM’s developer. I have not used the software for a long time and not sure if they have updated it.

  6. Can I start NIRS-SPM without the data files?Thank you.Hello Xu.
    When I input the NIRS-SPM in the command window of MATLAB,it shows Undefined function or variable ‘nirs’.But I’ve already set the path in a correct way.I mean, Is there need any connection between my computer and NIRS machine?And how can I work it out?
    Thank you.

  7. @neuron
    I suggest you contact NIRS SPM’s developers directly. I have not used the software for a long time.

    I don’t think you need to connect to the nirs machine to use NIRS-SPM.

  8. Hello Xu,

    Thanks for detailed steps.
    I was working on the nirs_spm temporal processing. And my time_series views doesn’t display the Load button. I tried to debug and look like the panel covers all the below button. Could you please share your nirs_timeseries viewer.m file .

    Thank you

    1. Binal,

      I belive NIRS_TimeSeries_Viewer was provided by NIRS-SPM. Please feel free to ask the develop for the code.

      Xu

      1. I downloaded entire folder from spm website. Looks like there is bug with this file during update.So was asking if you could provide the file.

        Thanks

          1. Thank you so much Xu for providing the matlab file and quick response.
            I would need the timeseries_viewer.fig file also for the code to work.

            Thanks again. I really appreciate your time and help.

Leave a Reply

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

Loading