function [Out]=generate_fig4(dataset,DF,params,I,addn)
% This code is a part of
%--------------------------------------------------------------------------
% [1]  Joy A, Paul J S. "Multi-channel MR Image Reconstruction using
%      Statistically Optimized Non-Linear Diffusion", Magnetic Resonance in 
%      Medicine, June 2017, doi:10.1002/mrm.26774.
% Email: ajin.joy@iiitmk.ac.in, j.paul@iiitmk.ac.in
%
% Coded by : Ajin Joy on March 2017
%--------------------------------------------------------------------------
gamma         = linspace(.0001,.25,100);
stdv          = [.005,.01,.015,.02];
params.scale  = .5^2;% 50%MAD
params.numitr = 100;
Out           = cell(1,4);
err           = zeros(1,100);
h             = waitbar(0,'sensitivity to stepsize..');
disp('Checking sensitivity to stepsize..')
for i=1:4
    for j=1:100
        waitbar(j/100,h,sprintf('gamma %d/100 std(noise) = %.3f',j,stdv(i)));
        params.gamma = gamma(j);
        OutNL        = NLdiffusionMRI_stripped(addn(I,stdv(i)),dataset{6}.mask,DF,params);
        err(j)       = OutNL.err(end);
    end
    Out{i} = err;
end
delete(h)