Skip to content

Instantly share code, notes, and snippets.

@moon6pence
Created February 11, 2015 11:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moon6pence/3e60772943f206842d31 to your computer and use it in GitHub Desktop.
Save moon6pence/3e60772943f206842d31 to your computer and use it in GitHub Desktop.
function [aline1] = getPhaseComplexDFT(nScans, nAlines, fringe, new_index, dispersion)
% window function
window = hann(length(new_index));
% generate bg by averaging fringes
bgm_1 = mean(fringe(:, 1:4:nAlines), 2);
bgm_2 = mean(fringe(:, 2:4:nAlines), 2);
bgm_3 = mean(fringe(:, 3:4:nAlines), 2);
bgm_4 = mean(fringe(:, 4:4:nAlines), 2);
bg = repmat([bgm_1 bgm_2 bgm_3 bgm_4], 1, nAlines/4);
% background subtraction
data_signal = fringe - bg;
% FFT real data
dft_signal = fft(data_signal);
% copy to extended vector, zero padding
% length(new_index) = nScans/2 (oph. system) or nScans/4 (doppler system)
dft_signal = [dft_signal(1:length(new_index), :); zeros(length(new_index), nAlines)];
% circular shift -1/4 to remove frequency shift effect
dft_signal = circshift(dft_signal, -size(dft_signal, 1)/4);
% IFFT to get complex fringes
scan_signal_zoom1 = ifft(dft_signal);
% calibration
dft_complex1 = interp1(scan_signal_zoom1, new_index);
% numerical dispersion compensation & apply window function
dft_complex1 = dft_complex1 .* repmat(dispersion .* window, 1, nAlines);
% FFT for imaging
dft_complex_zoom1 = fft(dft_complex1);
% circular shift -1/2 to remove frequency shift effect
aline1 = circshift(dft_complex_zoom1, -size(dft_complex_zoom1, 1)/2);
% flip upside down
aline1 = flipud(aline1);
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment