本文使用半自动的办法进行原点矫正,代码的主要作用是自动打开需要进行原点矫正的文件,随后手动进行原点矫正后,在matlab的command界面,激活光标后,按键盘任意键来打开下一个文件。
下面是matlab代码,分为.m和job.m两个文件。运行时,打开.m文件点击运行,开始进行数据处理。代码如下:
.m文件代码
% List of open inputs
global files filenames sub anat lesi path;
path = 'F:\TWDTIproject\datatoprocess\2NonCMSGroup\1_reoriented_nii'; %待处理的文件目录
files=dir(path);
filenames = {files.name};
for i=3:length(filenames)
sub = files(i).name;
anat = fullfile(path,sub,'3DT1.nii,1'); %需要进行原点矫正的图像
lesi = fullfile(path,sub,'TMASK.nii,1'); %需要同时进行原点矫正的mask
nrun = 1; % enter the number of runs here
jobfile = {'F:\TWDTIproject\datatoprocess\reorient_job.m'};
jobs = repmat(jobfile, 1, nrun);
inputs = cell(0, nrun);
for crun = 1:nrun
end
spm('defaults', 'FMRI');
spm_jobman('run', jobs, inputs{:});
pause()
end
job.m文件代码:
%-----------------------------------------------------------------------
% Job saved on 08-Dec-2022 10:59:42 by cfg_util (rev $Rev: 6134 $)
% spm SPM - SPM12 (6225)
% cfg_basicio BasicIO - Unknown
%-----------------------------------------------------------------------
global anat;
matlabbatch{1}.spm.util.disp.data = {anat};
%matlabbatch{2}.spm.util.reorient.srcfiles = {
%'D:\CMS-MB-multicenter_project\tiantanhospital\testreor\383360\t1.nii,1'
%'D:\CMS-MB-multicenter_project\tiantanhospital\testreor\383360\t1mask.nii,1'
%};
%matlabbatch{2}.spm.util.reorient.transform.transM = [0 0 0 0
%0 0 0 0
%0 0 0 0
%0 0 0 1];
%matlabbatch{2}.spm.util.reorient.prefix = 'ro';
操作过程如下:
step 1: matlab command 界面输入:spm fmri,随后使用matlab打开.m文件,并单击运行
step 2:在系统自动打开第一个文件后,手动矫正原点。①移动光标至前联合;②点击set origin;③点击reorient;④选择需要和T1一起reorient的mask文件,并点击确定;⑤保存.mat文件
step 3: 光标移动到matlab command 界面,并点击激活后,单击键盘任意键,开始循环,打开下一个需要矫正的文件
End