Created
February 11, 2015 11:13
-
-
Save moon6pence/4b43c63cb4240b31ea10 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getPhaseComplex(nScans::Int, nAlines::Int, fringe::Array{UInt16}, new_index::Array{Float32}, dispersion::Array{Complex64}) | |
# hanning window function | |
window = hanning(div(nScans, 2)) | |
# 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, div(nAlines, 4)) | |
# background subtraction | |
data_signal = fringe - bg | |
# FFT real data | |
dft_signal = fft(data_signal, 1) | |
# copy to extended vector, zero padding | |
dft_signal = [dft_signal[1:div(nScans,2), :]; zeros(Complex{Float64}, div(nScans,2), 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, 1) | |
# calibration | |
dft_complex1 = zeros(Complex128, length(new_index), nAlines) | |
for line = 1:nAlines | |
interp = Interpolation(scan_signal_zoom1[:, line], Linear(OnGrid()), ExtrapError()) | |
dft_complex1[:, line] = [interp[index] for index in new_index] | |
end | |
# numerical dispersion compensation & apply window function | |
dft_complex1 = dft_complex1 .* repmat(dispersion .* window, 1, nAlines) | |
# FFT for imaging | |
dft_complex_zoom1 = fft(dft_complex1, 1) | |
# 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) | |
return aline1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment