idamnjanovic@54
|
1 function data = completeOps(data)
|
idamnjanovic@54
|
2
|
idamnjanovic@54
|
3 % Copyright 2008, Ewout van den Berg and Michael P. Friedlander
|
idamnjanovic@54
|
4 % http://www.cs.ubc.ca/labs/scl/sparco
|
idamnjanovic@54
|
5 % $Id: completeOps.m 1040 2008-06-26 20:29:02Z ewout78 $
|
idamnjanovic@54
|
6
|
idamnjanovic@54
|
7 operators = {};
|
idamnjanovic@54
|
8 flagM = 0; if isfield(data,'M'), flagM = 1; end;
|
idamnjanovic@54
|
9 flagB = 0; if isfield(data,'B'), flagB = 1; end;
|
idamnjanovic@54
|
10
|
idamnjanovic@54
|
11 if (~flagM) && (~flagB)
|
idamnjanovic@54
|
12 error('At least one of the operators M or B has be to given.');
|
idamnjanovic@54
|
13 end
|
idamnjanovic@54
|
14
|
idamnjanovic@54
|
15 % Define measurement matrix if needed
|
idamnjanovic@54
|
16 if ~flagM
|
idamnjanovic@54
|
17 info = data.B([],0);
|
idamnjanovic@54
|
18 data.M = opDirac(info{1});
|
idamnjanovic@54
|
19 else
|
idamnjanovic@54
|
20 operators{end+1} = data.M;
|
idamnjanovic@54
|
21 end
|
idamnjanovic@54
|
22
|
idamnjanovic@54
|
23 % Define sparsity basis if needed
|
idamnjanovic@54
|
24 if ~flagB
|
idamnjanovic@54
|
25 info = data.M([],0);
|
idamnjanovic@54
|
26 data.B = opDirac(info{2});
|
idamnjanovic@54
|
27 else
|
idamnjanovic@54
|
28 operators{end+1} = data.B;
|
idamnjanovic@54
|
29 end
|
idamnjanovic@54
|
30
|
idamnjanovic@54
|
31 % Define operator A if needed
|
idamnjanovic@54
|
32 if ~isfield(data,'A')
|
idamnjanovic@54
|
33 if (length(operators) > 1)
|
idamnjanovic@54
|
34 data.A = opFoG(operators{:});
|
idamnjanovic@54
|
35 else
|
idamnjanovic@54
|
36 data.A = operators{1};
|
idamnjanovic@54
|
37 end
|
idamnjanovic@54
|
38 end
|
idamnjanovic@54
|
39
|
idamnjanovic@54
|
40 % Define empty solution if needed
|
idamnjanovic@54
|
41 if ~isfield(data,'x0')
|
idamnjanovic@54
|
42 data.x0 = [];
|
idamnjanovic@54
|
43 end
|
idamnjanovic@54
|
44
|
idamnjanovic@54
|
45 % Define the operator size and string
|
idamnjanovic@54
|
46 opInfo = data.A([],0);
|
idamnjanovic@54
|
47 data.sizeA = [opInfo{1},opInfo{2}];
|
idamnjanovic@54
|
48 opInfo = data.B([],0);
|
idamnjanovic@54
|
49 data.sizeB = [opInfo{1},opInfo{2}];
|
idamnjanovic@54
|
50 opInfo = data.M([],0);
|
idamnjanovic@54
|
51 data.sizeM = [opInfo{1},opInfo{2}];
|
idamnjanovic@54
|
52 data.op.strA = opToString(data.A);
|
idamnjanovic@54
|
53 data.op.strB = opToString(data.B);
|
idamnjanovic@54
|
54 data.op.strM = opToString(data.M);
|
idamnjanovic@54
|
55
|
idamnjanovic@54
|
56 % Get the size of the desired signal
|
idamnjanovic@54
|
57 if ~isfield(data,'signalSize')
|
idamnjanovic@54
|
58 if ~isfield(data,'signal')
|
idamnjanovic@54
|
59 error(['At least one of the fields signal ', ...
|
idamnjanovic@54
|
60 'or signalSize must be given.']);
|
idamnjanovic@54
|
61 end
|
idamnjanovic@54
|
62 data.signalSize = size(data.signal);
|
idamnjanovic@54
|
63 end
|
idamnjanovic@54
|
64
|
idamnjanovic@54
|
65 % Reconstruct signal from sparse coefficients
|
idamnjanovic@54
|
66 if ~isfield(data,'reconstruct')
|
idamnjanovic@54
|
67 data.reconstruct = @(x) reshape(data.B(x,1),data.signalSize);
|
idamnjanovic@54
|
68 end
|
idamnjanovic@54
|
69
|
idamnjanovic@54
|
70 % Reorder the fields (sort alphabetically)
|
idamnjanovic@54
|
71 m = fieldnames(data);
|
idamnjanovic@54
|
72 m = sort(m);
|
idamnjanovic@54
|
73 dataReorder = struct();
|
idamnjanovic@54
|
74 for i=1:length(m)
|
idamnjanovic@54
|
75 eval(sprintf('dataReorder.%s = data.%s;',m{i},m{i}));
|
idamnjanovic@54
|
76 end
|
idamnjanovic@54
|
77
|
idamnjanovic@54
|
78 data = dataReorder;
|