https://github.com/jaysonjeg/FacialDynamicsHMM
Raw File
Tip revision: 649ff3afa26624b9962409bb67543197668171ef authored by jaysonjeg on 01 December 2021, 11:29:02 UTC
update readme
Tip revision: 649ff3a
get_cwt_mag.m
function [out] = get_cwt_mag(values,cube)
%{
Given CWT image 'values' (complex), return either amplitude or power
Optionally normalise by std or variance of input array

Inputs: 
values: nfrqs x ntimes x nsubs x nAUs
%}

square_amplitude=false; %True: Use magnitude (abs(value)).^2 instead of amplitude (abs(value))
normalize_by_variance=false; %normalize by variability or not. Setting to true makes no difference, because HMM normalizes anyway

out=abs(values);
if square_amplitude
    out=out.^2;
end

if normalize_by_variance & nargin==2
    if square_amplitude   
        variability=var(cube,1); 
    else
        variability=std(cube,1);
    end
        
    variability=reshape(variability,[size(variability,3),size(variability,2)]);
    out=out./permute(repmat(variability,1,1,size(values,1),size(values,2)),[3,4,1,2]); 
end

end

back to top