batch script for NIRS-SPM

1 min read

I wrote some batch scripts for NIRS-SPM. They, together with NIRS-SPM and xTopo, are called “super” package (I apparently run out of names). The “super” package are located in directory:


Please don’t modify the files inside.

“super” contains the following scripts:

  1. mes2NIRSSPM, which converts Hitachi measurement data (in csv format) to NIRS-SPM recognized format (.mat file). Note: this script allows you to convert one or two files (for bilateral 3×5 and 4×4 configurations, you have 2 csv files) into one mat files. NIRS-SPM itself only convert 1 (I already contacted NIRS SPM developers to add this functionality.).
  2. spec, which specify your general linear model (design matrix), including data file, where to save spm files, either HbR or HbO, onset timing, duration etc.
  3. estimate_indiv, do estimation
  4. cuixu_nirsContrast, do contrast. Here you specify contrast vector etc
  5. estimate_group, do group estimation

All of these scripts can run alone — you don’t need to click button etc. To get more information of how to use these scripts, you may type help <script name>.

Here is instructions:

  1. Log in to server (e.g.  ssh fmri@scuttlebutt -Y)
  2. Start matlab with SPM5 in the path (e.g. ml7spm5 -jvm)
  3. add the path of super
  4. Enter a directory where you prefer to work (e.g. your data’s directory).
  5. Use mes2NIRSSPM to convert csv to mat file. e.g.
    mes2NIRSSPM(nirsfile, [‘converted_NIRS_’ subject_name])
    Note: nirsfile is a cell array. Each element is a file name. For 4×4 and 3×5 configurations, you have 2 files; for 3×11, you have only one.
  6. You need to configure your channel positions and get a channel position mat file. You can use the default files provided in super/templateFile/.
  7. use spec to specify design matrix. e.g.
    spec(‘converted_NIRS_c.mat’, ‘./newspmdir’,1, {‘trial1′,’t2′},{[1:1:100]’,[2:2:200]’},{ones(100,1),ones(100,1)*2});
    Type help spec for more info.
  8. use estimate_indiv to begin estimation. e.g.
  9. use cuixu_nirsContrast to do contrast.
  10. Repeat step 5-9 for other subjects
  11. use estimate_group to do group analysis
  12. To view result, launch nirs spm, click button “Results NIRS”. There you input the individual (or group)’s spm file, and channel location mat file (not required for group), and click button “Contrast”.

Leave a comment here if you have a question. To obtain a copy of super package, please fill the form below.


第十八期 fNIRS Journal Club 通知 2021/04/25,10am

北京师范大学的朱朝喆教授将为大家讲解他们最近几年在经颅脑图谱(Transcranial brain Atlas) 方面做的工作。热烈欢迎大家参与讨论。 时间: 北京时间2021年4月25日周日上午10点地点: https://zoom.com房间号: 863 1929 4069密码: 113560 朱朝喆教授简介:北京师范大学教授、博士生导师;认知神经科学与学习国家重点实验室,脑成像与神经调控实验室负责人(PI), 主要从事 fNIRS 脑成像与 TMS 神经调控相关理论研究与新技术开发。主持国家自然科学基金委重点项目、科技部重大仪器专项课题等。在 Science Advances,Brain 等期刊发表 SCI 论文八十余篇,SCI 引用 11851...
Xu Cui
5 sec read

第十七期 fNIRS Journal Club 视频

北京时间2021年3月27日周六10点,北京师范大学的卢春明教授为大家讲解他们最近发布的一篇用超扫描研究恋爱关系的文章。视频如下: Youtube: Youku:
Xu Cui
4 sec read

第十七期 fNIRS Journal Club 通知 2021/03/27,10am

北京师范大学的卢春明教授将为大家讲解他们最近发布的一篇用超扫描研究恋爱关系的文章。热烈欢迎大家参与讨论。 时间: 北京时间2021年3月27日周六上午10点地点: https://zoom.com房间号: 870 6817 2529 密码: 433527 Long, Zheng, Zhao, Zhou, Zhai, Lu (2020) Interpersonal Neural Synchronization during Interpersonal Touch Underlies Affiliative...
Xu Cui
51 sec read

26 Replies to “batch script for NIRS-SPM”

  1. Hi Xu,
    thank you very much for writing the “super” package. In your discription are some batches I need for my analysis with NIRS_SPM but I have not found the download here for your package.

    If it´s no more online available, please can you send it to my private emailadress?

    Thank you very much!

    kind regards,

  2. Would you send me the code as well please? I have about 90 files I need to convert for individual and group analysis. Automating the contrast and group analysis would be very helpful.


  3. Is this code still available? I just started with NIRS and am a bit lost as to coding around NIRS_SPM. Let me know if you could share, thanks!


  4. Hi Xu

    Hereby I would like to ask whether you still have the code for the batch processing using NIRS-SPM. I would be very grateful if you could share it with me, your ‘super’ package?

    Thank you in advcance,
    Lisa Holper

  5. Hi Xu,
    Thanks again for your hint, I downloaded the package.
    I know it is a long time ago you wrote that code. But would it be possible for you to adapt the code in order to process all subjects in one run?
    I have hundreds of subjects -)

    @Xu Cui

  6. Hi,Xu, I would really appreciate if you share your “super” codes with me.Thanks!

  7. Hi Xu,
    thank you very much for writing the “super” package. In your discription are some batches I need for my analysis with NIRS_SPM but I have not found the download here for your package.

    please send me link to your super script.

    Thank you very much!

    kind regards,
    Cui Jie

  8. Hi Xu,
    thank you very much for writing the “super” package. I have filled the form and clicked ’submit’ button, but I did not get an email with the download link. please send me your “super” scripts. Thank you very much!

    kind regards,
    Cui Jie

Leave a Reply to seapsy Cancel reply

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