function phi = probability(phi_w, t_low, t_high, w_s, w_t) si = size(phi_w); function p = prob_pass(phi_w, threshold) p = phi_w; pw = 0; for x=1:si(1) for y=1:si(2) for z=1:si(3) for t=1:si(4) grad_sum = 0; val = phi_w(x, y, z, t); tot = 0; if 1 threshold p(x, y, z, t) = val + 2*pi; pw = pw +1; end if prob < -threshold p(x, y, z, t) = val - 2*pi; pw = pw +1; end end end end end pw; end phi = prob_pass(phi_w, t_low); for i =1:9 phi = prob_pass(phi, t_low); end for i=1:10 phi = prob_pass(phi, t_high); end end