Commit ec67e930 authored by Simon Maretzke's avatar Simon Maretzke
Browse files

Improved GPU-support

parent d62b7fc5
Pipeline #100793 passed with stage
in 1 minute and 26 seconds
...@@ -269,7 +269,7 @@ if doIterativeOptimization ...@@ -269,7 +269,7 @@ if doIterativeOptimization
end end
if numel(settings.support) if numel(settings.support)
% If padding is applied to the data, the support has to be padded as well % If padding is applied to the data, the support has to be padded as well
support = gpuArrayIf(padarray(settings.support, [settings.pady, settings.padx]), useGPU); support = padarray(gpuArrayIf(settings.support, useGPU), [settings.pady, settings.padx]);
proxSupport = @(f) support .* f; proxSupport = @(f) support .* f;
else else
proxSupport = Id; proxSupport = Id;
......
...@@ -181,9 +181,9 @@ end ...@@ -181,9 +181,9 @@ end
% Optional padding of holograms (and of optional support) % Optional padding of holograms (and of optional support)
holograms = padarray(holograms, [settings.pady settings.padx], 'replicate'); holograms = padarray(gpuArrayIf(holograms, useGPU), [settings.pady settings.padx], 'replicate');
if ~isempty(settings.support) if ~isempty(settings.support)
settings.support = padarray(settings.support, [settings.pady settings.padx]); support = padarray(gpuArrayIf(settings.support, useGPU), [settings.pady settings.padx]);
end end
N = size(holograms(:,:,1)); N = size(holograms(:,:,1));
...@@ -199,6 +199,7 @@ settingsCTF.padx = 0; % Holograms are already padded, ...@@ -199,6 +199,7 @@ settingsCTF.padx = 0; % Holograms are already padded,
settingsCTF.pady = 0; % so no more padding necessary settingsCTF.pady = 0; % so no more padding necessary
settingsCTF.useGPUIfPossible = useGPU; settingsCTF.useGPUIfPossible = useGPU;
settingsCTF.optimization = struct; settingsCTF.optimization = struct;
settingsCTF.optimization.tolerance = 1e-2;
initialGuess = gpuArrayIf(phaserec_ctf(holograms, fresnelNumbers, settingsCTF), useGPU); initialGuess = gpuArrayIf(phaserec_ctf(holograms, fresnelNumbers, settingsCTF), useGPU);
% Preliminary nonlinearity-correction in the reconstructed absorption, applied in the low-frequency % Preliminary nonlinearity-correction in the reconstructed absorption, applied in the low-frequency
...@@ -235,7 +236,6 @@ F = NonlinearPhaseContrastOperator(N, fresnelNumbers, parOp); ...@@ -235,7 +236,6 @@ F = NonlinearPhaseContrastOperator(N, fresnelNumbers, parOp);
% Tikhonov functional(f) = || F(f) - holograms ||_2^2 + 2*|| regWeights * fft2(f) ||_2^2, % Tikhonov functional(f) = || F(f) - holograms ||_2^2 + 2*|| regWeights * fft2(f) ||_2^2,
% where regWeights contains the same Fourier-space regularization weights as used in phaserec_ctf % where regWeights contains the same Fourier-space regularization weights as used in phaserec_ctf
% (note that "*" denotes composition of Operators/functionals in the following statements) % (note that "*" denotes composition of Operators/functionals in the following statements)
holograms = gpuArrayIf(holograms, useGPU);
regWeightsTimes2 = 2*ctfRegWeights(N, mean(fresnelNumbers,2), settings.lim1, settings.lim2, useGPU); regWeightsTimes2 = 2*ctfRegWeights(N, mean(fresnelNumbers,2), settings.lim1, settings.lim2, useGPU);
TikhonovFunctional = NormSqFunctional * (F - holograms) ... TikhonovFunctional = NormSqFunctional * (F - holograms) ...
+ NormSqFunctional(@(f) real(ifft2(regWeightsTimes2 .* fft2(f)))); + NormSqFunctional(@(f) real(ifft2(regWeightsTimes2 .* fft2(f))));
...@@ -257,7 +257,6 @@ if settings.minPhase > -inf || settings.maxPhase < inf || ~isempty(settings.supp ...@@ -257,7 +257,6 @@ if settings.minPhase > -inf || settings.maxPhase < inf || ~isempty(settings.supp
end end
if numel(settings.support) if numel(settings.support)
% If padding is applied to the data, the support has to be padded as well % If padding is applied to the data, the support has to be padded as well
support = gpuArrayIf(settings.support, useGPU);
projSupport = @(f) support .* f; projSupport = @(f) support .* f;
else else
projSupport = Id; projSupport = Id;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment