idamnjanovic@54: function data = completeOps(data) idamnjanovic@54: idamnjanovic@54: % Copyright 2008, Ewout van den Berg and Michael P. Friedlander idamnjanovic@54: % http://www.cs.ubc.ca/labs/scl/sparco idamnjanovic@54: % $Id: completeOps.m 1040 2008-06-26 20:29:02Z ewout78 $ idamnjanovic@54: idamnjanovic@54: operators = {}; idamnjanovic@54: flagM = 0; if isfield(data,'M'), flagM = 1; end; idamnjanovic@54: flagB = 0; if isfield(data,'B'), flagB = 1; end; idamnjanovic@54: idamnjanovic@54: if (~flagM) && (~flagB) idamnjanovic@54: error('At least one of the operators M or B has be to given.'); idamnjanovic@54: end idamnjanovic@54: idamnjanovic@54: % Define measurement matrix if needed idamnjanovic@54: if ~flagM idamnjanovic@54: info = data.B([],0); idamnjanovic@54: data.M = opDirac(info{1}); idamnjanovic@54: else idamnjanovic@54: operators{end+1} = data.M; idamnjanovic@54: end idamnjanovic@54: idamnjanovic@54: % Define sparsity basis if needed idamnjanovic@54: if ~flagB idamnjanovic@54: info = data.M([],0); idamnjanovic@54: data.B = opDirac(info{2}); idamnjanovic@54: else idamnjanovic@54: operators{end+1} = data.B; idamnjanovic@54: end idamnjanovic@54: idamnjanovic@54: % Define operator A if needed idamnjanovic@54: if ~isfield(data,'A') idamnjanovic@54: if (length(operators) > 1) idamnjanovic@54: data.A = opFoG(operators{:}); idamnjanovic@54: else idamnjanovic@54: data.A = operators{1}; idamnjanovic@54: end idamnjanovic@54: end idamnjanovic@54: idamnjanovic@54: % Define empty solution if needed idamnjanovic@54: if ~isfield(data,'x0') idamnjanovic@54: data.x0 = []; idamnjanovic@54: end idamnjanovic@54: idamnjanovic@54: % Define the operator size and string idamnjanovic@54: opInfo = data.A([],0); idamnjanovic@54: data.sizeA = [opInfo{1},opInfo{2}]; idamnjanovic@54: opInfo = data.B([],0); idamnjanovic@54: data.sizeB = [opInfo{1},opInfo{2}]; idamnjanovic@54: opInfo = data.M([],0); idamnjanovic@54: data.sizeM = [opInfo{1},opInfo{2}]; idamnjanovic@54: data.op.strA = opToString(data.A); idamnjanovic@54: data.op.strB = opToString(data.B); idamnjanovic@54: data.op.strM = opToString(data.M); idamnjanovic@54: idamnjanovic@54: % Get the size of the desired signal idamnjanovic@54: if ~isfield(data,'signalSize') idamnjanovic@54: if ~isfield(data,'signal') idamnjanovic@54: error(['At least one of the fields signal ', ... idamnjanovic@54: 'or signalSize must be given.']); idamnjanovic@54: end idamnjanovic@54: data.signalSize = size(data.signal); idamnjanovic@54: end idamnjanovic@54: idamnjanovic@54: % Reconstruct signal from sparse coefficients idamnjanovic@54: if ~isfield(data,'reconstruct') idamnjanovic@54: data.reconstruct = @(x) reshape(data.B(x,1),data.signalSize); idamnjanovic@54: end idamnjanovic@54: idamnjanovic@54: % Reorder the fields (sort alphabetically) idamnjanovic@54: m = fieldnames(data); idamnjanovic@54: m = sort(m); idamnjanovic@54: dataReorder = struct(); idamnjanovic@54: for i=1:length(m) idamnjanovic@54: eval(sprintf('dataReorder.%s = data.%s;',m{i},m{i})); idamnjanovic@54: end idamnjanovic@54: idamnjanovic@54: data = dataReorder;