dicklyon@462
|
1 function stage_state = CARFAC_Spatial_Smooth(coeffs, stage, stage_state)
|
dicklyon@462
|
2 % function AGC_state = CARFAC_Spatial_Smooth( ...
|
dicklyon@462
|
3 % n_taps, n_iterations, FIR_coeffs, AGC_state)
|
dicklyon@462
|
4
|
dicklyon@462
|
5 n_iterations = coeffs.AGC_spatial_iterations(stage);
|
dicklyon@462
|
6
|
dicklyon@462
|
7 use_FIR = n_iterations < 4; % or whatever condition we want to try
|
dicklyon@462
|
8
|
dicklyon@462
|
9 if use_FIR
|
dicklyon@462
|
10 FIR_coeffs = coeffs.AGC_spatial_FIR(:,stage);
|
dicklyon@462
|
11 switch coeffs.AGC_n_taps(stage)
|
dicklyon@462
|
12 case 3
|
dicklyon@462
|
13 for iter = 1:n_iterations
|
dicklyon@462
|
14 stage_state = ...
|
dicklyon@462
|
15 FIR_coeffs(1) * stage_state([1, 1:(end-1)], :) + ...
|
dicklyon@462
|
16 FIR_coeffs(2) * stage_state + ...
|
dicklyon@462
|
17 FIR_coeffs(3) * stage_state([2:end, end], :);
|
dicklyon@462
|
18 end
|
dicklyon@462
|
19 case 5 % 5-tap smoother duplicates first and last coeffs:
|
dicklyon@462
|
20 for iter = 1:n_iterations
|
dicklyon@462
|
21 stage_state = ...
|
dicklyon@462
|
22 FIR_coeffs(1) * (stage_state([1, 1, 1:(end-2)], :) + ...
|
dicklyon@462
|
23 stage_state([1, 1:(end-1)], :)) + ...
|
dicklyon@462
|
24 FIR_coeffs(2) * stage_state + ...
|
dicklyon@462
|
25 FIR_coeffs(3) * (stage_state([2:end, end], :) + ...
|
dicklyon@462
|
26 stage_state([3:end, end, end], :));
|
dicklyon@462
|
27 end
|
dicklyon@462
|
28 otherwise
|
dicklyon@462
|
29 error('Bad n_taps in CARFAC_Spatial_Smooth');
|
dicklyon@462
|
30 end
|
dicklyon@462
|
31 else
|
dicklyon@462
|
32 % use IIR method, back-and-forth firt-order smoothers:
|
dicklyon@462
|
33 stage_state = SmoothDoubleExponential(stage_state, ...
|
dicklyon@462
|
34 coeffs.AGC_polez1(stage), coeffs.AGC_polez2(stage));
|
dicklyon@462
|
35 end
|