-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdp_node_items_from_fields.m
executable file
·50 lines (36 loc) · 1.12 KB
/
dp_node_items_from_fields.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
classdef dp_node_items_from_fields < dp_node
% generate output with items, where each item has the following fields
%
% bp
% op
% id
%
% nii_fn from field_names{c} (item c gets field name c from input)
%
% (general fields)
properties
field_names;
general_fields;
end
methods
function obj = dp_node_items_from_fields(field_names, general_fields)
obj.field_names = field_names;
obj.general_fields = general_fields;
end
function output = i2o(obj, input)
output.id = input.id;
for c = 1:numel(obj.field_names)
% transfer key fields
tmp.bp = input.bp;
tmp.op = input.op;
tmp.id = input.id;
% xxx: generalize this
tmp.nii_fn = input.(obj.field_names{c});
for c2 = 1:numel(obj.general_fields)
tmp.(obj.general_fields{c2}) = input.(obj.general_fields{c2});
end
output.items{c} = tmp;
end
end
end
end