function [x,SPIRiTobj,L1obj] = pocsSPIRiT_wrapper(data, GOP, nIter, x0, wavWeight, show)
%
% Wraps pocsSPIRiT, also computing SPIRiT and L1 objectives for solution.

x = pocsSPIRiT(data,GOP,nIter,x0,wavWeight,show);

% from pocsSPIRiT code -- need to match wavelet used in pocsSPIRiT
[sx,sy,nc] = size(data);
ssx = 2^ceil(log2(sx)); 
ssy = 2^ceil(log2(sy));
ss = max(ssx, ssy);
W = Wavelet('Daubechies',4,4);

X = GOP*x;
SPIRiTobj = 0.5.*norm(X(:))^2;
X = ifft2c(x); % goto image domain
X= zpad(X,ss,ss,nc); % zpad to the closest diadic 
X = W*(X); % apply wavelet
L1obj = sum(sum(sqrt(sum(abs(X).^2,3))));

end
