-
Notifications
You must be signed in to change notification settings - Fork 0
/
b_batch_stc.m
46 lines (36 loc) · 1.36 KB
/
b_batch_stc.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
function b_batch_stc(subs,runs,home_path,nFiles,refSlice,sliceOrder,TR,nSlices,TA)
%%
% spm_jobman('initcfg')
for s=1:numel(subs)
sub=subs(s);
for r=1:numel(runs)
run=runs(r);
end_path=['/s' sprintf('%3.3d',sub) '/r' num2str(run) '/import'];
path=[home_path end_path];
cd([home_path end_path])
list=dir('_s*.nii');
list=list(1:nFiles);
if length({list.name})~=nFiles
error(['wrong number of files in sub' sprintf('%3.3d',sub) ' run' num2str(run)]);
end
for i=1:length({list.name})
list(i).name=[path '/' list(i).name ',1'];
end
matlabbatch{1,1}.spm.temporal.st.scans{1,r}={list.name}';
end
matlabbatch{1}.spm.temporal.st.nslices = nSlices;
matlabbatch{1}.spm.temporal.st.tr = TR;
matlabbatch{1}.spm.temporal.st.ta = TA;
matlabbatch{1}.spm.temporal.st.so = sliceOrder;
matlabbatch{1}.spm.temporal.st.refslice = refSlice;
matlabbatch{1}.spm.temporal.st.prefix = 'a';
spm_jobman('run', matlabbatch);
%% movefiles
for r=1:numel(runs)
run=runs(r);
stcFldr=[home_path '/s' sprintf('%3.3d',sub) '/r' num2str(run) '/stc'];
mkdir(stcFldr);
movefile([home_path '/s' sprintf('%3.3d',sub) '/r' num2str(run) '/import/a*'],...
[stcFldr])
end
end