 function  [RFTO,paramTO]=makeTO(RF,param);
 %makeTO   makeTO produce RF image with Transverse Oscillations
%   [rfto] = makeTO(rf, param) introduce Transverse
%   Oscillations into the image stored in the array RF. RFTO contains RF
%   image with transverse ocillation. PARAM is a structure that contains
%   all the parameter values required for the migration (see below for more
%   details).
% 
%   [rfto,paramTO] = makeTO(rf, param) also returns the complete list of
%   parameters (including the default values).
%
%   %   PARAM is a structure that contains the following fields:
%   -------------------------------------------------------
%   1) PARAM.pitch: pitch of the transducer (in m, REQUIRED)
%   2) PARAM.Fe: sample frequency (in Hz, REQUIRED)
%   3) PARAM.c: sound velocity (in m/s, default = 1540 m/s)
%   4) PARAM.sigmax: the wanted lateral  full width at half maximum (FWHM) (in m, by default = 1)                                                
%   5) PARAM.fx0: the wanted lateral wavelengths (in m, by default = 1.5)
%   6) PARAM.interface: 1 = Interface ON (default)
%                       0 = Interface OFF
%
%
%   
%   %Examples:
%   %--------
%
%   load phantom
% 
%   param.lambdax= 1.5e-3;  %m
%   param.sigmax= 1.2e-3;   %m
%   param.pitch= 2.4500e-04;%m
%   param.Fe= 25e6;         %Hz
%   param.c= 1540;          %m/s
%   param.interface=1;      
% 
%   [RFOT param]=makeTO(migRF1(450:600,:,:),param);
%  
%   figure(1)
%   for i=1:size(migRF1,3)
%       subplot(121)
%       imagesc(inter(migRF1(450:600,:,i),2));
%       subplot(122)
%       imagesc(inter(RFOT(:,:,i),2));
%       pause(0.01)
%   end
%
%   %--------
%   Reference
%   ---------
%
%   Sebastien salles, Simon Lai, Damien Garcia, Alfred Yu, Didier Vray,
%   Hervé Liebgott1 "Estimation of arterial wall motion using ultrafast
%   imaging with transverse oscillations" Ultrasonics Symposium (IUS),
%   2014 IEEE International 
%
%   Salles, Sebastien; Garcia, Damien; Bou-Said, Benyebka; Savary, Florent;
%   Serusclat, Andre; Vray, Didier; Liebgott, Herve, "Plane wave transverse
%   oscillation (PWTO): An ultra-fast transverse oscillation imaging mode
%   performed in the Fourier domain for 2D motion estimation of the carotid
%   artery," Biomedical Imaging (ISBI), 2014 IEEE 11th International
%   Symposium on , vol., no., pp.1409,1412, April 29 2014-May 2 2014
% 
 
%--- Check input parameters ---
if ~isfield(param,'c')
    param.c = 1540; 
end
if ~isfield(param,'lambdax')
    param.lambdax = 1e-3;
end
if ~isfield(param,'sigmax')
    param.sigmax = 1.5e-3; 
end
if ~isfield(param,'interface')
    param.interface = 1; 
end

if ~isfield(param,'Fe')
    error('A sample frequency (PARAM.Fe) is required.')
end
if ~isfield(param,'pitch')
    error('A sample frequency (PARAM.pitch) is required.')
end

 if param.interface==0
     for i=1:size(RF,3)
     [RFTO(:,:,i) paramTO]=FourierFiltTO(RF(:,:,i), param);
     end
 else
     [RFTO paramTO]=Interface_TO(RF,param);
 end
 
