当前位置: 首页 > article >正文

使用SPM_batch进行批量跑脚本(matlab.m)

软件:spm8+matlab2023b+win11
数据格式:
F:\ASL\HC\CBF\HC_caishaoqing\CBF.nii
F:\ASL\HC\CBF\HC_caishaoqing\T1.nii

F:\ASL\HC\CBF\HC_wangdonga\CBF.nii
F:\ASL\HC\CBF\HC_wangdonga\T1.nii

clear
spmdir='D:\AnalysisApps\spm8';
datadir='F:\ASL\HC\CBF';
cd(datadir);
allsubs=dir('HC*');

for i=1:numel(allsubs)
    cursub=allsubs(i).name;
    matlabbatch{1}.spm.spatial.normalise.estwrite.subj.source = {fullfile(datadir,cursub,'CBF.nii')};
    matlabbatch{1}.spm.spatial.normalise.estwrite.subj.wtsrc = '';
    matlabbatch{1}.spm.spatial.normalise.estwrite.subj.resample = {fullfile(datadir,cursub,'CBF.nii')};
    matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.template = {'D:\AnalysisApps\spm8\templates\PET.nii,1'};
    matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.weight = '';
    matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.smosrc = 8;
    matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.smoref = 0;
    matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.regtype = 'mni';
    matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.cutoff = 25;
    matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.nits = 16;
    matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.reg = 1;
    matlabbatch{1}.spm.spatial.normalise.estwrite.roptions.preserve = 0;
    matlabbatch{1}.spm.spatial.normalise.estwrite.roptions.bb = [-78 -112 -50
                                                                 78 76 85];
    matlabbatch{1}.spm.spatial.normalise.estwrite.roptions.vox = [2 2 2];
    matlabbatch{1}.spm.spatial.normalise.estwrite.roptions.interp = 1;
    matlabbatch{1}.spm.spatial.normalise.estwrite.roptions.wrap = [0 0 0];
    matlabbatch{1}.spm.spatial.normalise.estwrite.roptions.prefix = 'w';
    spm_jobman('run',matlabbatch)
end

后面的脚本来自spm-view-show.m code
在这里插入图片描述
下面这里是show.m产生的原始脚本。可以看出我们只是把绿色部分用循环语句替换了。

matlabbatch{1}.spm.spatial.normalise.estwrite.subj.source = {'F:\ASL\HC\CBF\HC_caishaoqing\CBF.nii,1'};
matlabbatch{1}.spm.spatial.normalise.estwrite.subj.wtsrc = '';
matlabbatch{1}.spm.spatial.normalise.estwrite.subj.resample = {'F:\ASL\HC\CBF\HC_caishaoqing\CBF.nii,1'};
matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.template = {'D:\AnalysisApps\spm8\templates\PET.nii,1'};
matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.weight = '';
matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.smosrc = 8;
matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.smoref = 0;
matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.regtype = 'mni';
matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.cutoff = 25;
matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.nits = 16;
matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.reg = 1;
matlabbatch{1}.spm.spatial.normalise.estwrite.roptions.preserve = 0;
matlabbatch{1}.spm.spatial.normalise.estwrite.roptions.bb = [-78 -112 -50
                                                             78 76 85];
matlabbatch{1}.spm.spatial.normalise.estwrite.roptions.vox = [2 2 2];
matlabbatch{1}.spm.spatial.normalise.estwrite.roptions.interp = 1;
matlabbatch{1}.spm.spatial.normalise.estwrite.roptions.wrap = [0 0 0];
matlabbatch{1}.spm.spatial.normalise.estwrite.roptions.prefix = 'w';

在这里插入图片描述


http://www.kler.cn/a/229011.html

相关文章:

  • 【Java】LinkedHashMap (LRU)淘汰缓存的使用
  • 在Linux上如何让ollama在GPU上运行模型
  • arcgis提取不规则栅格数据的矢量边界
  • 2025 年 Java 最新学习资料与学习路线——从零基础到高手的成长之路
  • Java21 正则表达式
  • QT:IconButton的动画效果
  • 7.0 Zookeeper 客户端基础命令使用
  • Coil:Android上基于Kotlin协程的超级图片加载库
  • 想上岸?有这个神器足矣!
  • SpringMVC精简知识点
  • JAVA字节流的两个重要子类FileOutputStream、FileInputStream
  • 292.Nim游戏
  • React16源码: React中event事件监听绑定的源码实现
  • undefined symbol: _ZN5boost15program_options22error_with_option
  • 类银河恶魔城学习记录1-6 Flip基本设置源代码 P33
  • 网络原理TCP/IP(5)
  • ensp实验合集(二)
  • 创建自己的Hexo博客
  • 第8章 多线程
  • Postgresql体系结构
  • 【PTA函数题】6-2 约瑟夫环之循环链表
  • Hack The Box-Challenges-Misc-M0rsarchive
  • 【数据结构与算法】(7)基础数据结构之双端队列的链表实现、环形数组实现示例讲解
  • echarts使用之柱状图(一)
  • LeetCode--代码详解 2.两数相加
  • linux+rv1126/imx6ull:opencv静态库交叉编译(手把手百分百成功)