function [S,Smap] =oct_iaa_c1(X,q_i,K,eta,isel,q_rec,L)
% this fuction applies the non-recursive or recursive version of FIAA,
% dependent on the value of isel {1,2}
% X => the uniformly reshaped interference spectrum
% q => the number of iterations
% K => the length of the reconstruction grid in depth direction
% eta => a weighting of the noise matrix in R, default is 1
% isel {1,2} => chooses between nonrecursive{1} and recursive{2} reconstrution
% qrec => the number of iteration of recursive s
% L => the number of sections for the parallel processing, ideally chosen
% equal to the number of CPU cores or a multiple of that.
% S <= the IAA reconstrution

 meth=[...
 'FIAA  ';
 'RFIAA '];

[iM,iN]=size(X);
if(isel==1)  %       Fast IAA - Individual Ascan processing
%     disp(['Method ' meth(isel,:)])
    S=zeros(K,iN); Smap=S;
    parfor i=1:iN
      [S(:,i),~, Smap(:,i)]= fiaa_oct_c1(X(:,i),K,q_i,eta);
    end
      S=[S(1,:); S(end:-1:2,:)];  
      Smap=[Smap(1,:); Smap(end:-1:2,:)];  

elseif(isel==2) %       Fast IAA - Warm startup Ascan processing
%     disp(['Method ' meth(isel,:)])
    NL=floor(iN/L);
    iNL=L*NL;
    S=zeros(K,NL,L);
    Smap=S;
    bX=X(:,1:iNL);
    bX=reshape(bX,iM,NL,L);
    parfor ip=1:L
    [S(:,:,ip),Smap(:,:,ip)]=rfiaa_oct_c1(squeeze(bX(:,:,ip)),K,q_i,eta,q_rec);  
    end
    S=reshape(S,K,iNL);
    Smap=reshape(Smap,K,iNL);
    S=[S(1,:); S(end:-1:2,:)];  
    Smap=[Smap(1,:); Smap(end:-1:2,:)];  

else  
   
    disp('Wrong choice')
end

 
