% Version 1.00 stable %-------------------------------Copyright---------------------------------- % % Author: Dmytro Iatsenko % Information about these codes (e.g. links to the Video Instructions), % as well as other MatLab programs and many more can be found at % http://www.physics.lancs.ac.uk/research/nbmphysics/diats/tfr % % Related articles: % [1] D. Iatsenko, A. Stefanovska and P.V.E. McClintock, % "Linear and synchrosqueezed time-frequency representations revisited. % Part I: Overview, standards of use, related issues and algorithms." % {preprint:arXiv:1310.7215} % [2] D. Iatsenko, A. Stefanovska and P.V.E. McClintock, % "Linear and synchrosqueezed time-frequency representations revisited. % Part II: Resolution, reconstruction and concentration." % {preprint:arXiv:1310.7274} % %------------------------------Documentation------------------------------- % % [iamp,iphi,ifreq] = rectfr(tfsupp,TFR,freq,wopt) % - returns reconstructed from WFT/WT amplitude [iamp], phase [iphi] % and frequency [ifreq], each being 2xL matrix with first row % reconstructed by direct method, and second one - from the amplitude % ridge points; determines whether TFR is WFT or WT based on the % spacings between specified frequencies [freq] - linear (WFT) or % logarithmic (WT); rectfr.m is suitable only for WFT/WT, for SWFT/SWT % use ssrectfr.m instead. % % INPUT: % tfsupp: 3xL matrix % - extracted time-frequency support of the component, containing % frequencies of the TFR amplitude peaks (ridge points) in the % first row, support lower bounds (referred as \omega_-(t)/2/pi % in [1]) - in the second row, and the upper bounds (referred as % \omega_+(t)/2/pi in [1]) - in the third row. % TFR: FNxL matrix (rows correspond to frequencies, columns - to time) % - time-frequency representation (WFT or WT), to which [tfsupp] % correspond % freq: FNx1 vector % - the frequencies corresponding to the rows of [TFR] % wopt: structure returned by function wft.m or wt.m % - parameters of the window/wavelet and the simulation, returned as % a third output by functions wft, wt, sswft and sswt; [wopt] % contains all the needed information, i.e. name of the TFR, % sampling frequency, window/wavelet characteristics etc. % % NOTE: if the window/wavelet does not allow direct estimation of frequency % from WFT/WT, i.e. [wopt.omg=Inf] for WFT or [wopt.D=Inf] for WT (as % for the Morlet wavelet), corresponding to not finite \bar{\omega}_g % and D_\psi in [1], then uses hybrid frequency reconstruction % instead of the direct one. % %-------------------------------Examples----------------------------------- % % /Calculate first WFT (see wft function):/ % [WFT,freq,wopt]=wft(sig,fs,...(parameters)); % /Extract somehow the component time-frequency support from it, e.g./ % tfsupp=ecurve(WFT,freq); % /Then component'a parameters can be reconstructed from its extracted % WFT support [tfsupp] as/ % [iamp,iphi,ifreq]=rectfr(tfsupp,WFT,freq,wopt); % /For WT the same procedure is used./ % %-------------------------------------------------------------------------- function [iamp,iphi,ifreq] = rectfr(tfsupp,TFR,freq,wopt) [FN,L]=size(TFR); freq=freq(:); fs=wopt.fs; wp=wopt.wp; ifreq=ones(2,L)*NaN; iamp=ones(2,L)*NaN; iphi=ones(2,L)*NaN; tn1=find(~isnan(tfsupp(1,:)),1,'first'); tn2=find(~isnan(tfsupp(1,:)),1,'last'); %Determine the frequency resolution and transform [tfsupp] from frequencies to indices if freq(1)<=0 || std(diff(freq))tn1 && tn1 && ipeaktn1 && tn1 && ipeak