-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdp_node_elastix_coreg.m
executable file
·59 lines (41 loc) · 1.4 KB
/
dp_node_elastix_coreg.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
classdef dp_node_elastix_coreg < dp_node
% coregistration using elastix
%
% input fields
%
% nii_fn
% target_fn
%
% output fields
%
% nii_fn (registered file)
% elastix_f_fn (registration parameters)
% target_fn (same as input)
%
properties
p = elastix_p_6dof(100);
mio_opt = mio_opt();
end
methods
function obj = dp_node_elastix_coreg(p, mio_opt)
if (nargin >= 1), obj.p = p; end
if (nargin >= 2), obj.mio_opt = mio_opt; end
obj.output_test = {'nii_fn', 'elastix_t_fn'};
end
function output = i2o(obj, input, output)
output.nii_fn = dp.new_fn(input.op, input.nii_fn, '_ecoreg');
output.elastix_t_fn = dp.new_fn(input.op, input.nii_fn, '_ecoreg', '.txt');
% target passthrough
output.target_fn = input.target_fn;
end
function output = execute(obj, input, output)
% assume input.nii_fn is a 3D volume
[I_mov, h_mov] = mdm_nii_read(input.nii_fn);
[I_ref, h_ref] = mdm_nii_read(input.target_fn);
[I_res,tp,h_res,elastix_t] = mio_coreg(I_mov, I_ref, obj.p, ...
obj.mio_opt, h_mov, h_ref);
mdm_nii_write(I_res, output.nii_fn, h_res);
elastix_p_write(elastix_t, output.elastix_t_fn);
end
end
end