-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgroovy_smooth.m
52 lines (39 loc) · 1.22 KB
/
groovy_smooth.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
46
47
48
function groovy_smooth(glob_ps, sub_ps)
% Get the defaults
sdefs = glob_ps.smooth_opts;
imgs = '';
for sb = 1:length(sub_ps)
my_sub = sub_ps(sb);
subjroot = fullfile(glob_ps.fdata_root, my_sub.dir);
sm_filter = ['^' glob_ps.smooth_prefix my_sub.raw_filter '$'];
for ss = 1:length(my_sub.sesses)
dirn = fullfile(subjroot,my_sub.sesses(ss).dir);
% get files in this directory
P = spm_select('List',dirn,sm_filter);
% For 4dnii files
switch glob_ps.epi_format
case '4dnii'
vol = spm_vol(fullfile(dirn,P));
filename = vol(1).fname;
for b = 1:length(vol);
file_list{b}=sprintf('%s, %d',filename,b);
end;
imgs = strvcat(imgs,strvcat(file_list));
otherwise
imgs = strvcat(imgs, [repmat([dirn filesep],size(P,1),1) P]);
end;
end
end
% and this is just spm_smooth_ui pasted/edited
s = sdefs.fwhm;
P = imgs;
n = size(P,1);
dtype = sdefs.dtype;
% implement the convolution
%---------------------------------------------------------------------------
for i = 1:n
Q = deblank(P(i,:));
[pth,nm,xt] = fileparts(deblank(Q));
U = fullfile(pth,[sdefs.prefix nm xt]);
spm_smooth(Q,U,s);
end