-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdp_node_fsl_fnirt.m
executable file
·67 lines (49 loc) · 1.76 KB
/
dp_node_fsl_fnirt.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
classdef dp_node_fsl_fnirt < dp_node
% non-linear coregistration using fnirt
%
% as of now written for dmri (fa)
%
% input.nii_fn
% input.target_fn
%
% output.warp_fn
%
% output.nii_fn (passthrough)
% output.target_fn (passthrough)
properties
config_str = 'FA_2_FMRIB58_1mm';
end
methods
function obj = dp_node_fsl_fnirt()
obj.output_test = {'warp_fn'};
end
function input = po2i(obj, po)
input = po;
% output came from the flirt node, so we want to preserve
% the original nifti file throughout this chain
if (isfield(po, 'original_nii_fn'))
input.nii_fn = input.original_nii_fn;
end
end
function output = i2o(obj, input)
output.warp_fn = dp.new_fn(input.op, input.nii_fn, '_fnirtwarp');
% pass along the (unwarped) nifti file and the target
output.nii_fn = input.nii_fn;
output.target_fn = input.target_fn;
end
function output = execute(obj, input, output)
[~,~,suffix] = msf_fileparts(output.warp_fn);
f = @(x) x(1:(end-numel(suffix)));
% Build the fnirt command
fnirt_cmd = cat(2, ...
'fnirt ', ...
sprintf('--ref=''%s'' ', input.target_fn), ...
sprintf('--in=''%s'' ', input.nii_fn), ...
sprintf('--aff=''%s'' ', input.matrix_fn), ...
sprintf('--cout=''%s'' ', f(output.warp_fn)), ...
sprintf('--config=''%s'' ', obj.config_str));
msf_mkdir(fileparts(output.warp_fn));
system(fnirt_cmd); % Execute it
end
end
end