1 function [a_out] = phzapply(a,y);
2 % [a_out] = phzapply(a,y);
4 % apply the EPI phase shift parameters calcuated by phzshift or
5 % comp_local_pc to the original k-space data
9 % Copyright 2004-2016 W. Scott Hoge (wsh032580 at proton dot me)
11 % Licensed under the terms of the MIT License
12 % (https://opensource.org/licenses/MIT)
19 A1 = a(1:2:end,:,1:c);
20 A1a = fftshift(ifft(fftshift(A1,[ 2]),[],2),[ 2]);
22 A2 = a(2:2:end,:,1:c);
23 A2a = fftshift(ifft(fftshift(A2,[ 2]),[],2),[ 2]);
25 A1b = zeros(size(A1a));
26 A2b = zeros(size(A2a));
28 A1b(:,:,cnt) = A1a(:,:,cnt) * diag( exp( +j*y(1,cnt)/2*((1:size(A2a,2))-size(A2a,2)/2)));
29 A2b(:,:,cnt) = A2a(:,:,cnt) * diag( exp( -j*y(1,cnt)/2*((1:size(A2a,2))-size(A2a,2)/2)));
32 A1c = ifftshift(fft(ifftshift(A1b,[ 2]),[],2),[ 2]);
33 A2c = ifftshift(fft(ifftshift(A2b,[ 2]),[],2),[ 2]);
38 if ~isreal( y(2,cnt) ),
39 phz = angle(y(2,cnt));
43 A1c(:,:,cnt) = A1c(:,:,cnt) .* exp(-j*phz/2); % angle(y(2,cnt)));
44 A2c(:,:,cnt) = A2c(:,:,cnt) .* exp(j*phz/2); % angle(y(2,cnt)));
47 a_out = zeros(size(a));
48 a_out(1:2:end,:,:) = A1c;
49 a_out(2:2:end,:,:) = A2c;