function out = fft3c(in)
%
% function out = fft3c(in)
%
% Perform centered FFT, unnormalized, along first three input dimensions. 
%
% Input:
%   in - 3+-dimensional matrix of image(s)
%
% Output:
%   out - matrix of centered FFT coefficients
%
% Copyright 2012-10-09, Daniel Weller, University of Michigan

sz_in = size(in); sz_in(end+1:3) = 1;
nvols = prod(sz_in(4:end));
out = zeros(sz_in,class(in));

for ivol = 1:nvols
    fft_out = in(:,:,:,ivol);
    fft_out = fftshift(fftn(ifftshift(fft_out)));
    out(:,:,:,ivol) = fft_out;
end

end
