-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsurf_smooth.m
More file actions
41 lines (40 loc) · 1.33 KB
/
surf_smooth.m
File metadata and controls
41 lines (40 loc) · 1.33 KB
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
function Out=surf_smooth(P,varargin)
% Smooth metric files
% Out=surf_smooth(P,varargin);
% Uses wb_command to smooth the files
% INPUT:
% P: cell array of metric files to smooth
% VARARGIN:
% 'surf',file: Surface file to smooth on (fyll filepath)
% 'kernel': The sigma for the gaussian kernel function, in mm
% OUTPUT:
% Cell array of smooth metric files
% -------------------------------------------------------------------
% Note: default algorithm GEO_GAUSS_AREA, other methods not implemented
% More info: https://www.humanconnectome.org/software/workbench-command/-metric-smoothing
% EBerlot, May 2019
%
prefix = 's';
kernel = 2.0;
surf = [];
vararginoptions(varargin,{'prefix','kernel','surf','outfile'});
if (nargin<1 || isempty(P))
error('Provide the metric .func.gii file.\n');
elseif (iscell(P))
P=char(P);
end;
if (isempty(surf))
error('Provide the .surf.gii file.\n');
end;
N = size(P,1);
Out = cell(1,N);
for i=1:N
[dir,name,postfix]=fileparts(deblank(P(i,:)));
Out{i}=fullfile(dir,[prefix name postfix]);
comm=sprintf('wb_command -metric-smoothing %s %s %f %s -fix-zeros',...
surf,P,kernel,Out{i});
%fprintf('%s\n',comm)
[err,out]=system(comm);
fprintf('\nSmoothed file %s\n%d:%s\n',[name postfix],err,out);
%fprintf('Smoothed file %s\n',[name postfix]);
end;